diff options
Diffstat (limited to 'gfx/thebes/gfxFontEntry.cpp')
-rw-r--r-- | gfx/thebes/gfxFontEntry.cpp | 61 |
1 files changed, 27 insertions, 34 deletions
diff --git a/gfx/thebes/gfxFontEntry.cpp b/gfx/thebes/gfxFontEntry.cpp index 90c0bc8585..765332aef5 100644 --- a/gfx/thebes/gfxFontEntry.cpp +++ b/gfx/thebes/gfxFontEntry.cpp @@ -233,7 +233,9 @@ uint16_t gfxFontEntry::GetUVSGlyph(uint32_t aCh, uint32_t aVS) return 0; } -bool gfxFontEntry::SupportsScriptInGSUB(const hb_tag_t* aScriptTags) +bool +gfxFontEntry::SupportsScriptInGSUB(const hb_tag_t* aScriptTags, + uint32_t aNumTags) { hb_face_t *face = GetHBFace(); if (!face) { @@ -242,9 +244,9 @@ bool gfxFontEntry::SupportsScriptInGSUB(const hb_tag_t* aScriptTags) unsigned int index; hb_tag_t chosenScript; - bool found = - hb_ot_layout_table_choose_script(face, TRUETYPE_TAG('G','S','U','B'), - aScriptTags, &index, &chosenScript); + bool found = hb_ot_layout_table_select_script( + face, TRUETYPE_TAG('G', 'S', 'U', 'B'), aNumTags, aScriptTags, &index, + &chosenScript); hb_face_destroy(face); return found && chosenScript != TRUETYPE_TAG('D','F','L','T'); @@ -819,27 +821,22 @@ gfxFontEntry::SupportsOpenTypeFeature(Script aScript, uint32_t aFeatureTag) gfxHarfBuzzShaper::GetHBScriptUsedForShaping(aScript); // Get the OpenType tag(s) that match this script code - hb_tag_t scriptTags[4] = { - HB_TAG_NONE, - HB_TAG_NONE, - HB_TAG_NONE, - HB_TAG_NONE - }; - hb_ot_tags_from_script(hbScript, &scriptTags[0], &scriptTags[1]); - - // Replace the first remaining NONE with DEFAULT - hb_tag_t* scriptTag = &scriptTags[0]; - while (*scriptTag != HB_TAG_NONE) { - ++scriptTag; + unsigned int scriptCount = 4; + hb_tag_t scriptTags[4]; + hb_ot_tags_from_script_and_language(hbScript, HB_LANGUAGE_INVALID, + &scriptCount, scriptTags, nullptr, + nullptr); + + // Append DEFAULT to the returned tags, if room + if (scriptCount < 4) { + scriptTags[scriptCount++] = HB_OT_TAG_DEFAULT_SCRIPT; } - *scriptTag = HB_OT_TAG_DEFAULT_SCRIPT; // Now check for 'smcp' under the first of those scripts that is present const hb_tag_t kGSUB = HB_TAG('G','S','U','B'); - scriptTag = &scriptTags[0]; - while (*scriptTag != HB_TAG_NONE) { + for (unsigned int i = 0; i < scriptCount; i++) { unsigned int scriptIndex; - if (hb_ot_layout_table_find_script(face, kGSUB, *scriptTag, + if (hb_ot_layout_table_find_script(face, kGSUB, scriptTags[i], &scriptIndex)) { if (hb_ot_layout_language_find_feature(face, kGSUB, scriptIndex, @@ -849,7 +846,6 @@ gfxFontEntry::SupportsOpenTypeFeature(Script aScript, uint32_t aFeatureTag) } break; } - ++scriptTag; } } @@ -886,20 +882,17 @@ gfxFontEntry::InputsForOpenTypeFeature(Script aScript, uint32_t aFeatureTag) gfxHarfBuzzShaper::GetHBScriptUsedForShaping(aScript); // Get the OpenType tag(s) that match this script code - hb_tag_t scriptTags[4] = { - HB_TAG_NONE, - HB_TAG_NONE, - HB_TAG_NONE, - HB_TAG_NONE - }; - hb_ot_tags_from_script(hbScript, &scriptTags[0], &scriptTags[1]); - - // Replace the first remaining NONE with DEFAULT - hb_tag_t* scriptTag = &scriptTags[0]; - while (*scriptTag != HB_TAG_NONE) { - ++scriptTag; + unsigned int scriptCount = 4; + hb_tag_t scriptTags[5]; // space for null terminator + hb_ot_tags_from_script_and_language(hbScript, HB_LANGUAGE_INVALID, + &scriptCount, scriptTags, nullptr, + nullptr); + + // Append DEFAULT to the returned tags, if room + if (scriptCount < 4) { + scriptTags[scriptCount++] = HB_OT_TAG_DEFAULT_SCRIPT; } - *scriptTag = HB_OT_TAG_DEFAULT_SCRIPT; + scriptTags[scriptCount++] = 0; const hb_tag_t kGSUB = HB_TAG('G','S','U','B'); hb_tag_t features[2] = { aFeatureTag, HB_TAG_NONE }; |