diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-15 21:52:35 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-15 21:52:35 +0000 |
commit | 754dfebd945868c46111553bb51b2802ddbbf29c (patch) | |
tree | 3fb0a4bbe75437f3d570fe5c7992221d166131d5 /third_party/harfbuzz | |
parent | 4e25d214a2be8380501a1b1d9dcd958cb5778f19 (diff) | |
download | chromium_src-754dfebd945868c46111553bb51b2802ddbbf29c.zip chromium_src-754dfebd945868c46111553bb51b2802ddbbf29c.tar.gz chromium_src-754dfebd945868c46111553bb51b2802ddbbf29c.tar.bz2 |
linux: hack around arabic advances in harfbuzz
Arabic vowels in some fonts (Times New Roman, at least) have
non-zero advances, when they should be zero. Pango does a hack very
similar to this to work around the same problem.
Review URL: http://codereview.chromium.org/543067
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36418 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/harfbuzz')
-rw-r--r-- | third_party/harfbuzz/src/harfbuzz-arabic.c | 1 | ||||
-rw-r--r-- | third_party/harfbuzz/src/harfbuzz-shaper.cpp | 20 | ||||
-rw-r--r-- | third_party/harfbuzz/src/harfbuzz-shaper.h | 6 |
3 files changed, 26 insertions, 1 deletions
diff --git a/third_party/harfbuzz/src/harfbuzz-arabic.c b/third_party/harfbuzz/src/harfbuzz-arabic.c index 3837087..ce2ca6c 100644 --- a/third_party/harfbuzz/src/harfbuzz-arabic.c +++ b/third_party/harfbuzz/src/harfbuzz-arabic.c @@ -1107,6 +1107,7 @@ HB_Bool HB_ArabicShape(HB_ShaperItem *item) assert(item->item.script == HB_Script_Arabic || item->item.script == HB_Script_Syriac || item->item.script == HB_Script_Nko); + item->shaperFlags |= HB_ShaperFlag_ForceMarksToZeroWidth; #ifndef NO_OPENTYPE if (HB_SelectScript(item, item->item.script == HB_Script_Arabic ? arabic_features : syriac_features)) { diff --git a/third_party/harfbuzz/src/harfbuzz-shaper.cpp b/third_party/harfbuzz/src/harfbuzz-shaper.cpp index 2b0dfde..f1606e6 100644 --- a/third_party/harfbuzz/src/harfbuzz-shaper.cpp +++ b/third_party/harfbuzz/src/harfbuzz-shaper.cpp @@ -1189,6 +1189,24 @@ HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const hb_uint32 *properties) return true; } +/* See comments near the definition of HB_ShaperFlag_ForceMarksToZeroWidth for a description + of why this function exists. */ +void HB_FixupZeroWidth(HB_ShaperItem *item) +{ + HB_UShort property; + + if (!item->face->gdef) + return; + + for (unsigned int i = 0; i < item->num_glyphs; ++i) { + /* If the glyph is a mark, force its advance to zero. */ + if (HB_GDEF_Get_Glyph_Property (item->face->gdef, item->glyphs[i], &property) == HB_Err_Ok && + property == HB_GDEF_MARK) { + item->advances[i] = 0; + } + } +} + HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int availableGlyphs, HB_Bool doLogClusters) { HB_Face face = item->face; @@ -1203,6 +1221,8 @@ HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int availableGlyphs, HB_Bool do if (!face->glyphs_substituted && !glyphs_positioned) { HB_GetGlyphAdvances(item); + if (item->face->current_flags & HB_ShaperFlag_ForceMarksToZeroWidth) + HB_FixupZeroWidth(item); return true; // nothing to do for us } diff --git a/third_party/harfbuzz/src/harfbuzz-shaper.h b/third_party/harfbuzz/src/harfbuzz-shaper.h index f7c7714..33fc85a 100644 --- a/third_party/harfbuzz/src/harfbuzz-shaper.h +++ b/third_party/harfbuzz/src/harfbuzz-shaper.h @@ -154,7 +154,11 @@ typedef enum { typedef enum { HB_ShaperFlag_Default = 0, HB_ShaperFlag_NoKerning = 1, - HB_ShaperFlag_UseDesignMetrics = 2 + HB_ShaperFlag_UseDesignMetrics = 1 << 1, + /* Arabic vowels in some fonts (Times New Roman, at least) have + non-zero advances, when they should be zero. Setting this shaper + flag causes us to zero out the advances for mark glyphs. */ + HB_ShaperFlag_ForceMarksToZeroWidth = 1 << 2 } HB_ShaperFlag; /* |