OLD | NEW |
| (Empty) |
1 diff --git a/contrib/harfbuzz-unicode.c b/contrib/harfbuzz-unicode.c | |
2 index 72c5cf2..49e47b0 100644 | |
3 --- a/contrib/harfbuzz-unicode.c | |
4 +++ b/contrib/harfbuzz-unicode.c | |
5 @@ -120,7 +120,6 @@ hb_utf16_script_run_next(unsigned *num_code_points, HB_Scrip
tItem *output, | |
6 current_script = script; | |
7 continue; | |
8 } else if (script == HB_Script_Inherited) { | |
9 - current_script = script; | |
10 continue; | |
11 } else { | |
12 *iter = prev_iter; | |
13 @@ -171,7 +170,10 @@ hb_utf16_script_run_prev(unsigned *num_code_points, HB_Scri
ptItem *output, | |
14 current_script = script; | |
15 continue; | |
16 } else if (script == HB_Script_Inherited) { | |
17 - current_script = script; | |
18 + // Just assume that whatever follows this combining character is within | |
19 + // the same script. This is incorrect if you had language1 + combining | |
20 + // char + language 2, but that is rare and this code is suspicious | |
21 + // anyway. | |
22 continue; | |
23 } else { | |
24 *iter = prev_iter; | |
25 diff --git a/src/harfbuzz-arabic.c b/src/harfbuzz-arabic.c | |
26 index 51f839a..af40bf8 100644 | |
27 --- a/src/harfbuzz-arabic.c | |
28 +++ b/src/harfbuzz-arabic.c | |
29 @@ -1107,6 +1107,7 @@ HB_Bool HB_ArabicShape(HB_ShaperItem *item) | |
30 assert(item->item.script == HB_Script_Arabic || item->item.script == HB_Scr
ipt_Syriac | |
31 || item->item.script == HB_Script_Nko); | |
32 | |
33 + item->shaperFlags |= HB_ShaperFlag_ForceMarksToZeroWidth; | |
34 #ifndef NO_OPENTYPE | |
35 | |
36 if (HB_SelectScript(item, item->item.script == HB_Script_Arabic ? arabic_fe
atures : syriac_features)) { | |
37 diff --git a/src/harfbuzz-shaper.cpp b/src/harfbuzz-shaper.cpp | |
38 index 7fd04a9..66f0ea6 100644 | |
39 --- a/src/harfbuzz-shaper.cpp | |
40 +++ b/src/harfbuzz-shaper.cpp | |
41 @@ -430,8 +430,6 @@ void HB_HeuristicSetGlyphAttributes(HB_ShaperItem *item) | |
42 | |
43 // ### zeroWidth and justification are missing here!!!!! | |
44 | |
45 - assert(item->num_glyphs <= length); | |
46 - | |
47 // qDebug("QScriptEngine::heuristicSetGlyphAttributes, num_glyphs=%d", item
->num_glyphs); | |
48 HB_GlyphAttributes *attributes = item->attributes; | |
49 unsigned short *logClusters = item->log_clusters; | |
50 @@ -448,7 +446,6 @@ void HB_HeuristicSetGlyphAttributes(HB_ShaperItem *item) | |
51 } | |
52 ++glyph_pos; | |
53 } | |
54 - assert(glyph_pos == item->num_glyphs); | |
55 | |
56 // first char in a run is never (treated as) a mark | |
57 int cStart = 0; | |
58 @@ -1151,10 +1148,12 @@ HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const hb_u
int32 *properties) | |
59 return false; | |
60 face->tmpLogClusters = tmpLogClusters; | |
61 | |
62 + const int itemLength = item->item.length; | |
63 + assert(itemLength > 0); | |
64 for (int i = 0; i < face->length; ++i) { | |
65 hb_buffer_add_glyph(face->buffer, item->glyphs[i], properties ? propert
ies[i] : 0, i); | |
66 face->tmpAttributes[i] = item->attributes[i]; | |
67 - face->tmpLogClusters[i] = item->log_clusters[i]; | |
68 + face->tmpLogClusters[i] = i < itemLength ? item->log_clusters[i] : item
->log_clusters[itemLength - 1]; | |
69 } | |
70 | |
71 #ifdef OT_DEBUG | |
72 @@ -1190,6 +1189,24 @@ HB_Bool HB_OpenTypeShape(HB_ShaperItem *item, const hb_ui
nt32 *properties) | |
73 return true; | |
74 } | |
75 | |
76 +/* See comments near the definition of HB_ShaperFlag_ForceMarksToZeroWidth for
a description | |
77 + of why this function exists. */ | |
78 +void HB_FixupZeroWidth(HB_ShaperItem *item) | |
79 +{ | |
80 + HB_UShort property; | |
81 + | |
82 + if (!item->face->gdef) | |
83 + return; | |
84 + | |
85 + for (unsigned int i = 0; i < item->num_glyphs; ++i) { | |
86 + /* If the glyph is a mark, force its advance to zero. */ | |
87 + if (HB_GDEF_Get_Glyph_Property (item->face->gdef, item->glyphs[i], &pro
perty) == HB_Err_Ok && | |
88 + property == HB_GDEF_MARK) { | |
89 + item->advances[i] = 0; | |
90 + } | |
91 + } | |
92 +} | |
93 + | |
94 HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int availableGlyphs, HB_Bool d
oLogClusters) | |
95 { | |
96 HB_Face face = item->face; | |
97 @@ -1204,6 +1221,8 @@ HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int avail
ableGlyphs, HB_Bool do | |
98 | |
99 if (!face->glyphs_substituted && !glyphs_positioned) { | |
100 HB_GetGlyphAdvances(item); | |
101 + if (item->face->current_flags & HB_ShaperFlag_ForceMarksToZeroWidth) | |
102 + HB_FixupZeroWidth(item); | |
103 return true; // nothing to do for us | |
104 } | |
105 | |
106 diff --git a/src/harfbuzz-shaper.h b/src/harfbuzz-shaper.h | |
107 index ab5c07a..72c9aa3 100644 | |
108 --- a/src/harfbuzz-shaper.h | |
109 +++ b/src/harfbuzz-shaper.h | |
110 @@ -170,7 +170,11 @@ typedef enum { | |
111 typedef enum { | |
112 HB_ShaperFlag_Default = 0, | |
113 HB_ShaperFlag_NoKerning = 1, | |
114 - HB_ShaperFlag_UseDesignMetrics = 2 | |
115 + HB_ShaperFlag_UseDesignMetrics = 1 << 1, | |
116 + /* Arabic vowels in some fonts (Times New Roman, at least) have | |
117 + non-zero advances, when they should be zero. Setting this shaper | |
118 + flag causes us to zero out the advances for mark glyphs. */ | |
119 + HB_ShaperFlag_ForceMarksToZeroWidth = 1 << 2 | |
120 } HB_ShaperFlag; | |
121 | |
122 /* | |
123 | |
124 diff --git a/third_party/harfbuzz/contrib/harfbuzz-freetype.c b/third_party/harf
buzz | |
125 index a2962df..f6a1e1a 100644 | |
126 --- a/third_party/harfbuzz/contrib/harfbuzz-freetype.c | |
127 +++ b/third_party/harfbuzz/contrib/harfbuzz-freetype.c | |
128 @@ -21,7 +21,8 @@ hb_freetype_string_to_glyphs(HB_Font font, | |
129 if (len > *numGlyphs) | |
130 return 0; | |
131 | |
132 - size_t i = 0, j = 0; | |
133 + ssize_t i = 0; | |
134 + hb_uint32 j = 0; | |
135 while (i < len) { | |
136 const uint32_t cp = utf16_to_code_point(chars, len, &i); | |
137 glyphs[j++] = FT_Get_Char_Index(face, cp); | |
138 @@ -53,7 +54,7 @@ static HB_Bool | |
139 hb_freetype_can_render(HB_Font font, const HB_UChar16 *chars, hb_uint32 len) { | |
140 FT_Face face = (FT_Face)font->userData; | |
141 | |
142 - size_t i = 0; | |
143 + ssize_t i = 0; | |
144 while (i < len) { | |
145 const uint32_t cp = utf16_to_code_point(chars, len, &i); | |
146 if (FT_Get_Char_Index(face, cp) == 0) | |
OLD | NEW |