Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/text/qharfbuzzng.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | - | |||||||
5 | - | |||||||
6 | - | |||||||
7 | - | |||||||
8 | - | |||||||
9 | static const hb_script_t _qtscript_to_hbscript[] = { | - | ||||||
10 | HB_SCRIPT_UNKNOWN, | - | ||||||
11 | HB_SCRIPT_INHERITED, | - | ||||||
12 | HB_SCRIPT_COMMON, | - | ||||||
13 | - | |||||||
14 | HB_SCRIPT_LATIN, | - | ||||||
15 | HB_SCRIPT_GREEK, | - | ||||||
16 | HB_SCRIPT_CYRILLIC, | - | ||||||
17 | HB_SCRIPT_ARMENIAN, | - | ||||||
18 | HB_SCRIPT_HEBREW, | - | ||||||
19 | HB_SCRIPT_ARABIC, | - | ||||||
20 | HB_SCRIPT_SYRIAC, | - | ||||||
21 | HB_SCRIPT_THAANA, | - | ||||||
22 | HB_SCRIPT_DEVANAGARI, | - | ||||||
23 | HB_SCRIPT_BENGALI, | - | ||||||
24 | HB_SCRIPT_GURMUKHI, | - | ||||||
25 | HB_SCRIPT_GUJARATI, | - | ||||||
26 | HB_SCRIPT_ORIYA, | - | ||||||
27 | HB_SCRIPT_TAMIL, | - | ||||||
28 | HB_SCRIPT_TELUGU, | - | ||||||
29 | HB_SCRIPT_KANNADA, | - | ||||||
30 | HB_SCRIPT_MALAYALAM, | - | ||||||
31 | HB_SCRIPT_SINHALA, | - | ||||||
32 | HB_SCRIPT_THAI, | - | ||||||
33 | HB_SCRIPT_LAO, | - | ||||||
34 | HB_SCRIPT_TIBETAN, | - | ||||||
35 | HB_SCRIPT_MYANMAR, | - | ||||||
36 | HB_SCRIPT_GEORGIAN, | - | ||||||
37 | HB_SCRIPT_HANGUL, | - | ||||||
38 | HB_SCRIPT_ETHIOPIC, | - | ||||||
39 | HB_SCRIPT_CHEROKEE, | - | ||||||
40 | HB_SCRIPT_CANADIAN_SYLLABICS, | - | ||||||
41 | HB_SCRIPT_OGHAM, | - | ||||||
42 | HB_SCRIPT_RUNIC, | - | ||||||
43 | HB_SCRIPT_KHMER, | - | ||||||
44 | HB_SCRIPT_MONGOLIAN, | - | ||||||
45 | HB_SCRIPT_HIRAGANA, | - | ||||||
46 | HB_SCRIPT_KATAKANA, | - | ||||||
47 | HB_SCRIPT_BOPOMOFO, | - | ||||||
48 | HB_SCRIPT_HAN, | - | ||||||
49 | HB_SCRIPT_YI, | - | ||||||
50 | HB_SCRIPT_OLD_ITALIC, | - | ||||||
51 | HB_SCRIPT_GOTHIC, | - | ||||||
52 | HB_SCRIPT_DESERET, | - | ||||||
53 | HB_SCRIPT_TAGALOG, | - | ||||||
54 | HB_SCRIPT_HANUNOO, | - | ||||||
55 | HB_SCRIPT_BUHID, | - | ||||||
56 | HB_SCRIPT_TAGBANWA, | - | ||||||
57 | HB_SCRIPT_COPTIC, | - | ||||||
58 | - | |||||||
59 | - | |||||||
60 | HB_SCRIPT_LIMBU, | - | ||||||
61 | HB_SCRIPT_TAI_LE, | - | ||||||
62 | HB_SCRIPT_LINEAR_B, | - | ||||||
63 | HB_SCRIPT_UGARITIC, | - | ||||||
64 | HB_SCRIPT_SHAVIAN, | - | ||||||
65 | HB_SCRIPT_OSMANYA, | - | ||||||
66 | HB_SCRIPT_CYPRIOT, | - | ||||||
67 | HB_SCRIPT_BRAILLE, | - | ||||||
68 | - | |||||||
69 | - | |||||||
70 | HB_SCRIPT_BUGINESE, | - | ||||||
71 | HB_SCRIPT_NEW_TAI_LUE, | - | ||||||
72 | HB_SCRIPT_GLAGOLITIC, | - | ||||||
73 | HB_SCRIPT_TIFINAGH, | - | ||||||
74 | HB_SCRIPT_SYLOTI_NAGRI, | - | ||||||
75 | HB_SCRIPT_OLD_PERSIAN, | - | ||||||
76 | HB_SCRIPT_KHAROSHTHI, | - | ||||||
77 | - | |||||||
78 | - | |||||||
79 | HB_SCRIPT_BALINESE, | - | ||||||
80 | HB_SCRIPT_CUNEIFORM, | - | ||||||
81 | HB_SCRIPT_PHOENICIAN, | - | ||||||
82 | HB_SCRIPT_PHAGS_PA, | - | ||||||
83 | HB_SCRIPT_NKO, | - | ||||||
84 | - | |||||||
85 | - | |||||||
86 | HB_SCRIPT_SUNDANESE, | - | ||||||
87 | HB_SCRIPT_LEPCHA, | - | ||||||
88 | HB_SCRIPT_OL_CHIKI, | - | ||||||
89 | HB_SCRIPT_VAI, | - | ||||||
90 | HB_SCRIPT_SAURASHTRA, | - | ||||||
91 | HB_SCRIPT_KAYAH_LI, | - | ||||||
92 | HB_SCRIPT_REJANG, | - | ||||||
93 | HB_SCRIPT_LYCIAN, | - | ||||||
94 | HB_SCRIPT_CARIAN, | - | ||||||
95 | HB_SCRIPT_LYDIAN, | - | ||||||
96 | HB_SCRIPT_CHAM, | - | ||||||
97 | - | |||||||
98 | - | |||||||
99 | HB_SCRIPT_TAI_THAM, | - | ||||||
100 | HB_SCRIPT_TAI_VIET, | - | ||||||
101 | HB_SCRIPT_AVESTAN, | - | ||||||
102 | HB_SCRIPT_EGYPTIAN_HIEROGLYPHS, | - | ||||||
103 | HB_SCRIPT_SAMARITAN, | - | ||||||
104 | HB_SCRIPT_LISU, | - | ||||||
105 | HB_SCRIPT_BAMUM, | - | ||||||
106 | HB_SCRIPT_JAVANESE, | - | ||||||
107 | HB_SCRIPT_MEETEI_MAYEK, | - | ||||||
108 | HB_SCRIPT_IMPERIAL_ARAMAIC, | - | ||||||
109 | HB_SCRIPT_OLD_SOUTH_ARABIAN, | - | ||||||
110 | HB_SCRIPT_INSCRIPTIONAL_PARTHIAN, | - | ||||||
111 | HB_SCRIPT_INSCRIPTIONAL_PAHLAVI, | - | ||||||
112 | HB_SCRIPT_OLD_TURKIC, | - | ||||||
113 | HB_SCRIPT_KAITHI, | - | ||||||
114 | - | |||||||
115 | - | |||||||
116 | HB_SCRIPT_BATAK, | - | ||||||
117 | HB_SCRIPT_BRAHMI, | - | ||||||
118 | HB_SCRIPT_MANDAIC, | - | ||||||
119 | - | |||||||
120 | - | |||||||
121 | HB_SCRIPT_CHAKMA, | - | ||||||
122 | HB_SCRIPT_MEROITIC_CURSIVE, | - | ||||||
123 | HB_SCRIPT_MEROITIC_HIEROGLYPHS, | - | ||||||
124 | HB_SCRIPT_MIAO, | - | ||||||
125 | HB_SCRIPT_SHARADA, | - | ||||||
126 | HB_SCRIPT_SORA_SOMPENG, | - | ||||||
127 | HB_SCRIPT_TAKRI, | - | ||||||
128 | - | |||||||
129 | - | |||||||
130 | HB_SCRIPT_CAUCASIAN_ALBANIAN, | - | ||||||
131 | HB_SCRIPT_BASSA_VAH, | - | ||||||
132 | HB_SCRIPT_DUPLOYAN, | - | ||||||
133 | HB_SCRIPT_ELBASAN, | - | ||||||
134 | HB_SCRIPT_GRANTHA, | - | ||||||
135 | HB_SCRIPT_PAHAWH_HMONG, | - | ||||||
136 | HB_SCRIPT_KHOJKI, | - | ||||||
137 | HB_SCRIPT_LINEAR_A, | - | ||||||
138 | HB_SCRIPT_MAHAJANI, | - | ||||||
139 | HB_SCRIPT_MANICHAEAN, | - | ||||||
140 | HB_SCRIPT_MENDE_KIKAKUI, | - | ||||||
141 | HB_SCRIPT_MODI, | - | ||||||
142 | HB_SCRIPT_MRO, | - | ||||||
143 | HB_SCRIPT_OLD_NORTH_ARABIAN, | - | ||||||
144 | HB_SCRIPT_NABATAEAN, | - | ||||||
145 | HB_SCRIPT_PALMYRENE, | - | ||||||
146 | HB_SCRIPT_PAU_CIN_HAU, | - | ||||||
147 | HB_SCRIPT_OLD_PERMIC, | - | ||||||
148 | HB_SCRIPT_PSALTER_PAHLAVI, | - | ||||||
149 | HB_SCRIPT_SIDDHAM, | - | ||||||
150 | HB_SCRIPT_KHUDAWADI, | - | ||||||
151 | HB_SCRIPT_TIRHUTA, | - | ||||||
152 | HB_SCRIPT_WARANG_CITI, | - | ||||||
153 | - | |||||||
154 | - | |||||||
155 | HB_SCRIPT_AHOM, | - | ||||||
156 | HB_SCRIPT_ANATOLIAN_HIEROGLYPHS, | - | ||||||
157 | HB_SCRIPT_HATRAN, | - | ||||||
158 | HB_SCRIPT_MULTANI, | - | ||||||
159 | HB_SCRIPT_OLD_HUNGARIAN, | - | ||||||
160 | HB_SCRIPT_SIGNWRITING | - | ||||||
161 | }; | - | ||||||
162 | static_assert(bool(QChar::ScriptCount == sizeof(_qtscript_to_hbscript) / sizeof(_qtscript_to_hbscript[0])), "QChar::ScriptCount == sizeof(_qtscript_to_hbscript) / sizeof(_qtscript_to_hbscript[0])"); | - | ||||||
163 | - | |||||||
164 | hb_script_t hb_qt_script_to_script(QChar::Script script) | - | ||||||
165 | { | - | ||||||
166 | return _qtscript_to_hbscript[script]; | - | ||||||
167 | } | - | ||||||
168 | - | |||||||
169 | QChar::Script hb_qt_script_from_script(hb_script_t script) | - | ||||||
170 | { | - | ||||||
171 | uint i = QChar::ScriptCount - 1; | - | ||||||
172 | while (i > QChar::Script_Unknown && _qtscript_to_hbscript[i] != script) | - | ||||||
173 | --i; | - | ||||||
174 | return QChar::Script(i); | - | ||||||
175 | } | - | ||||||
176 | - | |||||||
177 | - | |||||||
178 | static hb_unicode_combining_class_t | - | ||||||
179 | _hb_qt_unicode_combining_class(hb_unicode_funcs_t * , | - | ||||||
180 | hb_codepoint_t unicode, | - | ||||||
181 | void * ) | - | ||||||
182 | { | - | ||||||
183 | return hb_unicode_combining_class_t(QChar::combiningClass(unicode)); | - | ||||||
184 | } | - | ||||||
185 | - | |||||||
186 | static unsigned int | - | ||||||
187 | _hb_qt_unicode_eastasian_width(hb_unicode_funcs_t * , | - | ||||||
188 | hb_codepoint_t , | - | ||||||
189 | void * ) | - | ||||||
190 | { | - | ||||||
191 | QMessageLogger(__FILE__, 230236, __PRETTY_FUNCTION__).critical("hb_qt_unicode_eastasian_width: not implemented!"); | - | ||||||
192 | return 1; | - | ||||||
193 | } | - | ||||||
194 | - | |||||||
195 | static const hb_unicode_general_category_t _qtcategory_to_hbcategory[] = { | - | ||||||
196 | HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK, | - | ||||||
197 | HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK, | - | ||||||
198 | HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK, | - | ||||||
199 | - | |||||||
200 | HB_UNICODE_GENERAL_CATEGORY_DECIMAL_NUMBER, | - | ||||||
201 | HB_UNICODE_GENERAL_CATEGORY_LETTER_NUMBER, | - | ||||||
202 | HB_UNICODE_GENERAL_CATEGORY_OTHER_NUMBER, | - | ||||||
203 | - | |||||||
204 | HB_UNICODE_GENERAL_CATEGORY_SPACE_SEPARATOR, | - | ||||||
205 | HB_UNICODE_GENERAL_CATEGORY_LINE_SEPARATOR, | - | ||||||
206 | HB_UNICODE_GENERAL_CATEGORY_PARAGRAPH_SEPARATOR, | - | ||||||
207 | - | |||||||
208 | HB_UNICODE_GENERAL_CATEGORY_CONTROL, | - | ||||||
209 | HB_UNICODE_GENERAL_CATEGORY_FORMAT, | - | ||||||
210 | HB_UNICODE_GENERAL_CATEGORY_SURROGATE, | - | ||||||
211 | HB_UNICODE_GENERAL_CATEGORY_PRIVATE_USE, | - | ||||||
212 | HB_UNICODE_GENERAL_CATEGORY_UNASSIGNED, | - | ||||||
213 | - | |||||||
214 | HB_UNICODE_GENERAL_CATEGORY_UPPERCASE_LETTER, | - | ||||||
215 | HB_UNICODE_GENERAL_CATEGORY_LOWERCASE_LETTER, | - | ||||||
216 | HB_UNICODE_GENERAL_CATEGORY_TITLECASE_LETTER, | - | ||||||
217 | HB_UNICODE_GENERAL_CATEGORY_MODIFIER_LETTER, | - | ||||||
218 | HB_UNICODE_GENERAL_CATEGORY_OTHER_LETTER, | - | ||||||
219 | - | |||||||
220 | HB_UNICODE_GENERAL_CATEGORY_CONNECT_PUNCTUATION, | - | ||||||
221 | HB_UNICODE_GENERAL_CATEGORY_DASH_PUNCTUATION, | - | ||||||
222 | HB_UNICODE_GENERAL_CATEGORY_OPEN_PUNCTUATION, | - | ||||||
223 | HB_UNICODE_GENERAL_CATEGORY_CLOSE_PUNCTUATION, | - | ||||||
224 | HB_UNICODE_GENERAL_CATEGORY_INITIAL_PUNCTUATION, | - | ||||||
225 | HB_UNICODE_GENERAL_CATEGORY_FINAL_PUNCTUATION, | - | ||||||
226 | HB_UNICODE_GENERAL_CATEGORY_OTHER_PUNCTUATION, | - | ||||||
227 | - | |||||||
228 | HB_UNICODE_GENERAL_CATEGORY_MATH_SYMBOL, | - | ||||||
229 | HB_UNICODE_GENERAL_CATEGORY_CURRENCY_SYMBOL, | - | ||||||
230 | HB_UNICODE_GENERAL_CATEGORY_MODIFIER_SYMBOL, | - | ||||||
231 | HB_UNICODE_GENERAL_CATEGORY_OTHER_SYMBOL | - | ||||||
232 | }; | - | ||||||
233 | - | |||||||
234 | static hb_unicode_general_category_t | - | ||||||
235 | _hb_qt_unicode_general_category(hb_unicode_funcs_t * , | - | ||||||
236 | hb_codepoint_t unicode, | - | ||||||
237 | void * ) | - | ||||||
238 | { | - | ||||||
239 | return _qtcategory_to_hbcategory[QChar::category(unicode)]; | - | ||||||
240 | } | - | ||||||
241 | - | |||||||
242 | static hb_codepoint_t | - | ||||||
243 | _hb_qt_unicode_mirroring(hb_unicode_funcs_t * , | - | ||||||
244 | hb_codepoint_t unicode, | - | ||||||
245 | void * ) | - | ||||||
246 | { | - | ||||||
247 | return QChar::mirroredChar(unicode); | - | ||||||
248 | } | - | ||||||
249 | - | |||||||
250 | static hb_script_t | - | ||||||
251 | _hb_qt_unicode_script(hb_unicode_funcs_t * , | - | ||||||
252 | hb_codepoint_t unicode, | - | ||||||
253 | void * ) | - | ||||||
254 | { | - | ||||||
255 | return _qtscript_to_hbscript[QChar::script(unicode)]; | - | ||||||
256 | } | - | ||||||
257 | - | |||||||
258 | static hb_bool_t | - | ||||||
259 | _hb_qt_unicode_compose(hb_unicode_funcs_t * , | - | ||||||
260 | hb_codepoint_t a, hb_codepoint_t b, | - | ||||||
261 | hb_codepoint_t *ab, | - | ||||||
262 | void * ) | - | ||||||
263 | { | - | ||||||
264 | - | |||||||
265 | QString s = QString::fromUcs4(&a, 1) + QString::fromUcs4(&b, 1); | - | ||||||
266 | QString normalized = s.normalized(QString::NormalizationForm_C); | - | ||||||
267 | - | |||||||
268 | QStringIterator it(normalized); | - | ||||||
269 | ((!(it.hasNext())) ? qt_assert("it.hasNext()",__FILE__,308314) : qt_noop()); | - | ||||||
270 | *ab = it.next(); | - | ||||||
271 | - | |||||||
272 | return !it.hasNext(); | - | ||||||
273 | } | - | ||||||
274 | - | |||||||
275 | static hb_bool_t | - | ||||||
276 | _hb_qt_unicode_decompose(hb_unicode_funcs_t * , | - | ||||||
277 | hb_codepoint_t ab, | - | ||||||
278 | hb_codepoint_t *a, hb_codepoint_t *b, | - | ||||||
279 | void * ) | - | ||||||
280 | { | - | ||||||
281 | - | |||||||
282 | if (QChar::decompositionTag(ab) != QChar::Canonical) | - | ||||||
283 | return false; | - | ||||||
284 | - | |||||||
285 | QString normalized = QChar::decomposition(ab); | - | ||||||
286 | if (normalized.isEmpty()) | - | ||||||
287 | return false; | - | ||||||
288 | - | |||||||
289 | QStringIterator it(normalized); | - | ||||||
290 | ((!(it.hasNext())) ? qt_assert("it.hasNext()",__FILE__,329335) : qt_noop()); | - | ||||||
291 | *a = it.next(); | - | ||||||
292 | - | |||||||
293 | if (!it.hasNext()) { | - | ||||||
294 | *b = 0; | - | ||||||
295 | return *a != ab; | - | ||||||
296 | } | - | ||||||
297 | - | |||||||
298 | - | |||||||
299 | *b = it.next(); | - | ||||||
300 | if (!it.hasNext()) { | - | ||||||
301 | - | |||||||
302 | - | |||||||
303 | - | |||||||
304 | const QString recomposed = normalized.normalized(QString::NormalizationForm_C); | - | ||||||
305 | QStringIterator jt(recomposed); | - | ||||||
306 | ((!(jt.hasNext())) ? qt_assert("jt.hasNext()",__FILE__,345351) : qt_noop()); | - | ||||||
307 | const hb_codepoint_t c = jt.next(); | - | ||||||
308 | if (c != *a && c != ab) { | - | ||||||
309 | *a = c; | - | ||||||
310 | *b = 0; | - | ||||||
311 | } | - | ||||||
312 | return true; | - | ||||||
313 | } | - | ||||||
314 | - | |||||||
315 | - | |||||||
316 | - | |||||||
317 | - | |||||||
318 | do { | - | ||||||
319 | *b = it.next(); | - | ||||||
320 | } while (it.hasNext()); | - | ||||||
321 | normalized.chop(QChar::requiresSurrogates(*b) ? 2 : 1); | - | ||||||
322 | const QString recomposed = normalized.normalized(QString::NormalizationForm_C); | - | ||||||
323 | QStringIterator jt(recomposed); | - | ||||||
324 | ((!(jt.hasNext())) ? qt_assert("jt.hasNext()",__FILE__,363369) : qt_noop()); | - | ||||||
325 | - | |||||||
326 | *a = jt.next(); | - | ||||||
327 | return true; | - | ||||||
328 | } | - | ||||||
329 | - | |||||||
330 | static unsigned int | - | ||||||
331 | _hb_qt_unicode_decompose_compatibility(hb_unicode_funcs_t * , | - | ||||||
332 | hb_codepoint_t u, | - | ||||||
333 | hb_codepoint_t *decomposed, | - | ||||||
334 | void * ) | - | ||||||
335 | { | - | ||||||
336 | const QString normalized = QChar::decomposition(u); | - | ||||||
337 | - | |||||||
338 | uint outlen = 0; | - | ||||||
339 | QStringIterator it(normalized); | - | ||||||
340 | while (it.hasNext()) { | - | ||||||
341 | ((!(outlen < (18+1))) ? qt_assert("outlen < HB_UNICODE_MAX_DECOMPOSITION_LEN",__FILE__,380386) : qt_noop()); | - | ||||||
342 | decomposed[outlen++] = it.next(); | - | ||||||
343 | } | - | ||||||
344 | - | |||||||
345 | return outlen; | - | ||||||
346 | } | - | ||||||
347 | - | |||||||
348 | - | |||||||
349 | struct _hb_unicode_funcs_t { | - | ||||||
350 | _hb_unicode_funcs_t() | - | ||||||
351 | { | - | ||||||
352 | funcs = hb_unicode_funcs_create(__null); | - | ||||||
353 | hb_unicode_funcs_set_combining_class_func(funcs, _hb_qt_unicode_combining_class, __null, __null); | - | ||||||
354 | hb_unicode_funcs_set_eastasian_width_func(funcs, _hb_qt_unicode_eastasian_width, __null, __null); | - | ||||||
355 | hb_unicode_funcs_set_general_category_func(funcs, _hb_qt_unicode_general_category, __null, __null); | - | ||||||
356 | hb_unicode_funcs_set_mirroring_func(funcs, _hb_qt_unicode_mirroring, __null, __null); | - | ||||||
357 | hb_unicode_funcs_set_script_func(funcs, _hb_qt_unicode_script, __null, __null); | - | ||||||
358 | hb_unicode_funcs_set_compose_func(funcs, _hb_qt_unicode_compose, __null, __null); | - | ||||||
359 | hb_unicode_funcs_set_decompose_func(funcs, _hb_qt_unicode_decompose, __null, __null); | - | ||||||
360 | hb_unicode_funcs_set_decompose_compatibility_func(funcs, _hb_qt_unicode_decompose_compatibility, __null, __null); | - | ||||||
361 | } | - | ||||||
362 | ~_hb_unicode_funcs_t() | - | ||||||
363 | { | - | ||||||
364 | hb_unicode_funcs_destroy(funcs); | - | ||||||
365 | } | - | ||||||
366 | - | |||||||
367 | hb_unicode_funcs_t *funcs; | - | ||||||
368 | }; | - | ||||||
369 | - | |||||||
370 | namespace { namespace Q_QGS_qt_ufuncs { typedef _hb_unicode_funcs_t Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<_hb_unicode_funcs_t, Q_QGS_qt_ufuncs::innerFunction, Q_QGS_qt_ufuncs::guard> qt_ufuncs; | - | ||||||
371 | - | |||||||
372 | hb_unicode_funcs_t *hb_qt_get_unicode_funcs() | - | ||||||
373 | { | - | ||||||
374 | return qt_ufuncs()->funcs; | - | ||||||
375 | } | - | ||||||
376 | - | |||||||
377 | - | |||||||
378 | - | |||||||
379 | - | |||||||
380 | static hb_bool_t | - | ||||||
381 | _hb_qt_font_get_glyph(hb_font_t * , void *font_data, | - | ||||||
382 | hb_codepoint_t unicode, hb_codepoint_t , | - | ||||||
383 | hb_codepoint_t *glyph, | - | ||||||
384 | void * ) | - | ||||||
385 | { | - | ||||||
386 | QFontEngine *fe = static_cast<QFontEngine *>(font_data); | - | ||||||
387 | ((!(fe)) ? qt_assert("fe",__FILE__,426432) : qt_noop()); | - | ||||||
388 | - | |||||||
389 | *glyph = fe->glyphIndex(unicode); | - | ||||||
390 | - | |||||||
391 | return true; | - | ||||||
392 | } | - | ||||||
393 | - | |||||||
394 | static hb_position_t | - | ||||||
395 | _hb_qt_font_get_glyph_h_advance(hb_font_t *font, void *font_data, | - | ||||||
396 | hb_codepoint_t glyph, | - | ||||||
397 | void * ) | - | ||||||
398 | { | - | ||||||
399 | QFontEngine *fe = static_cast<QFontEngine *>(font_data); | - | ||||||
400 | ((!(fe)) ? qt_assert("fe",__FILE__,439445) : qt_noop()); | - | ||||||
401 | - | |||||||
402 | QFixed advance; | - | ||||||
403 | - | |||||||
404 | QGlyphLayout g; | - | ||||||
405 | g.numGlyphs = 1; | - | ||||||
406 | g.glyphs = &glyph; | - | ||||||
407 | g.advances = &advance; | - | ||||||
408 | - | |||||||
409 | fe->recalcAdvances(&g, QFontEngine::ShaperFlags(hb_qt_font_get_use_design_metrics(font))); | - | ||||||
410 | - | |||||||
411 | return advance.value(); | - | ||||||
412 | } | - | ||||||
413 | - | |||||||
414 | static hb_position_t | - | ||||||
415 | _hb_qt_font_get_glyph_v_advance(hb_font_t * , void * , | - | ||||||
416 | hb_codepoint_t , | - | ||||||
417 | void * ) | - | ||||||
418 | { | - | ||||||
419 | QMessageLogger(__FILE__, 458464, __PRETTY_FUNCTION__).critical("hb_qt_font_get_glyph_v_advance: vertical writing isn't supported!"); | - | ||||||
420 | return 0; | - | ||||||
421 | } | - | ||||||
422 | - | |||||||
423 | static hb_bool_t | - | ||||||
424 | _hb_qt_font_get_glyph_h_origin(hb_font_t * , void * , | - | ||||||
425 | hb_codepoint_t , | - | ||||||
426 | hb_position_t * , hb_position_t * , | - | ||||||
427 | void * ) | - | ||||||
428 | { | - | ||||||
429 | return true; | - | ||||||
430 | } | - | ||||||
431 | - | |||||||
432 | static hb_bool_t | - | ||||||
433 | _hb_qt_font_get_glyph_v_origin(hb_font_t * , void * , | - | ||||||
434 | hb_codepoint_t , | - | ||||||
435 | hb_position_t * , hb_position_t * , | - | ||||||
436 | void * ) | - | ||||||
437 | { | - | ||||||
438 | QMessageLogger(__FILE__, 477483, __PRETTY_FUNCTION__).critical("hb_qt_get_glyph_v_origin: vertical writing isn't supported!"); | - | ||||||
439 | return false; | - | ||||||
440 | } | - | ||||||
441 | - | |||||||
442 | static hb_position_t | - | ||||||
443 | _hb_qt_font_get_glyph_h_kerning(hb_font_t *font, void *font_data, | - | ||||||
444 | hb_codepoint_t first_glyph, hb_codepoint_t second_glyph, | - | ||||||
445 | void * ) | - | ||||||
446 | { | - | ||||||
447 | QFontEngine *fe = static_cast<QFontEngine *>(font_data); | - | ||||||
448 | ((!(fe)) ? qt_assert("fe",__FILE__,487493) : qt_noop()); | - | ||||||
449 | - | |||||||
450 | glyph_t glyphs[2] = { first_glyph, second_glyph }; | - | ||||||
451 | QFixed advance; | - | ||||||
452 | - | |||||||
453 | QGlyphLayout g; | - | ||||||
454 | g.numGlyphs = 2; | - | ||||||
455 | g.glyphs = glyphs; | - | ||||||
456 | g.advances = &advance; | - | ||||||
457 | - | |||||||
458 | fe->doKerning(&g, QFontEngine::ShaperFlags(hb_qt_font_get_use_design_metrics(font))); | - | ||||||
459 | - | |||||||
460 | return advance.value(); | - | ||||||
461 | } | - | ||||||
462 | - | |||||||
463 | static hb_position_t | - | ||||||
464 | _hb_qt_font_get_glyph_v_kerning(hb_font_t * , void * , | - | ||||||
465 | hb_codepoint_t , hb_codepoint_t , | - | ||||||
466 | void * ) | - | ||||||
467 | { | - | ||||||
468 | QMessageLogger(__FILE__, 507513, __PRETTY_FUNCTION__).critical("hb_qt_get_glyph_v_kerning: vertical writing isn't supported!"); | - | ||||||
469 | return 0; | - | ||||||
470 | } | - | ||||||
471 | - | |||||||
472 | static hb_bool_t | - | ||||||
473 | _hb_qt_font_get_glyph_extents(hb_font_t * , void *font_data, | - | ||||||
474 | hb_codepoint_t glyph, | - | ||||||
475 | hb_glyph_extents_t *extents, | - | ||||||
476 | void * ) | - | ||||||
477 | { | - | ||||||
478 | QFontEngine *fe = static_cast<QFontEngine *>(font_data); | - | ||||||
479 | ((!(fe)) ? qt_assert("fe",__FILE__,518524) : qt_noop()); | - | ||||||
480 | - | |||||||
481 | glyph_metrics_t gm = fe->boundingBox(glyph); | - | ||||||
482 | - | |||||||
483 | extents->x_bearing = gm.x.value(); | - | ||||||
484 | extents->y_bearing = gm.y.value(); | - | ||||||
485 | extents->width = gm.width.value(); | - | ||||||
486 | extents->height = gm.height.value(); | - | ||||||
487 | - | |||||||
488 | return true; | - | ||||||
489 | } | - | ||||||
490 | - | |||||||
491 | static hb_bool_t | - | ||||||
492 | _hb_qt_font_get_glyph_contour_point(hb_font_t * , void *font_data, | - | ||||||
493 | hb_codepoint_t glyph, | - | ||||||
494 | unsigned int point_index, hb_position_t *x, hb_position_t *y, | - | ||||||
495 | void * ) | - | ||||||
496 | { | - | ||||||
497 | QFontEngine *fe = static_cast<QFontEngine *>(font_data); | - | ||||||
498 | ((!(fe)) ? qt_assert("fe",__FILE__,537543) : qt_noop()); | - | ||||||
499 | - | |||||||
500 | QFixed xpos, ypos; | - | ||||||
501 | quint32 numPoints = 1; | - | ||||||
502 | if (__builtin_expect(!!(fe->getPointInOutline(glyph, 0, point_index, &xpos, &ypos, &numPoints) == 0), true)) { | - | ||||||
503 | *x = xpos.value(); | - | ||||||
504 | *y = ypos.value(); | - | ||||||
505 | return true; | - | ||||||
506 | } | - | ||||||
507 | - | |||||||
508 | *x = *y = 0; | - | ||||||
509 | return false; | - | ||||||
510 | } | - | ||||||
511 | - | |||||||
512 | static hb_bool_t | - | ||||||
513 | _hb_qt_font_get_glyph_name(hb_font_t * , void * , | - | ||||||
514 | hb_codepoint_t , | - | ||||||
515 | char *name, unsigned int size, | - | ||||||
516 | void * ) | - | ||||||
517 | { | - | ||||||
518 | QMessageLogger(__FILE__, 557563, __PRETTY_FUNCTION__).critical("hb_qt_font_get_glyph_name: not implemented!"); | - | ||||||
519 | if (size) | - | ||||||
520 | *name = '\0'; | - | ||||||
521 | return false; | - | ||||||
522 | } | - | ||||||
523 | - | |||||||
524 | static hb_bool_t | - | ||||||
525 | _hb_qt_font_get_glyph_from_name(hb_font_t * , void * , | - | ||||||
526 | const char * , int , | - | ||||||
527 | hb_codepoint_t *glyph, | - | ||||||
528 | void * ) | - | ||||||
529 | { | - | ||||||
530 | QMessageLogger(__FILE__, 569575, __PRETTY_FUNCTION__).critical("hb_qt_font_get_glyph_from_name: not implemented!"); | - | ||||||
531 | *glyph = 0; | - | ||||||
532 | return false; | - | ||||||
533 | } | - | ||||||
534 | - | |||||||
535 | - | |||||||
536 | static hb_user_data_key_t _useDesignMetricsKey; | - | ||||||
537 | - | |||||||
538 | void hb_qt_font_set_use_design_metrics(hb_font_t *font, uint value) | - | ||||||
539 | { | - | ||||||
540 | hb_font_set_user_data(font, &_useDesignMetricsKey, (void *)quintptr(value), __null, true); | - | ||||||
541 | } | - | ||||||
542 | - | |||||||
543 | uint hb_qt_font_get_use_design_metrics(hb_font_t *font) | - | ||||||
544 | { | - | ||||||
545 | return quintptr(hb_font_get_user_data(font, &_useDesignMetricsKey)); | - | ||||||
546 | } | - | ||||||
547 | - | |||||||
548 | - | |||||||
549 | struct _hb_qt_font_funcs_t { | - | ||||||
550 | _hb_qt_font_funcs_t() | - | ||||||
551 | { | - | ||||||
552 | funcs = hb_font_funcs_create(); | - | ||||||
553 | hb_font_funcs_set_glyph_func(funcs, _hb_qt_font_get_glyph, __null, __null); | - | ||||||
554 | hb_font_funcs_set_glyph_h_advance_func(funcs, _hb_qt_font_get_glyph_h_advance, __null, __null); | - | ||||||
555 | hb_font_funcs_set_glyph_v_advance_func(funcs, _hb_qt_font_get_glyph_v_advance, __null, __null); | - | ||||||
556 | hb_font_funcs_set_glyph_h_origin_func(funcs, _hb_qt_font_get_glyph_h_origin, __null, __null); | - | ||||||
557 | hb_font_funcs_set_glyph_v_origin_func(funcs, _hb_qt_font_get_glyph_v_origin, __null, __null); | - | ||||||
558 | hb_font_funcs_set_glyph_h_kerning_func(funcs, _hb_qt_font_get_glyph_h_kerning, __null, __null); | - | ||||||
559 | hb_font_funcs_set_glyph_v_kerning_func(funcs, _hb_qt_font_get_glyph_v_kerning, __null, __null); | - | ||||||
560 | hb_font_funcs_set_glyph_extents_func(funcs, _hb_qt_font_get_glyph_extents, __null, __null); | - | ||||||
561 | hb_font_funcs_set_glyph_contour_point_func(funcs, _hb_qt_font_get_glyph_contour_point, __null, __null); | - | ||||||
562 | hb_font_funcs_set_glyph_name_func(funcs, _hb_qt_font_get_glyph_name, __null, __null); | - | ||||||
563 | hb_font_funcs_set_glyph_from_name_func(funcs, _hb_qt_font_get_glyph_from_name, __null, __null); | - | ||||||
564 | } | - | ||||||
565 | ~_hb_qt_font_funcs_t() | - | ||||||
566 | { | - | ||||||
567 | hb_font_funcs_destroy(funcs); | - | ||||||
568 | } | - | ||||||
569 | - | |||||||
570 | hb_font_funcs_t *funcs; | - | ||||||
571 | }; | - | ||||||
572 | - | |||||||
573 | namespace { namespace Q_QGS_qt_ffuncs { typedef _hb_qt_font_funcs_t Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<_hb_qt_font_funcs_t, Q_QGS_qt_ffuncs::innerFunction, Q_QGS_qt_ffuncs::guard> qt_ffuncs; | - | ||||||
574 | - | |||||||
575 | hb_font_funcs_t *hb_qt_get_font_funcs() | - | ||||||
576 | { | - | ||||||
577 | return qt_ffuncs()->funcs; | - | ||||||
578 | } | - | ||||||
579 | - | |||||||
580 | - | |||||||
581 | static hb_blob_t * | - | ||||||
582 | _hb_qt_reference_table(hb_face_t * , hb_tag_t tag, void *user_data) | - | ||||||
583 | { | - | ||||||
584 | QFontEngine::FaceData *data = static_cast<QFontEngine::FaceData *>(user_data); | - | ||||||
585 | ((!(data)) ? qt_assert("data",__FILE__,624630) : qt_noop()); | - | ||||||
586 | - | |||||||
587 | qt_get_font_table_func_t get_font_table = data->get_font_table; | - | ||||||
588 | ((!(get_font_table)) ? qt_assert("get_font_table",__FILE__,627633) : qt_noop()); | - | ||||||
589 | - | |||||||
590 | uint length = 0; | - | ||||||
591 | if (__builtin_expect(!!(!get_font_table(data->user_data, tag, 0, &length)), false)) | - | ||||||
592 | return hb_blob_get_empty(); | - | ||||||
593 | - | |||||||
594 | char *buffer = static_cast<char *>(malloc(length)); | - | ||||||
595 | do {if(!(buffer))qt_check_pointer(__FILE__,634640);} while (0); | - | ||||||
596 | - | |||||||
597 | if (__builtin_expect(!!(!get_font_table(data->user_data, tag, reinterpret_cast<uchar *>(buffer), &length)), false)) | - | ||||||
598 | length = 0; | - | ||||||
599 | - | |||||||
600 | return hb_blob_create(const_cast<const char *>(buffer), length, | - | ||||||
601 | HB_MEMORY_MODE_READONLY, | - | ||||||
602 | buffer, free); | - | ||||||
603 | } | - | ||||||
604 | - | |||||||
605 | static inline hb_face_t * | - | ||||||
606 | _hb_qt_face_create(QFontEngine *fe) | - | ||||||
607 | { | - | ||||||
608 | QFontEngine::FaceData *data = static_cast<QFontEngine::FaceData *>(malloc(sizeof(QFontEngine::FaceData))); | - | ||||||
609 | do {if(!(data))qt_check_pointer(__FILE__,648654);} while (0); | - | ||||||
610 | data->user_data = fe->faceData.user_data; | - | ||||||
611 | data->get_font_table = fe->faceData.get_font_table; | - | ||||||
612 | - | |||||||
613 | hb_face_t *face = hb_face_create_for_tables(_hb_qt_reference_table, (void *)data, free); | - | ||||||
614 | if (__builtin_expect(!!(hb_face_is_immutable(face)), false)) { | - | ||||||
615 | hb_face_destroy(face); | - | ||||||
616 | return __null; | - | ||||||
617 | } | - | ||||||
618 | - | |||||||
619 | hb_face_set_index(face, fe->faceId().index); | - | ||||||
620 | hb_face_set_upem(face, fe->emSquareSize().truncate()); | - | ||||||
621 | - | |||||||
622 | return face; | - | ||||||
623 | } | - | ||||||
624 | - | |||||||
625 | static void | - | ||||||
626 | _hb_qt_face_release(void *user_data) | - | ||||||
627 | { | - | ||||||
628 | if (__builtin_expect(!!(user_data), true)) | - | ||||||
629 | hb_face_destroy(static_cast<hb_face_t *>(user_data)); | - | ||||||
630 | } | - | ||||||
631 | - | |||||||
632 | hb_face_t *hb_qt_face_get_for_engine(QFontEngine *fe) | - | ||||||
633 | { | - | ||||||
634 | ((!(fe && fe->type() != QFontEngine::Multi)) ? qt_assert("fe && fe->type() != QFontEngine::Multi",__FILE__,673679) : qt_noop()); | - | ||||||
635 | - | |||||||
636 | if (__builtin_expect(!!(!fe->face_), false)
| 0 | ||||||
637 | {fe->face_ = _hb_qt_face_createQFontEngine::Holder(fe); never executed: fe->face_ = QFontEngine::Holder(_hb_qt_face_create(fe), _hb_qt_face_release); | 0 | ||||||
if never executed: fe->face_ = QFontEngine::Holder(_hb_qt_face_create(fe), _hb_qt_face_release); never executed: _hb_qt_face_create(__builtin_expect(!!(!fe->face_), false))fe->face_ = QFontEngine::Holder(_hb_qt_face_create(fe), _hb_qt_face_release); never executed: fe->face_ = QFontEngine::Holder(_hb_qt_face_create(fe), _hb_qt_face_release); | ||||||||
return __null; never executed: fe->face_ = QFontEngine::Holder(_hb_qt_face_create(fe), _hb_qt_face_release); | ||||||||
fe->face_destroy_func = never executed: fe->face_ = QFontEngine::Holder(_hb_qt_face_create(fe), _hb_qt_face_release); never executed: _hb_qt_face_release;fe->face_ = QFontEngine::Holder(_hb_qt_face_create(fe), _hb_qt_face_release); never executed: fe->face_ = QFontEngine::Holder(_hb_qt_face_create(fe), _hb_qt_face_release); | ||||||||
} never executed: fe->face_ = QFontEngine::Holder(_hb_qt_face_create(fe), _hb_qt_face_release); never executed: );fe->face_ = QFontEngine::Holder(_hb_qt_face_create(fe), _hb_qt_face_release); never executed: fe->face_ = QFontEngine::Holder(_hb_qt_face_create(fe), _hb_qt_face_release); | ||||||||
638 | - | |||||||
639 | return never executed: static_cast<hb_face_t *>(fe->face_);.get());return static_cast<hb_face_t *>(fe->face_.get()); never executed: return static_cast<hb_face_t *>(fe->face_.get()); | 0 | ||||||
640 | } | - | ||||||
641 | - | |||||||
642 | - | |||||||
643 | static inline hb_font_t * | - | ||||||
644 | _hb_qt_font_create(QFontEngine *fe) | - | ||||||
645 | { | - | ||||||
646 | hb_face_t *face = hb_qt_face_get_for_engine(fe); | - | ||||||
647 | if (__builtin_expect(!!(!face), false)) | - | ||||||
648 | return __null; | - | ||||||
649 | - | |||||||
650 | hb_font_t *font = hb_font_create(face); | - | ||||||
651 | - | |||||||
652 | if (__builtin_expect(!!(hb_font_is_immutable(font)), false)) { | - | ||||||
653 | hb_font_destroy(font); | - | ||||||
654 | return __null; | - | ||||||
655 | } | - | ||||||
656 | - | |||||||
657 | const int y_ppem = fe->fontDef.pixelSize; | - | ||||||
658 | const int x_ppem = (fe->fontDef.pixelSize * fe->fontDef.stretch) / 100; | - | ||||||
659 | - | |||||||
660 | hb_font_set_funcs(font, hb_qt_get_font_funcs(), (void *)fe, __null); | - | ||||||
661 | - | |||||||
662 | - | |||||||
663 | - | |||||||
664 | hb_font_set_scale(font, QFixed(x_ppem).value(), -QFixed(y_ppem).value()); | - | ||||||
665 | - | |||||||
666 | hb_font_set_ppem(font, x_ppem, y_ppem); | - | ||||||
667 | - | |||||||
668 | return font; | - | ||||||
669 | } | - | ||||||
670 | - | |||||||
671 | static void | - | ||||||
672 | _hb_qt_font_release(void *user_data) | - | ||||||
673 | { | - | ||||||
674 | if (__builtin_expect(!!(user_data), true)) | - | ||||||
675 | hb_font_destroy(static_cast<hb_font_t *>(user_data)); | - | ||||||
676 | } | - | ||||||
677 | - | |||||||
678 | hb_font_t *hb_qt_font_get_for_engine(QFontEngine *fe) | - | ||||||
679 | { | - | ||||||
680 | ((!(fe && fe->type() != QFontEngine::Multi)) ? qt_assert("fe && fe->type() != QFontEngine::Multi",__FILE__,723725) : qt_noop()); | - | ||||||
681 | - | |||||||
682 | if (__builtin_expect(!!(!fe->font_), false)
| 0 | ||||||
683 | {fe->font_ = _hb_qt_font_createQFontEngine::Holder(fe); never executed: fe->font_ = QFontEngine::Holder(_hb_qt_font_create(fe), _hb_qt_font_release); | 0 | ||||||
if never executed: fe->font_ = QFontEngine::Holder(_hb_qt_font_create(fe), _hb_qt_font_release); never executed: _hb_qt_font_create(__builtin_expect(!!(!fe->font_), false))fe->font_ = QFontEngine::Holder(_hb_qt_font_create(fe), _hb_qt_font_release); never executed: fe->font_ = QFontEngine::Holder(_hb_qt_font_create(fe), _hb_qt_font_release); | ||||||||
return __null; never executed: fe->font_ = QFontEngine::Holder(_hb_qt_font_create(fe), _hb_qt_font_release); | ||||||||
fe->font_destroy_func = never executed: fe->font_ = QFontEngine::Holder(_hb_qt_font_create(fe), _hb_qt_font_release); never executed: _hb_qt_font_release;fe->font_ = QFontEngine::Holder(_hb_qt_font_create(fe), _hb_qt_font_release); never executed: fe->font_ = QFontEngine::Holder(_hb_qt_font_create(fe), _hb_qt_font_release); | ||||||||
} never executed: fe->font_ = QFontEngine::Holder(_hb_qt_font_create(fe), _hb_qt_font_release); never executed: );fe->font_ = QFontEngine::Holder(_hb_qt_font_create(fe), _hb_qt_font_release); never executed: fe->font_ = QFontEngine::Holder(_hb_qt_font_create(fe), _hb_qt_font_release); | ||||||||
684 | - | |||||||
685 | return never executed: static_cast<hb_font_t *>(fe->font_);.get());return static_cast<hb_font_t *>(fe->font_.get()); never executed: return static_cast<hb_font_t *>(fe->font_.get()); | 0 | ||||||
686 | } | - | ||||||
687 | - | |||||||
688 | - | |||||||
Switch to Source code | Preprocessed file |