From 940961fcf73fce9770f12ed314411d20238c1be1 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Mon, 16 Jul 2012 07:23:49 -0500 Subject: [PATCH] usp10: Implement SHAPE_ApplyOpenTypePositions using GPOS table. --- dlls/usp10/opentype.c | 28 +++++ dlls/usp10/shape.c | 255 +++++++++++++++++++++++++++----------------- dlls/usp10/usp10.c | 2 + dlls/usp10/usp10_internal.h | 2 + 4 files changed, 189 insertions(+), 98 deletions(-) diff --git a/dlls/usp10/opentype.c b/dlls/usp10/opentype.c index fa160b76540..b875594f8c8 100644 --- a/dlls/usp10/opentype.c +++ b/dlls/usp10/opentype.c @@ -869,6 +869,34 @@ INT OpenType_apply_GSUB_lookup(LPCVOID table, INT lookup_index, WORD *glyphs, IN return GSUB_apply_lookup(lookup, lookup_index, glyphs, glyph_index, write_dir, glyph_count); } +/********** + * GPOS + **********/ + +static INT GPOS_apply_lookup(LPOUTLINETEXTMETRICW lpotm, LPLOGFONTW lplogfont, INT* piAdvance, const OT_LookupList* lookup, INT lookup_index, const WORD *glyphs, INT glyph_index, INT write_dir, INT glyph_count, GOFFSET *pGoffset) +{ + int offset; + const OT_LookupTable *look; + + offset = GET_BE_WORD(lookup->Lookup[lookup_index]); + look = (const OT_LookupTable*)((const BYTE*)lookup + offset); + TRACE("type %i, flag %x, subtables %i\n",GET_BE_WORD(look->LookupType),GET_BE_WORD(look->LookupFlag),GET_BE_WORD(look->SubTableCount)); + switch(GET_BE_WORD(look->LookupType)) + { + default: + FIXME("We do not handle SubType %i\n",GET_BE_WORD(look->LookupType)); + } + return glyph_index+1; +} + +INT OpenType_apply_GPOS_lookup(LPOUTLINETEXTMETRICW lpotm, LPLOGFONTW lplogfont, INT* piAdvance, LPCVOID table, INT lookup_index, const WORD *glyphs, INT glyph_index, INT write_dir, INT glyph_count, GOFFSET *pGoffset) +{ + const GPOS_Header *header = (const GPOS_Header *)table; + const OT_LookupList *lookup = (const OT_LookupList*)((const BYTE*)header + GET_BE_WORD(header->LookupList)); + + return GPOS_apply_lookup(lpotm, lplogfont, piAdvance, lookup, lookup_index, glyphs, glyph_index, write_dir, glyph_count, pGoffset); +} + static void GSUB_initialize_script_cache(ScriptCache *psc) { int i; diff --git a/dlls/usp10/shape.c b/dlls/usp10/shape.c index f9a09093e69..d9f6df8bac8 100644 --- a/dlls/usp10/shape.c +++ b/dlls/usp10/shape.c @@ -382,6 +382,7 @@ static OPENTYPE_FEATURE_RECORD mongolian_features[] = typedef struct ScriptShapeDataTag { TEXTRANGE_PROPERTIES defaultTextRange; + TEXTRANGE_PROPERTIES defaultGPOSTextRange; const char** requiredFeatures; OPENTYPE_TAG newOtTag; ContextualShapingProc contextProc; @@ -391,88 +392,88 @@ typedef struct ScriptShapeDataTag { /* in order of scripts */ static const ScriptShapeData ShapingData[] = { - {{ standard_features, 2}, NULL, 0, NULL, NULL}, - {{ latin_features, 2}, NULL, 0, NULL, NULL}, - {{ latin_features, 2}, NULL, 0, NULL, NULL}, - {{ latin_features, 2}, NULL, 0, NULL, NULL}, - {{ standard_features, 2}, NULL, 0, NULL, NULL}, - {{ latin_features, 2}, NULL, 0, NULL, NULL}, - {{ arabic_features, 6}, required_arabic_features, 0, ContextualShape_Arabic, ShapeCharGlyphProp_Arabic}, - {{ arabic_features, 6}, required_arabic_features, 0, ContextualShape_Arabic, ShapeCharGlyphProp_Arabic}, - {{ hebrew_features, 1}, NULL, 0, ContextualShape_Hebrew, ShapeCharGlyphProp_Hebrew}, - {{ syriac_features, 4}, required_syriac_features, 0, ContextualShape_Syriac, ShapeCharGlyphProp_None}, - {{ arabic_features, 6}, required_arabic_features, 0, ContextualShape_Arabic, ShapeCharGlyphProp_Arabic}, - {{ NULL, 0}, NULL, 0, ContextualShape_Thaana, ShapeCharGlyphProp_None}, - {{ standard_features, 2}, NULL, 0, NULL, NULL}, - {{ standard_features, 2}, NULL, 0, NULL, NULL}, - {{ standard_features, 2}, NULL, 0, NULL, NULL}, - {{ standard_features, 2}, NULL, 0, NULL, NULL}, - {{ sinhala_features, 3}, NULL, 0, ContextualShape_Sinhala, ShapeCharGlyphProp_Sinhala}, - {{ tibetan_features, 2}, NULL, 0, NULL, ShapeCharGlyphProp_Tibet}, - {{ tibetan_features, 2}, NULL, 0, NULL, ShapeCharGlyphProp_Tibet}, - {{ phags_features, 3}, NULL, 0, ContextualShape_Phags_pa, ShapeCharGlyphProp_Thai}, - {{ thai_features, 1}, NULL, 0, ContextualShape_Thai, ShapeCharGlyphProp_Thai}, - {{ thai_features, 1}, NULL, 0, ContextualShape_Thai, NULL}, - {{ thai_features, 1}, required_lao_features, 0, ContextualShape_Lao, ShapeCharGlyphProp_Thai}, - {{ thai_features, 1}, required_lao_features, 0, ContextualShape_Lao, ShapeCharGlyphProp_Thai}, - {{ devanagari_features, 6}, required_devanagari_features, MS_MAKE_TAG('d','e','v','2'), ContextualShape_Devanagari, ShapeCharGlyphProp_Devanagari}, - {{ devanagari_features, 6}, required_devanagari_features, MS_MAKE_TAG('d','e','v','2'), ContextualShape_Devanagari, NULL}, - {{ devanagari_features, 6}, required_bengali_features, MS_MAKE_TAG('b','n','g','2'), ContextualShape_Bengali, ShapeCharGlyphProp_Bengali}, - {{ devanagari_features, 6}, required_bengali_features, MS_MAKE_TAG('b','n','g','2'), ContextualShape_Bengali, NULL}, - {{ devanagari_features, 6}, required_bengali_features, MS_MAKE_TAG('b','n','g','2'), ContextualShape_Bengali, ShapeCharGlyphProp_Bengali}, - {{ devanagari_features, 6}, required_gurmukhi_features, MS_MAKE_TAG('g','u','r','2'), ContextualShape_Gurmukhi, ShapeCharGlyphProp_Gurmukhi}, - {{ devanagari_features, 6}, required_gurmukhi_features, MS_MAKE_TAG('g','u','r','2'), ContextualShape_Gurmukhi, NULL}, - {{ devanagari_features, 6}, required_devanagari_features, MS_MAKE_TAG('g','j','r','2'), ContextualShape_Gujarati, ShapeCharGlyphProp_Gujarati}, - {{ devanagari_features, 6}, required_devanagari_features, MS_MAKE_TAG('g','j','r','2'), ContextualShape_Gujarati, NULL}, - {{ devanagari_features, 6}, required_devanagari_features, MS_MAKE_TAG('g','j','r','2'), ContextualShape_Gujarati, ShapeCharGlyphProp_Gujarati}, - {{ devanagari_features, 6}, required_oriya_features, MS_MAKE_TAG('o','r','y','2'), ContextualShape_Oriya, ShapeCharGlyphProp_Oriya}, - {{ devanagari_features, 6}, required_oriya_features, MS_MAKE_TAG('o','r','y','2'), ContextualShape_Oriya, NULL}, - {{ devanagari_features, 6}, required_tamil_features, MS_MAKE_TAG('t','a','m','2'), ContextualShape_Tamil, ShapeCharGlyphProp_Tamil}, - {{ devanagari_features, 6}, required_tamil_features, MS_MAKE_TAG('t','a','m','2'), ContextualShape_Tamil, NULL}, - {{ devanagari_features, 6}, required_telugu_features, MS_MAKE_TAG('t','e','l','2'), ContextualShape_Telugu, ShapeCharGlyphProp_Telugu}, - {{ devanagari_features, 6}, required_telugu_features, MS_MAKE_TAG('t','e','l','2'), ContextualShape_Telugu, NULL}, - {{ devanagari_features, 6}, required_telugu_features, MS_MAKE_TAG('k','n','d','2'), ContextualShape_Kannada, ShapeCharGlyphProp_Kannada}, - {{ devanagari_features, 6}, required_telugu_features, MS_MAKE_TAG('k','n','d','2'), ContextualShape_Kannada, NULL}, - {{ devanagari_features, 6}, required_telugu_features, MS_MAKE_TAG('m','l','m','2'), ContextualShape_Malayalam, ShapeCharGlyphProp_Malayalam}, - {{ devanagari_features, 6}, required_telugu_features, MS_MAKE_TAG('m','l','m','2'), ContextualShape_Malayalam, NULL}, - {{ standard_features, 2}, NULL, 0, NULL, NULL}, - {{ latin_features, 2}, NULL, 0, NULL, NULL}, - {{ standard_features, 2}, NULL, 0, NULL, NULL}, - {{ myanmar_features, 2}, NULL, 0, NULL, NULL}, - {{ myanmar_features, 2}, NULL, 0, NULL, NULL}, - {{ standard_features, 2}, NULL, 0, NULL, NULL}, - {{ standard_features, 2}, NULL, 0, NULL, NULL}, - {{ standard_features, 2}, NULL, 0, NULL, NULL}, - {{ khmer_features, 5}, required_khmer_features, 0, ContextualShape_Khmer, ShapeCharGlyphProp_Khmer}, - {{ khmer_features, 5}, required_khmer_features, 0, ContextualShape_Khmer, ShapeCharGlyphProp_Khmer}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ ethiopic_features, 4}, NULL, 0, NULL, NULL}, - {{ ethiopic_features, 4}, NULL, 0, NULL, NULL}, - {{ mongolian_features, 4}, NULL, 0, ContextualShape_Mongolian, NULL}, - {{ mongolian_features, 4}, NULL, 0, ContextualShape_Mongolian, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ NULL, 0}, NULL, 0, NULL, NULL}, - {{ hebrew_features, 1}, NULL, 0, ContextualShape_Hebrew, NULL}, - {{ latin_features, 2}, NULL, 0, NULL, NULL}, - {{ thai_features, 1}, NULL, 0, ContextualShape_Thai, ShapeCharGlyphProp_Thai}, + {{ standard_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ latin_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ latin_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ latin_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ standard_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ latin_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ arabic_features, 6}, {NULL, 0}, required_arabic_features, 0, ContextualShape_Arabic, ShapeCharGlyphProp_Arabic}, + {{ arabic_features, 6}, {NULL, 0}, required_arabic_features, 0, ContextualShape_Arabic, ShapeCharGlyphProp_Arabic}, + {{ hebrew_features, 1}, {NULL, 0}, NULL, 0, ContextualShape_Hebrew, ShapeCharGlyphProp_Hebrew}, + {{ syriac_features, 4}, {NULL, 0}, required_syriac_features, 0, ContextualShape_Syriac, ShapeCharGlyphProp_None}, + {{ arabic_features, 6}, {NULL, 0}, required_arabic_features, 0, ContextualShape_Arabic, ShapeCharGlyphProp_Arabic}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, ContextualShape_Thaana, ShapeCharGlyphProp_None}, + {{ standard_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ standard_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ standard_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ standard_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ sinhala_features, 3}, {NULL, 0}, NULL, 0, ContextualShape_Sinhala, ShapeCharGlyphProp_Sinhala}, + {{ tibetan_features, 2}, {NULL, 0}, NULL, 0, NULL, ShapeCharGlyphProp_Tibet}, + {{ tibetan_features, 2}, {NULL, 0}, NULL, 0, NULL, ShapeCharGlyphProp_Tibet}, + {{ phags_features, 3}, {NULL, 0}, NULL, 0, ContextualShape_Phags_pa, ShapeCharGlyphProp_Thai}, + {{ thai_features, 1}, {NULL, 0}, NULL, 0, ContextualShape_Thai, ShapeCharGlyphProp_Thai}, + {{ thai_features, 1}, {NULL, 0}, NULL, 0, ContextualShape_Thai, NULL}, + {{ thai_features, 1}, {NULL, 0}, required_lao_features, 0, ContextualShape_Lao, ShapeCharGlyphProp_Thai}, + {{ thai_features, 1}, {NULL, 0}, required_lao_features, 0, ContextualShape_Lao, ShapeCharGlyphProp_Thai}, + {{ devanagari_features, 6}, {NULL, 0}, required_devanagari_features, MS_MAKE_TAG('d','e','v','2'), ContextualShape_Devanagari, ShapeCharGlyphProp_Devanagari}, + {{ devanagari_features, 6}, {NULL, 0}, required_devanagari_features, MS_MAKE_TAG('d','e','v','2'), ContextualShape_Devanagari, NULL}, + {{ devanagari_features, 6}, {NULL, 0}, required_bengali_features, MS_MAKE_TAG('b','n','g','2'), ContextualShape_Bengali, ShapeCharGlyphProp_Bengali}, + {{ devanagari_features, 6}, {NULL, 0}, required_bengali_features, MS_MAKE_TAG('b','n','g','2'), ContextualShape_Bengali, NULL}, + {{ devanagari_features, 6}, {NULL, 0}, required_bengali_features, MS_MAKE_TAG('b','n','g','2'), ContextualShape_Bengali, ShapeCharGlyphProp_Bengali}, + {{ devanagari_features, 6}, {NULL, 0}, required_gurmukhi_features, MS_MAKE_TAG('g','u','r','2'), ContextualShape_Gurmukhi, ShapeCharGlyphProp_Gurmukhi}, + {{ devanagari_features, 6}, {NULL, 0}, required_gurmukhi_features, MS_MAKE_TAG('g','u','r','2'), ContextualShape_Gurmukhi, NULL}, + {{ devanagari_features, 6}, {NULL, 0}, required_devanagari_features, MS_MAKE_TAG('g','j','r','2'), ContextualShape_Gujarati, ShapeCharGlyphProp_Gujarati}, + {{ devanagari_features, 6}, {NULL, 0}, required_devanagari_features, MS_MAKE_TAG('g','j','r','2'), ContextualShape_Gujarati, NULL}, + {{ devanagari_features, 6}, {NULL, 0}, required_devanagari_features, MS_MAKE_TAG('g','j','r','2'), ContextualShape_Gujarati, ShapeCharGlyphProp_Gujarati}, + {{ devanagari_features, 6}, {NULL, 0}, required_oriya_features, MS_MAKE_TAG('o','r','y','2'), ContextualShape_Oriya, ShapeCharGlyphProp_Oriya}, + {{ devanagari_features, 6}, {NULL, 0}, required_oriya_features, MS_MAKE_TAG('o','r','y','2'), ContextualShape_Oriya, NULL}, + {{ devanagari_features, 6}, {NULL, 0}, required_tamil_features, MS_MAKE_TAG('t','a','m','2'), ContextualShape_Tamil, ShapeCharGlyphProp_Tamil}, + {{ devanagari_features, 6}, {NULL, 0}, required_tamil_features, MS_MAKE_TAG('t','a','m','2'), ContextualShape_Tamil, NULL}, + {{ devanagari_features, 6}, {NULL, 0}, required_telugu_features, MS_MAKE_TAG('t','e','l','2'), ContextualShape_Telugu, ShapeCharGlyphProp_Telugu}, + {{ devanagari_features, 6}, {NULL, 0}, required_telugu_features, MS_MAKE_TAG('t','e','l','2'), ContextualShape_Telugu, NULL}, + {{ devanagari_features, 6}, {NULL, 0}, required_telugu_features, MS_MAKE_TAG('k','n','d','2'), ContextualShape_Kannada, ShapeCharGlyphProp_Kannada}, + {{ devanagari_features, 6}, {NULL, 0}, required_telugu_features, MS_MAKE_TAG('k','n','d','2'), ContextualShape_Kannada, NULL}, + {{ devanagari_features, 6}, {NULL, 0}, required_telugu_features, MS_MAKE_TAG('m','l','m','2'), ContextualShape_Malayalam, ShapeCharGlyphProp_Malayalam}, + {{ devanagari_features, 6}, {NULL, 0}, required_telugu_features, MS_MAKE_TAG('m','l','m','2'), ContextualShape_Malayalam, NULL}, + {{ standard_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ latin_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ standard_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ myanmar_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ myanmar_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ standard_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ standard_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ standard_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ khmer_features, 5}, {NULL, 0}, required_khmer_features, 0, ContextualShape_Khmer, ShapeCharGlyphProp_Khmer}, + {{ khmer_features, 5}, {NULL, 0}, required_khmer_features, 0, ContextualShape_Khmer, ShapeCharGlyphProp_Khmer}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ ethiopic_features, 4}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ ethiopic_features, 4}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ mongolian_features, 4}, {NULL, 0}, NULL, 0, ContextualShape_Mongolian, NULL}, + {{ mongolian_features, 4}, {NULL, 0}, NULL, 0, ContextualShape_Mongolian, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ NULL, 0}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ hebrew_features, 1}, {NULL, 0}, NULL, 0, ContextualShape_Hebrew, NULL}, + {{ latin_features, 2}, {NULL, 0}, NULL, 0, NULL, NULL}, + {{ thai_features, 1}, {NULL, 0}, NULL, 0, ContextualShape_Thai, ShapeCharGlyphProp_Thai}, }; extern scriptData scriptInformation[]; @@ -544,11 +545,11 @@ static OPENTYPE_TAG get_opentype_script(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCac } } -static LoadedFeature* load_GSUB_feature(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache *psc, const char* feat) +static LoadedFeature* load_OT_feature(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache *psc, const char* feat) { LoadedFeature *feature = NULL; - if (psc->GSUB_Table) + if (psc->GSUB_Table || psc->GPOS_Table) { int attempt = 2; OPENTYPE_TAG tags; @@ -582,7 +583,7 @@ static INT apply_GSUB_feature_to_glyph(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCach { LoadedFeature *feature; - feature = load_GSUB_feature(hdc, psa, psc, feat); + feature = load_OT_feature(hdc, psa, psc, feat); if (!feature) return GSUB_E_NOFEATURE; @@ -767,7 +768,7 @@ static int apply_GSUB_feature(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, W LoadedFeature *feature; int lookup_index; - feature = load_GSUB_feature(hdc, psa, psc, feat); + feature = load_OT_feature(hdc, psa, psc, feat); if (!feature) return GSUB_E_NOFEATURE; @@ -801,6 +802,19 @@ static int apply_GSUB_feature(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, W return GSUB_E_NOFEATURE; } +static VOID GPOS_apply_feature(LPOUTLINETEXTMETRICW lpotm, LPLOGFONTW lplogfont, INT* piAdvance, LPCVOID header, LoadedFeature *feature, const WORD *glyphs, INT write_dir, INT glyph_count, GOFFSET *pGoffset) +{ + int i; + + TRACE("%i lookups\n", feature->lookup_count); + for (i = 0; i < feature->lookup_count; i++) + { + int j; + for (j = 0; j < glyph_count; ) + j = OpenType_apply_GPOS_lookup(lpotm, lplogfont, piAdvance, header, feature->lookups[i], glyphs, j, write_dir, glyph_count, pGoffset); + } +} + static inline BOOL get_GSUB_Indic2(SCRIPT_ANALYSIS *psa, ScriptCache *psc) { OPENTYPE_TAG tag; @@ -1949,17 +1963,17 @@ static void ShapeIndicSyllables(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, { int c; int overall_shift = 0; - LoadedFeature *locl = (modern)?load_GSUB_feature(hdc, psa, psc, "locl"):NULL; - LoadedFeature *nukt = load_GSUB_feature(hdc, psa, psc, "nukt"); - LoadedFeature *akhn = load_GSUB_feature(hdc, psa, psc, "akhn"); - LoadedFeature *rkrf = (modern)?load_GSUB_feature(hdc, psa, psc, "rkrf"):NULL; - LoadedFeature *pstf = load_GSUB_feature(hdc, psa, psc, "pstf"); - LoadedFeature *vatu = (!rkrf)?load_GSUB_feature(hdc, psa, psc, "vatu"):NULL; - LoadedFeature *cjct = (modern)?load_GSUB_feature(hdc, psa, psc, "cjct"):NULL; - BOOL rphf = (load_GSUB_feature(hdc, psa, psc, "rphf") != NULL); - BOOL pref = (load_GSUB_feature(hdc, psa, psc, "pref") != NULL); - BOOL blwf = (load_GSUB_feature(hdc, psa, psc, "blwf") != NULL); - BOOL half = (load_GSUB_feature(hdc, psa, psc, "half") != NULL); + LoadedFeature *locl = (modern)?load_OT_feature(hdc, psa, psc, "locl"):NULL; + LoadedFeature *nukt = load_OT_feature(hdc, psa, psc, "nukt"); + LoadedFeature *akhn = load_OT_feature(hdc, psa, psc, "akhn"); + LoadedFeature *rkrf = (modern)?load_OT_feature(hdc, psa, psc, "rkrf"):NULL; + LoadedFeature *pstf = load_OT_feature(hdc, psa, psc, "pstf"); + LoadedFeature *vatu = (!rkrf)?load_OT_feature(hdc, psa, psc, "vatu"):NULL; + LoadedFeature *cjct = (modern)?load_OT_feature(hdc, psa, psc, "cjct"):NULL; + BOOL rphf = (load_OT_feature(hdc, psa, psc, "rphf") != NULL); + BOOL pref = (load_OT_feature(hdc, psa, psc, "pref") != NULL); + BOOL blwf = (load_OT_feature(hdc, psa, psc, "blwf") != NULL); + BOOL half = (load_OT_feature(hdc, psa, psc, "half") != NULL); IndicSyllable glyph_indexs; for (c = 0; c < syllable_count; c++) @@ -3209,6 +3223,51 @@ rpRangeProperties = &ShapingData[psa->eScript].defaultTextRange; SHAPE_ApplyOpenTypeFeatures(hdc, psc, psa, pwOutGlyphs, pcGlyphs, cMaxGlyphs, cChars, rpRangeProperties, pwLogClust); } +void SHAPE_ApplyOpenTypePositions(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, const WORD* pwGlyphs, INT cGlyphs, int *piAdvance, GOFFSET *pGoffset ) +{ + const TEXTRANGE_PROPERTIES *rpRangeProperties; + int i; + INT dirL; + LPOUTLINETEXTMETRICW lpotm; + LOGFONTW lf; + HFONT hfont; + + rpRangeProperties = &ShapingData[psa->eScript].defaultGPOSTextRange; + + if (!rpRangeProperties) + return; + + load_ot_tables(hdc, psc); + + if (!psc->GPOS_Table) + return; + + i = GetOutlineTextMetricsW( hdc, 0, NULL); + lpotm = HeapAlloc(GetProcessHeap(),0,i); + GetOutlineTextMetricsW( hdc, i, lpotm); + hfont = GetCurrentObject(hdc, OBJ_FONT); + GetObjectW(hfont, sizeof(lf), &lf); + + if (!psa->fLogicalOrder && psa->fRTL) + dirL = -1; + else + dirL = 1; + + for (i = 0; i < rpRangeProperties->cotfRecords; i++) + { + if (rpRangeProperties->potfRecords[i].lParameter > 0) + { + LoadedFeature *feature; + + feature = load_OT_feature(hdc, psa, psc, (const char*)&rpRangeProperties->potfRecords[i].tagFeature); + if (!feature) + continue; + + GPOS_apply_feature(lpotm, &lf, piAdvance, psc->GPOS_Table, feature, pwGlyphs, dirL, cGlyphs, pGoffset); + } + } +} + HRESULT SHAPE_CheckFontForRequiredFeatures(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa) { LoadedFeature *feature; @@ -3223,7 +3282,7 @@ HRESULT SHAPE_CheckFontForRequiredFeatures(HDC hdc, ScriptCache *psc, SCRIPT_ANA i = 0; while (ShapingData[psa->eScript].requiredFeatures[i]) { - feature = load_GSUB_feature(hdc, psa, psc, ShapingData[psa->eScript].requiredFeatures[i]); + feature = load_OT_feature(hdc, psa, psc, ShapingData[psa->eScript].requiredFeatures[i]); if (feature) return S_OK; i++; diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c index 0e97405be6d..0b535993755 100644 --- a/dlls/usp10/usp10.c +++ b/dlls/usp10/usp10.c @@ -3044,6 +3044,8 @@ HRESULT WINAPI ScriptPlaceOpenType( HDC hdc, SCRIPT_CACHE *psc, SCRIPT_ANALYSIS if (piAdvance) piAdvance[i] = abc.abcA + abc.abcB + abc.abcC; } + SHAPE_ApplyOpenTypePositions(hdc, (ScriptCache *)*psc, psa, pwGlyphs, cGlyphs, piAdvance, pGoffset); + if (pABC) TRACE("Total for run: abcA=%d, abcB=%d, abcC=%d\n", pABC->abcA, pABC->abcB, pABC->abcC); return S_OK; } diff --git a/dlls/usp10/usp10_internal.h b/dlls/usp10/usp10_internal.h index 8cc8f143d7a..15553eb25dc 100644 --- a/dlls/usp10/usp10_internal.h +++ b/dlls/usp10/usp10_internal.h @@ -221,6 +221,7 @@ INT BIDI_ReorderV2lLevel(int level, int *pIndexs, const BYTE* plevel, int cch, B INT BIDI_ReorderL2vLevel(int level, int *pIndexs, const BYTE* plevel, int cch, BOOL fReverse) DECLSPEC_HIDDEN; void SHAPE_ContextualShaping(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WCHAR* pwcChars, INT cChars, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, WORD *pwLogClust) DECLSPEC_HIDDEN; void SHAPE_ApplyDefaultOpentypeFeatures(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, WORD* pwOutGlyphs, INT* pcGlyphs, INT cMaxGlyphs, INT cChars, WORD *pwLogClust) DECLSPEC_HIDDEN; +void SHAPE_ApplyOpenTypePositions(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, const WORD* pwGlyphs, INT cGlyphs, int *piAdvance, GOFFSET *pGoffset ); HRESULT SHAPE_CheckFontForRequiredFeatures(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa) DECLSPEC_HIDDEN; void SHAPE_CharGlyphProp(HDC hdc, ScriptCache *psc, SCRIPT_ANALYSIS *psa, const WCHAR* pwcChars, const INT cChars, const WORD* pwGlyphs, const INT cGlyphs, WORD *pwLogClust, SCRIPT_CHARPROP *pCharProp, SCRIPT_GLYPHPROP *pGlyphProp) DECLSPEC_HIDDEN; INT SHAPE_does_GSUB_feature_apply_to_chars(HDC hdc, SCRIPT_ANALYSIS *psa, ScriptCache* psc, const WCHAR *chars, INT write_dir, INT count, const char* feature) DECLSPEC_HIDDEN; @@ -236,6 +237,7 @@ void BREAK_line(const WCHAR *chars, int count, const SCRIPT_ANALYSIS *sa, SCRIPT DWORD OpenType_CMAP_GetGlyphIndex(HDC hdc, ScriptCache *psc, DWORD utf32c, LPWORD pgi, DWORD flags) DECLSPEC_HIDDEN; void OpenType_GDEF_UpdateGlyphProps(HDC hdc, ScriptCache *psc, const WORD *pwGlyphs, const WORD cGlyphs, WORD* pwLogClust, const WORD cChars, SCRIPT_GLYPHPROP *pGlyphProp) DECLSPEC_HIDDEN; INT OpenType_apply_GSUB_lookup(LPCVOID table, INT lookup_index, WORD *glyphs, INT glyph_index, INT write_dir, INT *glyph_count) DECLSPEC_HIDDEN; +INT OpenType_apply_GPOS_lookup(LPOUTLINETEXTMETRICW lpotm, LPLOGFONTW lplogfont, INT* piAdvance, LPCVOID table, INT lookup_index, const WORD *glyphs, INT glyph_index, INT write_dir, INT glyph_count, GOFFSET *pGoffset) DECLSPEC_HIDDEN; HRESULT OpenType_GetFontScriptTags(ScriptCache *psc, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pScriptTags, int *pcTags) DECLSPEC_HIDDEN; HRESULT OpenType_GetFontLanguageTags(ScriptCache *psc, OPENTYPE_TAG script_tag, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pLanguageTags, int *pcTags) DECLSPEC_HIDDEN; HRESULT OpenType_GetFontFeatureTags(ScriptCache *psc, OPENTYPE_TAG script_tag, OPENTYPE_TAG language_tag, BOOL filtered, OPENTYPE_TAG searchingFor, int cMaxTags, OPENTYPE_TAG *pFeatureTags, int *pcTags, LoadedFeature** feature) DECLSPEC_HIDDEN; -- 2.11.4.GIT