27 */ |
27 */ |
28 |
28 |
29 #ifndef HB_OT_LAYOUT_COMMON_PRIVATE_HH |
29 #ifndef HB_OT_LAYOUT_COMMON_PRIVATE_HH |
30 #define HB_OT_LAYOUT_COMMON_PRIVATE_HH |
30 #define HB_OT_LAYOUT_COMMON_PRIVATE_HH |
31 |
31 |
|
32 #include "hb-private.hh" |
|
33 #include "hb-debug.hh" |
32 #include "hb-ot-layout-private.hh" |
34 #include "hb-ot-layout-private.hh" |
33 #include "hb-open-type-private.hh" |
35 #include "hb-open-type-private.hh" |
34 #include "hb-set-private.hh" |
36 #include "hb-set-private.hh" |
35 |
37 |
36 |
38 |
41 #define HB_MAX_CONTEXT_LENGTH 64 |
43 #define HB_MAX_CONTEXT_LENGTH 64 |
42 #endif |
44 #endif |
43 |
45 |
44 |
46 |
45 namespace OT { |
47 namespace OT { |
46 |
|
47 |
|
48 #define TRACE_DISPATCH(this, format) \ |
|
49 hb_auto_trace_t<context_t::max_debug_depth, typename context_t::return_t> trace \ |
|
50 (&c->debug_depth, c->get_name (), this, HB_FUNC, \ |
|
51 "format %d", (int) format); |
|
52 |
48 |
53 |
49 |
54 #define NOT_COVERED ((unsigned int) -1) |
50 #define NOT_COVERED ((unsigned int) -1) |
55 |
51 |
56 |
52 |
212 return Index::NOT_FOUND_INDEX; |
208 return Index::NOT_FOUND_INDEX; |
213 return reqFeatureIndex;; |
209 return reqFeatureIndex;; |
214 } |
210 } |
215 |
211 |
216 inline bool sanitize (hb_sanitize_context_t *c, |
212 inline bool sanitize (hb_sanitize_context_t *c, |
217 const Record<LangSys>::sanitize_closure_t * = NULL) const |
213 const Record<LangSys>::sanitize_closure_t * = nullptr) const |
218 { |
214 { |
219 TRACE_SANITIZE (this); |
215 TRACE_SANITIZE (this); |
220 return_trace (c->check_struct (this) && featureIndex.sanitize (c)); |
216 return_trace (c->check_struct (this) && featureIndex.sanitize (c)); |
221 } |
217 } |
222 |
218 |
252 |
248 |
253 inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; } |
249 inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; } |
254 inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; } |
250 inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; } |
255 |
251 |
256 inline bool sanitize (hb_sanitize_context_t *c, |
252 inline bool sanitize (hb_sanitize_context_t *c, |
257 const Record<Script>::sanitize_closure_t * = NULL) const |
253 const Record<Script>::sanitize_closure_t * = nullptr) const |
258 { |
254 { |
259 TRACE_SANITIZE (this); |
255 TRACE_SANITIZE (this); |
260 return_trace (defaultLangSys.sanitize (c, this) && langSys.sanitize (c, this)); |
256 return_trace (defaultLangSys.sanitize (c, this) && langSys.sanitize (c, this)); |
261 } |
257 } |
262 |
258 |
433 USHORT format; /* Format number is set to 0. */ |
429 USHORT format; /* Format number is set to 0. */ |
434 USHORT featUILableNameID; /* The ‘name’ table name ID that |
430 USHORT featUILableNameID; /* The ‘name’ table name ID that |
435 * specifies a string (or strings, |
431 * specifies a string (or strings, |
436 * for multiple languages) for a |
432 * for multiple languages) for a |
437 * user-interface label for this |
433 * user-interface label for this |
438 * feature. (May be NULL.) */ |
434 * feature. (May be nullptr.) */ |
439 USHORT featUITooltipTextNameID;/* The ‘name’ table name ID that |
435 USHORT featUITooltipTextNameID;/* The ‘name’ table name ID that |
440 * specifies a string (or strings, |
436 * specifies a string (or strings, |
441 * for multiple languages) that an |
437 * for multiple languages) that an |
442 * application can use for tooltip |
438 * application can use for tooltip |
443 * text for this feature. (May be |
439 * text for this feature. (May be |
444 * NULL.) */ |
440 * nullptr.) */ |
445 USHORT sampleTextNameID; /* The ‘name’ table name ID that |
441 USHORT sampleTextNameID; /* The ‘name’ table name ID that |
446 * specifies sample text that |
442 * specifies sample text that |
447 * illustrates the effect of this |
443 * illustrates the effect of this |
448 * feature. (May be NULL.) */ |
444 * feature. (May be nullptr.) */ |
449 USHORT numNamedParameters; /* Number of named parameters. (May |
445 USHORT numNamedParameters; /* Number of named parameters. (May |
450 * be zero.) */ |
446 * be zero.) */ |
451 USHORT firstParamUILabelNameID;/* The first ‘name’ table name ID |
447 USHORT firstParamUILabelNameID;/* The first ‘name’ table name ID |
452 * used to specify strings for |
448 * used to specify strings for |
453 * user-interface labels for the |
449 * user-interface labels for the |
505 |
501 |
506 inline const FeatureParams &get_feature_params (void) const |
502 inline const FeatureParams &get_feature_params (void) const |
507 { return this+featureParams; } |
503 { return this+featureParams; } |
508 |
504 |
509 inline bool sanitize (hb_sanitize_context_t *c, |
505 inline bool sanitize (hb_sanitize_context_t *c, |
510 const Record<Feature>::sanitize_closure_t *closure = NULL) const |
506 const Record<Feature>::sanitize_closure_t *closure = nullptr) const |
511 { |
507 { |
512 TRACE_SANITIZE (this); |
508 TRACE_SANITIZE (this); |
513 if (unlikely (!(c->check_struct (this) && lookupIndex.sanitize (c)))) |
509 if (unlikely (!(c->check_struct (this) && lookupIndex.sanitize (c)))) |
514 return_trace (false); |
510 return_trace (false); |
515 |
511 |
688 |
684 |
689 private: |
685 private: |
690 inline unsigned int get_coverage (hb_codepoint_t glyph_id) const |
686 inline unsigned int get_coverage (hb_codepoint_t glyph_id) const |
691 { |
687 { |
692 int i = glyphArray.bsearch (glyph_id); |
688 int i = glyphArray.bsearch (glyph_id); |
693 ASSERT_STATIC (((unsigned int) -1) == NOT_COVERED); |
689 static_assert ((((unsigned int) -1) == NOT_COVERED), ""); |
694 return i; |
690 return i; |
695 } |
691 } |
696 |
692 |
697 inline bool serialize (hb_serialize_context_t *c, |
693 inline bool serialize (hb_serialize_context_t *c, |
698 Supplier<GlyphID> &glyphs, |
694 Supplier<GlyphID> &glyphs, |
939 default: break; |
935 default: break; |
940 } |
936 } |
941 } |
937 } |
942 |
938 |
943 struct Iter { |
939 struct Iter { |
944 Iter (void) : format (0) {}; |
940 Iter (void) : format (0), u () {}; |
945 inline void init (const Coverage &c_) { |
941 inline void init (const Coverage &c_) { |
946 format = c_.u.format; |
942 format = c_.u.format; |
947 switch (format) { |
943 switch (format) { |
948 case 1: u.format1.init (c_.u.format1); return; |
944 case 1: u.format1.init (c_.u.format1); return; |
949 case 2: u.format2.init (c_.u.format2); return; |
945 case 2: u.format2.init (c_.u.format2); return; |
1321 return (this+dataSets[outer]).get_delta (inner, |
1317 return (this+dataSets[outer]).get_delta (inner, |
1322 coords, coord_count, |
1318 coords, coord_count, |
1323 this+regions); |
1319 this+regions); |
1324 } |
1320 } |
1325 |
1321 |
|
1322 inline float get_delta (unsigned int index, |
|
1323 int *coords, unsigned int coord_count) const |
|
1324 { |
|
1325 unsigned int outer = index >> 16; |
|
1326 unsigned int inner = index & 0xFFFF; |
|
1327 return get_delta (outer, inner, coords, coord_count); |
|
1328 } |
|
1329 |
1326 inline bool sanitize (hb_sanitize_context_t *c) const |
1330 inline bool sanitize (hb_sanitize_context_t *c) const |
1327 { |
1331 { |
1328 TRACE_SANITIZE (this); |
1332 TRACE_SANITIZE (this); |
1329 return_trace (c->check_struct (this) && |
1333 return_trace (c->check_struct (this) && |
1330 format == 1 && |
1334 format == 1 && |
1332 dataSets.sanitize (c, this)); |
1336 dataSets.sanitize (c, this)); |
1333 } |
1337 } |
1334 |
1338 |
1335 protected: |
1339 protected: |
1336 USHORT format; |
1340 USHORT format; |
1337 OffsetTo<VarRegionList, ULONG> regions; |
1341 LOffsetTo<VarRegionList> regions; |
1338 OffsetArrayOf<VarData, ULONG> dataSets; |
1342 OffsetArrayOf<VarData, ULONG> dataSets; |
1339 public: |
1343 public: |
1340 DEFINE_SIZE_ARRAY (8, dataSets); |
1344 DEFINE_SIZE_ARRAY (8, dataSets); |
1341 }; |
1345 }; |
1342 |
1346 |
1431 TRACE_SANITIZE (this); |
1435 TRACE_SANITIZE (this); |
1432 return_trace (c->check_struct (this) && feature.sanitize (c, base)); |
1436 return_trace (c->check_struct (this) && feature.sanitize (c, base)); |
1433 } |
1437 } |
1434 |
1438 |
1435 protected: |
1439 protected: |
1436 USHORT featureIndex; |
1440 USHORT featureIndex; |
1437 OffsetTo<Feature, ULONG> feature; |
1441 LOffsetTo<Feature> feature; |
1438 public: |
1442 public: |
1439 DEFINE_SIZE_STATIC (6); |
1443 DEFINE_SIZE_STATIC (6); |
1440 }; |
1444 }; |
1441 |
1445 |
1442 struct FeatureTableSubstitution |
1446 struct FeatureTableSubstitution |
1448 { |
1452 { |
1449 const FeatureTableSubstitutionRecord &record = substitutions.array[i]; |
1453 const FeatureTableSubstitutionRecord &record = substitutions.array[i]; |
1450 if (record.featureIndex == feature_index) |
1454 if (record.featureIndex == feature_index) |
1451 return &(this+record.feature); |
1455 return &(this+record.feature); |
1452 } |
1456 } |
1453 return NULL; |
1457 return nullptr; |
1454 } |
1458 } |
1455 |
1459 |
1456 inline bool sanitize (hb_sanitize_context_t *c) const |
1460 inline bool sanitize (hb_sanitize_context_t *c) const |
1457 { |
1461 { |
1458 TRACE_SANITIZE (this); |
1462 TRACE_SANITIZE (this); |
1479 return_trace (conditions.sanitize (c, base) && |
1483 return_trace (conditions.sanitize (c, base) && |
1480 substitutions.sanitize (c, base)); |
1484 substitutions.sanitize (c, base)); |
1481 } |
1485 } |
1482 |
1486 |
1483 protected: |
1487 protected: |
1484 OffsetTo<ConditionSet, ULONG> |
1488 LOffsetTo<ConditionSet> |
1485 conditions; |
1489 conditions; |
1486 OffsetTo<FeatureTableSubstitution, ULONG> |
1490 LOffsetTo<FeatureTableSubstitution> |
1487 substitutions; |
1491 substitutions; |
1488 public: |
1492 public: |
1489 DEFINE_SIZE_STATIC (8); |
1493 DEFINE_SIZE_STATIC (8); |
1490 }; |
1494 }; |
1491 |
1495 |
1525 varRecords.sanitize (c, this)); |
1529 varRecords.sanitize (c, this)); |
1526 } |
1530 } |
1527 |
1531 |
1528 protected: |
1532 protected: |
1529 FixedVersion<> version; /* Version--0x00010000u */ |
1533 FixedVersion<> version; /* Version--0x00010000u */ |
1530 ArrayOf<FeatureVariationRecord, ULONG> |
1534 LArrayOf<FeatureVariationRecord> |
1531 varRecords; |
1535 varRecords; |
1532 public: |
1536 public: |
1533 DEFINE_SIZE_ARRAY (8, varRecords); |
1537 DEFINE_SIZE_ARRAY (8, varRecords); |
1534 }; |
1538 }; |
1535 |
1539 |