Kaydet (Commit) 2e302f18 authored tarafından Khaled Hosny's avatar Khaled Hosny

[harfbuzz] Follow variable naming conventions

Not that I'm a fan of Hungarian notation, but for the sake of
consistency. Fix some placement of opening braces along the way.

Change-Id: Id6ea758fd438a4040e7451430a0f3a166efdec43
üst 8f748ce0
...@@ -157,7 +157,7 @@ static bool needNextCode(sal_Unicode cChar) ...@@ -157,7 +157,7 @@ static bool needNextCode(sal_Unicode cChar)
} }
#if ENABLE_HARFBUZZ #if ENABLE_HARFBUZZ
static hb_blob_t *getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* userData) static hb_blob_t *getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* pUserData)
{ {
char pTagName[5]; char pTagName[5];
pTagName[0] = (char)(nTableTag >> 24); pTagName[0] = (char)(nTableTag >> 24);
...@@ -166,9 +166,9 @@ static hb_blob_t *getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* us ...@@ -166,9 +166,9 @@ static hb_blob_t *getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* us
pTagName[3] = (char)(nTableTag); pTagName[3] = (char)(nTableTag);
pTagName[4] = 0; pTagName[4] = 0;
ServerFont* rFont = (ServerFont*) userData; ServerFont* pFont = (ServerFont*) pUserData;
sal_uLong nLength; sal_uLong nLength;
const unsigned char* pBuffer = rFont->GetTable(pTagName, &nLength); const unsigned char* pBuffer = pFont->GetTable(pTagName, &nLength);
hb_blob_t* pBlob = NULL; hb_blob_t* pBlob = NULL;
if (pBuffer != NULL) if (pBuffer != NULL)
...@@ -177,61 +177,61 @@ static hb_blob_t *getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* us ...@@ -177,61 +177,61 @@ static hb_blob_t *getFontTable(hb_face_t* /*face*/, hb_tag_t nTableTag, void* us
return pBlob; return pBlob;
} }
static hb_bool_t getFontGlyph(hb_font_t* /*font*/, void* fontData, static hb_bool_t getFontGlyph(hb_font_t* /*font*/, void* pFontData,
hb_codepoint_t ch, hb_codepoint_t vs, hb_codepoint_t ch, hb_codepoint_t vs,
hb_codepoint_t* nGlyphIndex, hb_codepoint_t* nGlyphIndex,
void* /*userData*/) void* /*pUserData*/)
{ {
ServerFont* rFont = (ServerFont*) fontData; ServerFont* pFont = (ServerFont*) pFontData;
*nGlyphIndex = 0; *nGlyphIndex = 0;
if (vs) if (vs)
*nGlyphIndex = rFont->GetRawGlyphIndex(ch /*, vs*/); // XXX handle variation selectors *nGlyphIndex = pFont->GetRawGlyphIndex(ch /*, vs*/); // XXX handle variation selectors
if (*nGlyphIndex == 0) if (*nGlyphIndex == 0)
*nGlyphIndex = rFont->GetRawGlyphIndex(ch); *nGlyphIndex = pFont->GetRawGlyphIndex(ch);
return *nGlyphIndex != 0; return *nGlyphIndex != 0;
} }
static hb_position_t getGlyphAdvanceH(hb_font_t* /*font*/, void* fontData, static hb_position_t getGlyphAdvanceH(hb_font_t* /*font*/, void* pFontData,
hb_codepoint_t nGlyphIndex, hb_codepoint_t nGlyphIndex,
void* /*userData*/) void* /*pUserData*/)
{ {
ServerFont* rFont = (ServerFont*) fontData; ServerFont* pFont = (ServerFont*) pFontData;
const GlyphMetric& rGM = rFont->GetGlyphMetric(nGlyphIndex); const GlyphMetric& rGM = pFont->GetGlyphMetric(nGlyphIndex);
return rGM.GetCharWidth() << 6; return rGM.GetCharWidth() << 6;
} }
static hb_position_t getGlyphAdvanceV(hb_font_t* /*font*/, void* /*fontData*/, static hb_position_t getGlyphAdvanceV(hb_font_t* /*font*/, void* /*pFontData*/,
hb_codepoint_t /*nGlyphIndex*/, hb_codepoint_t /*nGlyphIndex*/,
void* /*userData*/) void* /*pUserData*/)
{ {
// XXX: vertical metrics // XXX: vertical metrics
return 0; return 0;
} }
static hb_bool_t getGlyphOriginH(hb_font_t* /*font*/, void* /*fontData*/, static hb_bool_t getGlyphOriginH(hb_font_t* /*font*/, void* /*pFontData*/,
hb_codepoint_t /*nGlyphIndex*/, hb_codepoint_t /*nGlyphIndex*/,
hb_position_t* /*x*/, hb_position_t* /*y*/, hb_position_t* /*x*/, hb_position_t* /*y*/,
void* /*userData*/) void* /*pUserData*/)
{ {
// the horizontal origin is always (0, 0) // the horizontal origin is always (0, 0)
return true; return true;
} }
static hb_bool_t getGlyphOriginV(hb_font_t* /*font*/, void* /*fontData*/, static hb_bool_t getGlyphOriginV(hb_font_t* /*font*/, void* /*pFontData*/,
hb_codepoint_t /*nGlyphIndex*/, hb_codepoint_t /*nGlyphIndex*/,
hb_position_t* /*x*/, hb_position_t* /*y*/, hb_position_t* /*x*/, hb_position_t* /*y*/,
void* /*userData*/) void* /*pUserData*/)
{ {
// XXX: vertical origin // XXX: vertical origin
return true; return true;
} }
static hb_position_t getGlyphKerningH(hb_font_t* /*font*/, void* fontData, static hb_position_t getGlyphKerningH(hb_font_t* /*font*/, void* pFontData,
hb_codepoint_t nGlyphIndex1, hb_codepoint_t nGlyphIndex2, hb_codepoint_t nGlyphIndex1, hb_codepoint_t nGlyphIndex2,
void* /*userData*/) void* /*pUserData*/)
{ {
// This callback is for old style 'kern' table, GPOS kerning is handled by HarfBuzz directly // This callback is for old style 'kern' table, GPOS kerning is handled by HarfBuzz directly
...@@ -241,8 +241,8 @@ static hb_position_t getGlyphKerningH(hb_font_t* /*font*/, void* fontData, ...@@ -241,8 +241,8 @@ static hb_position_t getGlyphKerningH(hb_font_t* /*font*/, void* fontData,
// other implementattions should be removed, don't seem to be used // other implementattions should be removed, don't seem to be used
// anywhere. // anywhere.
ServerFont* rFont = (ServerFont*) fontData; ServerFont* pFont = (ServerFont*) pFontData;
FT_Face aFace = rFont->GetFtFace(); FT_Face aFace = pFont->GetFtFace();
FT_Error error; FT_Error error;
FT_Vector kerning; FT_Vector kerning;
...@@ -257,48 +257,52 @@ static hb_position_t getGlyphKerningH(hb_font_t* /*font*/, void* fontData, ...@@ -257,48 +257,52 @@ static hb_position_t getGlyphKerningH(hb_font_t* /*font*/, void* fontData,
return ret; return ret;
} }
static hb_position_t getGlyphKerningV(hb_font_t* /*font*/, void* /*fontData*/, static hb_position_t getGlyphKerningV(hb_font_t* /*font*/, void* /*pFontData*/,
hb_codepoint_t /*nGlyphIndex1*/, hb_codepoint_t /*nGlyphIndex2*/, hb_codepoint_t /*nGlyphIndex1*/, hb_codepoint_t /*nGlyphIndex2*/,
void* /*userData*/) void* /*pUserData*/)
{ {
// XXX vertical kerning // XXX vertical kerning
return 0; return 0;
} }
static hb_bool_t getGlyphExtents(hb_font_t* /*font*/, void* fontData, static hb_bool_t getGlyphExtents(hb_font_t* /*font*/, void* pFontData,
hb_codepoint_t nGlyphIndex, hb_codepoint_t nGlyphIndex,
hb_glyph_extents_t* extents, hb_glyph_extents_t* pExtents,
void* /*userData*/) void* /*pUserData*/)
{ {
ServerFont* rFont = (ServerFont*) fontData; ServerFont* pFont = (ServerFont*) pFontData;
FT_Face aFace = rFont->GetFtFace(); FT_Face aFace = pFont->GetFtFace();
FT_Error error; FT_Error error;
error = FT_Load_Glyph(aFace, nGlyphIndex, FT_LOAD_DEFAULT); error = FT_Load_Glyph(aFace, nGlyphIndex, FT_LOAD_DEFAULT);
if (!error) { if (!error)
extents->x_bearing = aFace->glyph->metrics.horiBearingX; {
extents->y_bearing = aFace->glyph->metrics.horiBearingY; pExtents->x_bearing = aFace->glyph->metrics.horiBearingX;
extents->width = aFace->glyph->metrics.width; pExtents->y_bearing = aFace->glyph->metrics.horiBearingY;
extents->height = -aFace->glyph->metrics.height; pExtents->width = aFace->glyph->metrics.width;
pExtents->height = -aFace->glyph->metrics.height;
} }
return !error; return !error;
} }
static hb_bool_t getGlyphContourPoint(hb_font_t* /*font*/, void* fontData, static hb_bool_t getGlyphContourPoint(hb_font_t* /*font*/, void* pFontData,
hb_codepoint_t nGlyphIndex, unsigned int nPointIndex, hb_codepoint_t nGlyphIndex, unsigned int nPointIndex,
hb_position_t *x, hb_position_t *y, hb_position_t *x, hb_position_t *y,
void* /*userData*/) void* /*pUserData*/)
{ {
ServerFont* rFont = (ServerFont*) fontData; ServerFont* pFont = (ServerFont*) pFontData;
FT_Face aFace = rFont->GetFtFace(); FT_Face aFace = pFont->GetFtFace();
FT_Error error; FT_Error error;
bool ret = false; bool ret = false;
error = FT_Load_Glyph(aFace, nGlyphIndex, FT_LOAD_DEFAULT); error = FT_Load_Glyph(aFace, nGlyphIndex, FT_LOAD_DEFAULT);
if (!error) { if (!error)
if (aFace->glyph->format == FT_GLYPH_FORMAT_OUTLINE) { {
if (nPointIndex < (unsigned int) aFace->glyph->outline.n_points) { if (aFace->glyph->format == FT_GLYPH_FORMAT_OUTLINE)
{
if (nPointIndex < (unsigned int) aFace->glyph->outline.n_points)
{
*x = aFace->glyph->outline.points[nPointIndex].x; *x = aFace->glyph->outline.points[nPointIndex].x;
*y = aFace->glyph->outline.points[nPointIndex].y; *y = aFace->glyph->outline.points[nPointIndex].y;
ret = true; ret = true;
...@@ -330,7 +334,7 @@ class HbLayoutEngine : public ServerFontLayoutEngine ...@@ -330,7 +334,7 @@ class HbLayoutEngine : public ServerFontLayoutEngine
{ {
private: private:
UScriptCode meScriptCode; UScriptCode meScriptCode;
hb_face_t* maHbFace; hb_face_t* mpHbFace;
int fUnitsPerEM; int fUnitsPerEM;
public: public:
...@@ -342,20 +346,20 @@ public: ...@@ -342,20 +346,20 @@ public:
HbLayoutEngine::HbLayoutEngine(ServerFont& rServerFont) HbLayoutEngine::HbLayoutEngine(ServerFont& rServerFont)
: meScriptCode(USCRIPT_INVALID_CODE), : meScriptCode(USCRIPT_INVALID_CODE),
maHbFace(NULL), mpHbFace(NULL),
fUnitsPerEM(0) fUnitsPerEM(0)
{ {
FT_Face aFtFace = rServerFont.GetFtFace(); FT_Face aFtFace = rServerFont.GetFtFace();
fUnitsPerEM = rServerFont.GetEmUnits(); fUnitsPerEM = rServerFont.GetEmUnits();
maHbFace = hb_face_create_for_tables(getFontTable, &rServerFont, NULL); mpHbFace = hb_face_create_for_tables(getFontTable, &rServerFont, NULL);
hb_face_set_index(maHbFace, aFtFace->face_index); hb_face_set_index(mpHbFace, aFtFace->face_index);
hb_face_set_upem(maHbFace, fUnitsPerEM); hb_face_set_upem(mpHbFace, fUnitsPerEM);
} }
HbLayoutEngine::~HbLayoutEngine() HbLayoutEngine::~HbLayoutEngine()
{ {
hb_face_destroy(maHbFace); hb_face_destroy(mpHbFace);
} }
bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
...@@ -363,12 +367,12 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) ...@@ -363,12 +367,12 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
ServerFont& rFont = rLayout.GetServerFont(); ServerFont& rFont = rLayout.GetServerFont();
FT_Face aFtFace = rFont.GetFtFace(); FT_Face aFtFace = rFont.GetFtFace();
hb_font_t *aHbFont = hb_font_create(maHbFace); hb_font_t *pHbFont = hb_font_create(mpHbFace);
hb_font_set_funcs(aHbFont, getFontFuncs(), &rFont, NULL); hb_font_set_funcs(pHbFont, getFontFuncs(), &rFont, NULL);
hb_font_set_scale(aHbFont, hb_font_set_scale(pHbFont,
((uint64_t) aFtFace->size->metrics.x_scale * (uint64_t) fUnitsPerEM) >> 16, ((uint64_t) aFtFace->size->metrics.x_scale * (uint64_t) fUnitsPerEM) >> 16,
((uint64_t) aFtFace->size->metrics.y_scale * (uint64_t) fUnitsPerEM) >> 16); ((uint64_t) aFtFace->size->metrics.y_scale * (uint64_t) fUnitsPerEM) >> 16);
hb_font_set_ppem(aHbFont, aFtFace->size->metrics.x_ppem, aFtFace->size->metrics.y_ppem); hb_font_set_ppem(pHbFont, aFtFace->size->metrics.x_ppem, aFtFace->size->metrics.y_ppem);
// allocate temporary arrays, note: round to even // allocate temporary arrays, note: round to even
int nGlyphCapacity = (3 * (rArgs.mnEndCharPos - rArgs.mnMinCharPos) | 15) + 1; int nGlyphCapacity = (3 * (rArgs.mnEndCharPos - rArgs.mnMinCharPos) | 15) + 1;
...@@ -409,21 +413,21 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) ...@@ -409,21 +413,21 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
LanguageTag aLangTag(rArgs.meLanguage); LanguageTag aLangTag(rArgs.meLanguage);
OString sLanguage = OUStringToOString(aLangTag.getLanguage(), RTL_TEXTENCODING_UTF8); OString sLanguage = OUStringToOString(aLangTag.getLanguage(), RTL_TEXTENCODING_UTF8);
hb_buffer_t *aHbBuffer = hb_buffer_create(); hb_buffer_t *pHbBuffer = hb_buffer_create();
hb_buffer_set_direction(aHbBuffer, bRightToLeft ? HB_DIRECTION_RTL: HB_DIRECTION_LTR); hb_buffer_set_direction(pHbBuffer, bRightToLeft ? HB_DIRECTION_RTL: HB_DIRECTION_LTR);
hb_buffer_set_script(aHbBuffer, hb_icu_script_to_script(eScriptCode)); hb_buffer_set_script(pHbBuffer, hb_icu_script_to_script(eScriptCode));
hb_buffer_set_language(aHbBuffer, hb_language_from_string(sLanguage.getStr(), -1)); hb_buffer_set_language(pHbBuffer, hb_language_from_string(sLanguage.getStr(), -1));
hb_buffer_add_utf16(aHbBuffer, rArgs.mpStr, nRunLen, nMinRunPos, nRunLen); hb_buffer_add_utf16(pHbBuffer, rArgs.mpStr, nRunLen, nMinRunPos, nRunLen);
hb_shape(aHbFont, aHbBuffer, NULL, 0); hb_shape(pHbFont, pHbBuffer, NULL, 0);
int nRunGlyphCount = hb_buffer_get_length(aHbBuffer); int nRunGlyphCount = hb_buffer_get_length(pHbBuffer);
hb_glyph_info_t *aHbGlyphInfos = hb_buffer_get_glyph_infos(aHbBuffer, NULL); hb_glyph_info_t *pHbGlyphInfos = hb_buffer_get_glyph_infos(pHbBuffer, NULL);
hb_glyph_position_t *aHbPositions = hb_buffer_get_glyph_positions(aHbBuffer, NULL); hb_glyph_position_t *pHbPositions = hb_buffer_get_glyph_positions(pHbBuffer, NULL);
int32_t nLastCluster = -1; int32_t nLastCluster = -1;
for (int i = 0; i < nRunGlyphCount; ++i) { for (int i = 0; i < nRunGlyphCount; ++i) {
int32_t nGlyphIndex = aHbGlyphInfos[i].codepoint; int32_t nGlyphIndex = pHbGlyphInfos[i].codepoint;
int32_t nCluster = aHbGlyphInfos[i].cluster; int32_t nCluster = pHbGlyphInfos[i].cluster;
int32_t nCharPos = nCluster; int32_t nCharPos = nCluster;
// if needed request glyph fallback by updating LayoutArgs // if needed request glyph fallback by updating LayoutArgs
...@@ -460,13 +464,13 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) ...@@ -460,13 +464,13 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
if (bInCluster) if (bInCluster)
nGlyphFlags |= GlyphItem::IS_IN_CLUSTER; nGlyphFlags |= GlyphItem::IS_IN_CLUSTER;
if (hb_ot_layout_get_glyph_class(maHbFace, nGlyphIndex) == HB_OT_LAYOUT_GLYPH_CLASS_MARK) if (hb_ot_layout_get_glyph_class(mpHbFace, nGlyphIndex) == HB_OT_LAYOUT_GLYPH_CLASS_MARK)
nGlyphFlags |= GlyphItem::IS_DIACRITIC; nGlyphFlags |= GlyphItem::IS_DIACRITIC;
int32_t nXOffset = aHbPositions[i].x_offset >> 6; int32_t nXOffset = pHbPositions[i].x_offset >> 6;
int32_t nYOffset = aHbPositions[i].y_offset >> 6; int32_t nYOffset = pHbPositions[i].y_offset >> 6;
int32_t nXAdvance = aHbPositions[i].x_advance >> 6; int32_t nXAdvance = pHbPositions[i].x_advance >> 6;
int32_t nYAdvance = aHbPositions[i].y_advance >> 6; int32_t nYAdvance = pHbPositions[i].y_advance >> 6;
Point aNewPos = Point(aCurrPos.X() + nXOffset, -(aCurrPos.Y() + nYOffset)); Point aNewPos = Point(aCurrPos.X() + nXOffset, -(aCurrPos.Y() + nYOffset));
...@@ -479,10 +483,10 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) ...@@ -479,10 +483,10 @@ bool HbLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
aCurrPos.Y() += nYAdvance; aCurrPos.Y() += nYAdvance;
} }
hb_buffer_destroy(aHbBuffer); hb_buffer_destroy(pHbBuffer);
} }
hb_font_destroy(aHbFont); hb_font_destroy(pHbFont);
// sort glyphs in visual order // sort glyphs in visual order
// and then in logical order (e.g. diacritics after cluster start) // and then in logical order (e.g. diacritics after cluster start)
...@@ -1039,7 +1043,7 @@ bool IcuLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) ...@@ -1039,7 +1043,7 @@ bool IcuLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
sal_UCS4 aChar = rArgs.mpStr[ nCharPos ]; sal_UCS4 aChar = rArgs.mpStr[ nCharPos ];
nGlyphIndex = rFont.FixupGlyphIndex( nGlyphIndex, aChar ); nGlyphIndex = rFont.FixupGlyphIndex( nGlyphIndex, aChar );
// #i99367# HACK: try to detect all diacritics // i#99367# HACK: try to detect all diacritics
if( aChar>=0x0300 && aChar<0x2100 ) if( aChar>=0x0300 && aChar<0x2100 )
bDiacritic = IsDiacritic( aChar ); bDiacritic = IsDiacritic( aChar );
} }
...@@ -1051,7 +1055,7 @@ bool IcuLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs) ...@@ -1051,7 +1055,7 @@ bool IcuLayoutEngine::layout(ServerFontLayout& rLayout, ImplLayoutArgs& rArgs)
int nNewWidth = nGlyphWidth; int nNewWidth = nGlyphWidth;
if( nGlyphWidth <= 0 ) if( nGlyphWidth <= 0 )
bDiacritic |= true; bDiacritic |= true;
// #i99367# force all diacritics to zero width // i#99367# force all diacritics to zero width
// TODO: we need mnOrigWidth/mnLogicWidth/mnNewWidth // TODO: we need mnOrigWidth/mnLogicWidth/mnNewWidth
else if( bDiacritic ) else if( bDiacritic )
nGlyphWidth = nNewWidth = 0; nGlyphWidth = nNewWidth = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment