mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1500356 - Update gfxFont/gfxFontEntry to use new harfbuzz API in place of deprecated functions. r=jrmuizel
--HG-- extra : rebase_source : d5737b581503e45e1d9fb235cbfc21d8fb568ee7
This commit is contained in:
parent
2fee089e7b
commit
23806e75ca
@ -518,7 +518,7 @@ nsresult FT2FontEntry::ReadCMAP(FontInfoData* aFontInfoData) {
|
||||
// check to see if the cmap includes complex script codepoints
|
||||
if (charmap->TestRange(sr->rangeStart, sr->rangeEnd)) {
|
||||
// We check for GSUB here, as GPOS alone would not be ok.
|
||||
if (hasGSUB && SupportsScriptInGSUB(sr->tags)) {
|
||||
if (hasGSUB && SupportsScriptInGSUB(sr->tags, sr->numTags)) {
|
||||
continue;
|
||||
}
|
||||
charmap->ClearRange(sr->rangeStart, sr->rangeEnd);
|
||||
|
@ -1143,12 +1143,14 @@ void gfxFont::CheckForFeaturesInvolvingSpace() {
|
||||
int(Script::NUM_SCRIPT_CODES)));
|
||||
for (Script s = Script::ARABIC; s < scriptCount;
|
||||
s = Script(static_cast<int>(s) + 1)) {
|
||||
hb_script_t scriptTag = hb_script_t(GetScriptTagForCode(s));
|
||||
hb_tag_t s1, s2;
|
||||
hb_ot_tags_from_script(scriptTag, &s1, &s2);
|
||||
sScriptTagToCode->Put(s1, s);
|
||||
if (s2 != HB_OT_TAG_DEFAULT_SCRIPT) {
|
||||
sScriptTagToCode->Put(s2, s);
|
||||
hb_script_t script = hb_script_t(GetScriptTagForCode(s));
|
||||
unsigned int scriptCount = 4;
|
||||
hb_tag_t scriptTags[4];
|
||||
hb_ot_tags_from_script_and_language(script, HB_LANGUAGE_INVALID,
|
||||
&scriptCount, scriptTags, nullptr,
|
||||
nullptr);
|
||||
for (unsigned int i = 0; i < scriptCount; i++) {
|
||||
sScriptTagToCode->Put(scriptTags[i], s);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,8 @@ 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) {
|
||||
return false;
|
||||
@ -209,9 +210,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');
|
||||
@ -707,23 +708,22 @@ bool gfxFontEntry::SupportsOpenTypeFeature(Script aScript,
|
||||
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]);
|
||||
unsigned int scriptCount = 4;
|
||||
hb_tag_t scriptTags[4];
|
||||
hb_ot_tags_from_script_and_language(hbScript, HB_LANGUAGE_INVALID,
|
||||
&scriptCount, scriptTags, nullptr,
|
||||
nullptr);
|
||||
|
||||
// Replace the first remaining NONE with DEFAULT
|
||||
hb_tag_t* scriptTag = &scriptTags[0];
|
||||
while (*scriptTag != HB_TAG_NONE) {
|
||||
++scriptTag;
|
||||
// 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, HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX,
|
||||
@ -732,7 +732,6 @@ bool gfxFontEntry::SupportsOpenTypeFeature(Script aScript,
|
||||
}
|
||||
break;
|
||||
}
|
||||
++scriptTag;
|
||||
}
|
||||
}
|
||||
|
||||
@ -769,16 +768,17 @@ const hb_set_t* gfxFontEntry::InputsForOpenTypeFeature(Script aScript,
|
||||
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]);
|
||||
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);
|
||||
|
||||
// Replace the first remaining NONE with DEFAULT
|
||||
hb_tag_t* scriptTag = &scriptTags[0];
|
||||
while (*scriptTag != HB_TAG_NONE) {
|
||||
++scriptTag;
|
||||
// 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};
|
||||
|
@ -356,11 +356,11 @@ class gfxFontEntry {
|
||||
struct ScriptRange {
|
||||
uint32_t rangeStart;
|
||||
uint32_t rangeEnd;
|
||||
hb_tag_t tags[3]; // one or two OpenType script tags to check,
|
||||
// plus a NULL terminator
|
||||
uint32_t numTags; // number of entries in the tags[] array
|
||||
hb_tag_t tags[3]; // up to three OpenType script tags to check
|
||||
};
|
||||
|
||||
bool SupportsScriptInGSUB(const hb_tag_t* aScriptTags);
|
||||
bool SupportsScriptInGSUB(const hb_tag_t* aScriptTags, uint32_t aNumTags);
|
||||
|
||||
/**
|
||||
* Font-variation query methods.
|
||||
|
@ -214,7 +214,7 @@ MacOSFontEntry::ReadCMAP(FontInfoData *aFontInfoData)
|
||||
}
|
||||
|
||||
// We check for GSUB here, as GPOS alone would not be ok.
|
||||
if (hasGSUB && SupportsScriptInGSUB(sr->tags)) {
|
||||
if (hasGSUB && SupportsScriptInGSUB(sr->tags, sr->numTags)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -59,50 +59,61 @@ const gfxFontEntry::ScriptRange gfxPlatformFontList::sComplexScriptRanges[] = {
|
||||
// want to mask the basic Arabic block here?
|
||||
// This affects the arabic-fallback-*.html reftests, which rely on
|
||||
// loading a font that *doesn't* have any GSUB table.
|
||||
{0x0600, 0x06FF, {TRUETYPE_TAG('a', 'r', 'a', 'b'), 0, 0}},
|
||||
{0x0700, 0x074F, {TRUETYPE_TAG('s', 'y', 'r', 'c'), 0, 0}},
|
||||
{0x0750, 0x077F, {TRUETYPE_TAG('a', 'r', 'a', 'b'), 0, 0}},
|
||||
{0x08A0, 0x08FF, {TRUETYPE_TAG('a', 'r', 'a', 'b'), 0, 0}},
|
||||
{0x0600, 0x06FF, 1, {TRUETYPE_TAG('a', 'r', 'a', 'b'), 0, 0}},
|
||||
{0x0700, 0x074F, 1, {TRUETYPE_TAG('s', 'y', 'r', 'c'), 0, 0}},
|
||||
{0x0750, 0x077F, 1, {TRUETYPE_TAG('a', 'r', 'a', 'b'), 0, 0}},
|
||||
{0x08A0, 0x08FF, 1, {TRUETYPE_TAG('a', 'r', 'a', 'b'), 0, 0}},
|
||||
{0x0900,
|
||||
0x097F,
|
||||
2,
|
||||
{TRUETYPE_TAG('d', 'e', 'v', '2'), TRUETYPE_TAG('d', 'e', 'v', 'a'), 0}},
|
||||
{0x0980,
|
||||
0x09FF,
|
||||
2,
|
||||
{TRUETYPE_TAG('b', 'n', 'g', '2'), TRUETYPE_TAG('b', 'e', 'n', 'g'), 0}},
|
||||
{0x0A00,
|
||||
0x0A7F,
|
||||
2,
|
||||
{TRUETYPE_TAG('g', 'u', 'r', '2'), TRUETYPE_TAG('g', 'u', 'r', 'u'), 0}},
|
||||
{0x0A80,
|
||||
0x0AFF,
|
||||
2,
|
||||
{TRUETYPE_TAG('g', 'j', 'r', '2'), TRUETYPE_TAG('g', 'u', 'j', 'r'), 0}},
|
||||
{0x0B00,
|
||||
0x0B7F,
|
||||
2,
|
||||
{TRUETYPE_TAG('o', 'r', 'y', '2'), TRUETYPE_TAG('o', 'r', 'y', 'a'), 0}},
|
||||
{0x0B80,
|
||||
0x0BFF,
|
||||
2,
|
||||
{TRUETYPE_TAG('t', 'm', 'l', '2'), TRUETYPE_TAG('t', 'a', 'm', 'l'), 0}},
|
||||
{0x0C00,
|
||||
0x0C7F,
|
||||
2,
|
||||
{TRUETYPE_TAG('t', 'e', 'l', '2'), TRUETYPE_TAG('t', 'e', 'l', 'u'), 0}},
|
||||
{0x0C80,
|
||||
0x0CFF,
|
||||
2,
|
||||
{TRUETYPE_TAG('k', 'n', 'd', '2'), TRUETYPE_TAG('k', 'n', 'd', 'a'), 0}},
|
||||
{0x0D00,
|
||||
0x0D7F,
|
||||
2,
|
||||
{TRUETYPE_TAG('m', 'l', 'm', '2'), TRUETYPE_TAG('m', 'l', 'y', 'm'), 0}},
|
||||
{0x0D80, 0x0DFF, {TRUETYPE_TAG('s', 'i', 'n', 'h'), 0, 0}},
|
||||
{0x0E80, 0x0EFF, {TRUETYPE_TAG('l', 'a', 'o', ' '), 0, 0}},
|
||||
{0x0F00, 0x0FFF, {TRUETYPE_TAG('t', 'i', 'b', 't'), 0, 0}},
|
||||
{0x0D80, 0x0DFF, 1, {TRUETYPE_TAG('s', 'i', 'n', 'h'), 0, 0}},
|
||||
{0x0E80, 0x0EFF, 1, {TRUETYPE_TAG('l', 'a', 'o', ' '), 0, 0}},
|
||||
{0x0F00, 0x0FFF, 1, {TRUETYPE_TAG('t', 'i', 'b', 't'), 0, 0}},
|
||||
{0x1000,
|
||||
0x109f,
|
||||
2,
|
||||
{TRUETYPE_TAG('m', 'y', 'm', 'r'), TRUETYPE_TAG('m', 'y', 'm', '2'), 0}},
|
||||
{0x1780, 0x17ff, {TRUETYPE_TAG('k', 'h', 'm', 'r'), 0, 0}},
|
||||
{0x1780, 0x17ff, 1, {TRUETYPE_TAG('k', 'h', 'm', 'r'), 0, 0}},
|
||||
// Khmer Symbols (19e0..19ff) don't seem to need any special shaping
|
||||
{0xaa60,
|
||||
0xaa7f,
|
||||
2,
|
||||
{TRUETYPE_TAG('m', 'y', 'm', 'r'), TRUETYPE_TAG('m', 'y', 'm', '2'), 0}},
|
||||
// Thai seems to be "renderable" without AAT morphing tables
|
||||
{0, 0, {0, 0, 0}} // terminator
|
||||
{0, 0, 0, {0, 0, 0}} // terminator
|
||||
};
|
||||
|
||||
// prefs for the font info loader
|
||||
|
Loading…
Reference in New Issue
Block a user