dwrite: Remove OpenType language id from cache.
This commit is contained in:
parent
bcbd83d154
commit
53209e7017
|
@ -844,6 +844,7 @@ static HRESULT WINAPI dwritetextanalyzer_GetGlyphs(IDWriteTextAnalyzer2 *iface,
|
||||||
DWRITE_SHAPING_GLYPH_PROPERTIES* glyph_props, UINT32* actual_glyph_count)
|
DWRITE_SHAPING_GLYPH_PROPERTIES* glyph_props, UINT32* actual_glyph_count)
|
||||||
{
|
{
|
||||||
const struct dwritescript_properties *scriptprops;
|
const struct dwritescript_properties *scriptprops;
|
||||||
|
struct scriptshaping_context context;
|
||||||
struct scriptshaping_cache *cache;
|
struct scriptshaping_cache *cache;
|
||||||
WCHAR *string;
|
WCHAR *string;
|
||||||
BOOL update_cluster;
|
BOOL update_cluster;
|
||||||
|
@ -924,13 +925,25 @@ static HRESULT WINAPI dwritetextanalyzer_GetGlyphs(IDWriteTextAnalyzer2 *iface,
|
||||||
}
|
}
|
||||||
*actual_glyph_count = g;
|
*actual_glyph_count = g;
|
||||||
|
|
||||||
hr = create_scriptshaping_cache(fontface, locale, &cache);
|
hr = create_scriptshaping_cache(fontface, &cache);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
context.cache = cache;
|
||||||
|
context.text = text;
|
||||||
|
context.length = length;
|
||||||
|
context.is_rtl = is_rtl;
|
||||||
|
context.max_glyph_count = max_glyph_count;
|
||||||
|
context.language_tag = DWRITE_MAKE_OPENTYPE_TAG('d','f','l','t');
|
||||||
|
if (locale) {
|
||||||
|
WCHAR tag[5];
|
||||||
|
if (GetLocaleInfoEx(locale, LOCALE_SOPENTYPELANGUAGETAG, tag, sizeof(tag)/sizeof(WCHAR)))
|
||||||
|
context.language_tag = DWRITE_MAKE_OPENTYPE_TAG(tag[0],tag[1],tag[2],tag[3]);
|
||||||
|
}
|
||||||
|
|
||||||
scriptprops = &dwritescripts_properties[script];
|
scriptprops = &dwritescripts_properties[script];
|
||||||
if (scriptprops->ops && scriptprops->ops->contextual_shaping) {
|
if (scriptprops->ops && scriptprops->ops->contextual_shaping) {
|
||||||
hr = scriptprops->ops->contextual_shaping(cache, is_rtl, string, length, max_glyph_count, clustermap, glyph_indices, actual_glyph_count);
|
hr = scriptprops->ops->contextual_shaping(&context, clustermap, glyph_indices, actual_glyph_count);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -938,9 +951,9 @@ static HRESULT WINAPI dwritetextanalyzer_GetGlyphs(IDWriteTextAnalyzer2 *iface,
|
||||||
/* FIXME: apply default features */
|
/* FIXME: apply default features */
|
||||||
|
|
||||||
if (scriptprops->ops && scriptprops->ops->set_text_glyphs_props)
|
if (scriptprops->ops && scriptprops->ops->set_text_glyphs_props)
|
||||||
hr = scriptprops->ops->set_text_glyphs_props(cache, string, length, clustermap, glyph_indices, *actual_glyph_count, text_props, glyph_props);
|
hr = scriptprops->ops->set_text_glyphs_props(&context, clustermap, glyph_indices, *actual_glyph_count, text_props, glyph_props);
|
||||||
else
|
else
|
||||||
hr = default_shaping_ops.set_text_glyphs_props(cache, string, length, clustermap, glyph_indices, *actual_glyph_count, text_props, glyph_props);
|
hr = default_shaping_ops.set_text_glyphs_props(&context, clustermap, glyph_indices, *actual_glyph_count, text_props, glyph_props);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
release_scriptshaping_cache(cache);
|
release_scriptshaping_cache(cache);
|
||||||
|
|
|
@ -143,14 +143,26 @@ enum SCRIPT_JUSTIFY
|
||||||
};
|
};
|
||||||
|
|
||||||
struct scriptshaping_cache;
|
struct scriptshaping_cache;
|
||||||
extern HRESULT create_scriptshaping_cache(IDWriteFontFace*,const WCHAR*,struct scriptshaping_cache**) DECLSPEC_HIDDEN;
|
|
||||||
|
struct scriptshaping_context
|
||||||
|
{
|
||||||
|
struct scriptshaping_cache *cache;
|
||||||
|
UINT32 language_tag;
|
||||||
|
|
||||||
|
const WCHAR *text;
|
||||||
|
UINT32 length;
|
||||||
|
BOOL is_rtl;
|
||||||
|
|
||||||
|
UINT32 max_glyph_count;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern HRESULT create_scriptshaping_cache(IDWriteFontFace*,struct scriptshaping_cache**) DECLSPEC_HIDDEN;
|
||||||
extern void release_scriptshaping_cache(struct scriptshaping_cache*) DECLSPEC_HIDDEN;
|
extern void release_scriptshaping_cache(struct scriptshaping_cache*) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
struct scriptshaping_ops
|
struct scriptshaping_ops
|
||||||
{
|
{
|
||||||
HRESULT (*contextual_shaping)(struct scriptshaping_cache *cache, BOOL is_rtl, const WCHAR *text, UINT32 len, UINT32 max_glyph_count,
|
HRESULT (*contextual_shaping)(struct scriptshaping_context *context, UINT16 *clustermap, UINT16 *glyph_indices, UINT32* actual_glyph_count);
|
||||||
UINT16 *clustermap, UINT16 *glyph_indices, UINT32* actual_glyph_count);
|
HRESULT (*set_text_glyphs_props)(struct scriptshaping_context *context, UINT16 *clustermap, UINT16 *glyph_indices,
|
||||||
HRESULT (*set_text_glyphs_props)(struct scriptshaping_cache *cache, const WCHAR *text, UINT32 len, UINT16 *clustermap, UINT16 *glyph_indices,
|
|
||||||
UINT32 glyphcount, DWRITE_SHAPING_TEXT_PROPERTIES *text_props, DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props);
|
UINT32 glyphcount, DWRITE_SHAPING_TEXT_PROPERTIES *text_props, DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,10 +28,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(dwrite);
|
||||||
struct scriptshaping_cache
|
struct scriptshaping_cache
|
||||||
{
|
{
|
||||||
IDWriteFontFace *fontface;
|
IDWriteFontFace *fontface;
|
||||||
UINT32 language_tag;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
HRESULT create_scriptshaping_cache(IDWriteFontFace *fontface, const WCHAR *locale, struct scriptshaping_cache **cache)
|
HRESULT create_scriptshaping_cache(IDWriteFontFace *fontface, struct scriptshaping_cache **cache)
|
||||||
{
|
{
|
||||||
struct scriptshaping_cache *ret;
|
struct scriptshaping_cache *ret;
|
||||||
|
|
||||||
|
@ -42,13 +41,6 @@ HRESULT create_scriptshaping_cache(IDWriteFontFace *fontface, const WCHAR *local
|
||||||
ret->fontface = fontface;
|
ret->fontface = fontface;
|
||||||
IDWriteFontFace_AddRef(fontface);
|
IDWriteFontFace_AddRef(fontface);
|
||||||
|
|
||||||
ret->language_tag = DWRITE_MAKE_OPENTYPE_TAG('d','f','l','t');
|
|
||||||
if (locale) {
|
|
||||||
WCHAR tag[5];
|
|
||||||
if (GetLocaleInfoEx(locale, LOCALE_SOPENTYPELANGUAGETAG, tag, sizeof(tag)/sizeof(WCHAR)))
|
|
||||||
ret->language_tag = DWRITE_MAKE_OPENTYPE_TAG(tag[0],tag[1],tag[2],tag[3]);
|
|
||||||
}
|
|
||||||
|
|
||||||
*cache = ret;
|
*cache = ret;
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
|
@ -122,7 +114,7 @@ static INT32 map_glyph_to_text_pos(const UINT16 *clustermap, UINT32 len, UINT16
|
||||||
return k;
|
return k;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT default_set_text_glyphs_props(struct scriptshaping_cache *cache, const WCHAR *text, UINT32 len, UINT16 *clustermap, UINT16 *glyph_indices,
|
static HRESULT default_set_text_glyphs_props(struct scriptshaping_context *context, UINT16 *clustermap, UINT16 *glyph_indices,
|
||||||
UINT32 glyphcount, DWRITE_SHAPING_TEXT_PROPERTIES *text_props, DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props)
|
UINT32 glyphcount, DWRITE_SHAPING_TEXT_PROPERTIES *text_props, DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props)
|
||||||
{
|
{
|
||||||
UINT32 i;
|
UINT32 i;
|
||||||
|
@ -132,36 +124,36 @@ static HRESULT default_set_text_glyphs_props(struct scriptshaping_cache *cache,
|
||||||
UINT32 char_count = 0;
|
UINT32 char_count = 0;
|
||||||
INT32 k;
|
INT32 k;
|
||||||
|
|
||||||
k = map_glyph_to_text_pos(clustermap, len, i);
|
k = map_glyph_to_text_pos(clustermap, context->length, i);
|
||||||
if (k >= 0) {
|
if (k >= 0) {
|
||||||
for (; k < len && clustermap[k] == i; k++)
|
for (; k < context->length && clustermap[k] == i; k++)
|
||||||
char_index[char_count++] = k;
|
char_index[char_count++] = k;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (char_count == 0)
|
if (char_count == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (char_count == 1 && isspaceW(text[char_index[0]])) {
|
if (char_count == 1 && isspaceW(context->text[char_index[0]])) {
|
||||||
glyph_props[i].justification = SCRIPT_JUSTIFY_BLANK;
|
glyph_props[i].justification = SCRIPT_JUSTIFY_BLANK;
|
||||||
text_props[char_index[0]].isShapedAlone = text[char_index[0]] == ' ';
|
text_props[char_index[0]].isShapedAlone = context->text[char_index[0]] == ' ';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
glyph_props[i].justification = SCRIPT_JUSTIFY_CHARACTER;
|
glyph_props[i].justification = SCRIPT_JUSTIFY_CHARACTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: update properties using GDEF table */
|
/* FIXME: update properties using GDEF table */
|
||||||
shape_update_clusters_from_glyphprop(glyphcount, len, clustermap, glyph_props);
|
shape_update_clusters_from_glyphprop(glyphcount, context->length, clustermap, glyph_props);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT latn_set_text_glyphs_props(struct scriptshaping_cache *cache, const WCHAR *text, UINT32 len, UINT16 *clustermap, UINT16 *glyph_indices,
|
static HRESULT latn_set_text_glyphs_props(struct scriptshaping_context *context, UINT16 *clustermap, UINT16 *glyph_indices,
|
||||||
UINT32 glyphcount, DWRITE_SHAPING_TEXT_PROPERTIES *text_props, DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props)
|
UINT32 glyphcount, DWRITE_SHAPING_TEXT_PROPERTIES *text_props, DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
UINT32 i;
|
UINT32 i;
|
||||||
|
|
||||||
hr = default_set_text_glyphs_props(cache, text, len, clustermap, glyph_indices, glyphcount, text_props, glyph_props);
|
hr = default_set_text_glyphs_props(context, clustermap, glyph_indices, glyphcount, text_props, glyph_props);
|
||||||
|
|
||||||
for (i = 0; i < glyphcount; i++)
|
for (i = 0; i < glyphcount; i++)
|
||||||
if (glyph_props[i].isZeroWidthSpace)
|
if (glyph_props[i].isZeroWidthSpace)
|
||||||
|
|
Loading…
Reference in New Issue