forked from Mirrors/wine-wine
dwrite: Keep text properties zero initialized.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>feature/deterministic
parent
b582ab26f9
commit
a66668c129
|
@ -34,11 +34,11 @@ extern const unsigned short wine_scripts_table[] DECLSPEC_HIDDEN;
|
||||||
/* Number of characters needed for LOCALE_SNATIVEDIGITS */
|
/* Number of characters needed for LOCALE_SNATIVEDIGITS */
|
||||||
#define NATIVE_DIGITS_LEN 11
|
#define NATIVE_DIGITS_LEN 11
|
||||||
|
|
||||||
struct dwritescript_properties {
|
struct dwritescript_properties
|
||||||
|
{
|
||||||
DWRITE_SCRIPT_PROPERTIES props;
|
DWRITE_SCRIPT_PROPERTIES props;
|
||||||
UINT32 scripttags[3]; /* Maximum 2 script tags, 0-terminated. */
|
UINT32 scripttags[3]; /* Maximum 2 script tags, 0-terminated. */
|
||||||
BOOL is_complex;
|
BOOL is_complex;
|
||||||
const struct scriptshaping_ops *ops;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define _OT(a,b,c,d) DWRITE_MAKE_OPENTYPE_TAG(a,b,c,d)
|
#define _OT(a,b,c,d) DWRITE_MAKE_OPENTYPE_TAG(a,b,c,d)
|
||||||
|
@ -1194,8 +1194,6 @@ static HRESULT WINAPI dwritetextanalyzer_GetGlyphs(IDWriteTextAnalyzer2 *iface,
|
||||||
*actual_glyph_count = context.glyph_count;
|
*actual_glyph_count = context.glyph_count;
|
||||||
memcpy(glyphs, context.u.subst.glyphs, context.glyph_count * sizeof(*glyphs));
|
memcpy(glyphs, context.u.subst.glyphs, context.glyph_count * sizeof(*glyphs));
|
||||||
memcpy(glyph_props, context.u.subst.glyph_props, context.glyph_count * sizeof(*glyph_props));
|
memcpy(glyph_props, context.u.subst.glyph_props, context.glyph_count * sizeof(*glyph_props));
|
||||||
hr = default_shaping_ops.set_text_glyphs_props(&context, clustermap, glyphs, *actual_glyph_count,
|
|
||||||
text_props, glyph_props);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
heap_free(context.u.subst.glyph_props);
|
heap_free(context.u.subst.glyph_props);
|
||||||
|
|
|
@ -571,15 +571,5 @@ extern void opentype_layout_apply_gsub_features(struct scriptshaping_context *co
|
||||||
extern void opentype_layout_apply_gpos_features(struct scriptshaping_context *context, unsigned int script_index,
|
extern void opentype_layout_apply_gpos_features(struct scriptshaping_context *context, unsigned int script_index,
|
||||||
unsigned int language_index, const struct shaping_features *features) DECLSPEC_HIDDEN;
|
unsigned int language_index, const struct shaping_features *features) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
struct scriptshaping_ops
|
|
||||||
{
|
|
||||||
HRESULT (*contextual_shaping)(struct scriptshaping_context *context, UINT16 *clustermap, UINT16 *glyph_indices, UINT32* actual_glyph_count);
|
|
||||||
HRESULT (*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);
|
|
||||||
const struct shaping_features *gpos_features;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern const struct scriptshaping_ops default_shaping_ops DECLSPEC_HIDDEN;
|
|
||||||
|
|
||||||
extern HRESULT shape_get_glyphs(struct scriptshaping_context *context, const unsigned int *scripts) DECLSPEC_HIDDEN;
|
extern HRESULT shape_get_glyphs(struct scriptshaping_context *context, const unsigned int *scripts) DECLSPEC_HIDDEN;
|
||||||
extern HRESULT shape_get_positions(struct scriptshaping_context *context, const unsigned int *scripts) DECLSPEC_HIDDEN;
|
extern HRESULT shape_get_positions(struct scriptshaping_context *context, const unsigned int *scripts) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -55,105 +55,6 @@ void release_scriptshaping_cache(struct scriptshaping_cache *cache)
|
||||||
heap_free(cache);
|
heap_free(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shape_update_clusters_from_glyphprop(UINT32 glyphcount, UINT32 text_len, UINT16 *clustermap, DWRITE_SHAPING_GLYPH_PROPERTIES *glyph_props)
|
|
||||||
{
|
|
||||||
UINT32 i;
|
|
||||||
|
|
||||||
for (i = 0; i < glyphcount; i++) {
|
|
||||||
if (!glyph_props[i].isClusterStart) {
|
|
||||||
UINT32 j;
|
|
||||||
|
|
||||||
for (j = 0; j < text_len; j++) {
|
|
||||||
if (clustermap[j] == i) {
|
|
||||||
int k = j;
|
|
||||||
while (k >= 0 && k < text_len && !glyph_props[clustermap[k]].isClusterStart)
|
|
||||||
k--;
|
|
||||||
|
|
||||||
if (k >= 0 && k < text_len && glyph_props[clustermap[k]].isClusterStart)
|
|
||||||
clustermap[j] = clustermap[k];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int compare_clustersearch(const void *a, const void* b)
|
|
||||||
{
|
|
||||||
UINT16 target = *(UINT16*)a;
|
|
||||||
UINT16 index = *(UINT16*)b;
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
if (target > index)
|
|
||||||
ret = 1;
|
|
||||||
else if (target < index)
|
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Maps given glyph position in glyph indices array to text index this glyph represents.
|
|
||||||
Lowest possible index is returned.
|
|
||||||
|
|
||||||
clustermap [I] Text index to index in glyph indices array map
|
|
||||||
len [I] Clustermap size
|
|
||||||
target [I] Index in glyph indices array to map
|
|
||||||
*/
|
|
||||||
static INT32 map_glyph_to_text_pos(const UINT16 *clustermap, UINT32 len, UINT16 target)
|
|
||||||
{
|
|
||||||
UINT16 *ptr;
|
|
||||||
INT32 k;
|
|
||||||
|
|
||||||
ptr = bsearch(&target, clustermap, len, sizeof(UINT16), compare_clustersearch);
|
|
||||||
if (!ptr)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* get to the beginning */
|
|
||||||
for (k = (ptr - clustermap) - 1; k >= 0 && clustermap[k] == target; k--)
|
|
||||||
;
|
|
||||||
k++;
|
|
||||||
|
|
||||||
return k;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 i;
|
|
||||||
|
|
||||||
for (i = 0; i < glyphcount; i++) {
|
|
||||||
UINT32 char_index[20];
|
|
||||||
UINT32 char_count = 0;
|
|
||||||
INT32 k;
|
|
||||||
|
|
||||||
k = map_glyph_to_text_pos(clustermap, context->length, i);
|
|
||||||
if (k >= 0) {
|
|
||||||
for (; k < context->length && clustermap[k] == i; k++)
|
|
||||||
char_index[char_count++] = k;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (char_count == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (char_count == 1 && isspaceW(context->text[char_index[0]])) {
|
|
||||||
glyph_props[i].justification = SCRIPT_JUSTIFY_BLANK;
|
|
||||||
text_props[char_index[0]].isShapedAlone = context->text[char_index[0]] == ' ';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
glyph_props[i].justification = SCRIPT_JUSTIFY_CHARACTER;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME: update properties using GDEF table */
|
|
||||||
shape_update_clusters_from_glyphprop(glyphcount, context->length, clustermap, glyph_props);
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
const struct scriptshaping_ops default_shaping_ops =
|
|
||||||
{
|
|
||||||
NULL,
|
|
||||||
default_set_text_glyphs_props
|
|
||||||
};
|
|
||||||
|
|
||||||
static unsigned int shape_select_script(const struct scriptshaping_cache *cache, DWORD kind, const DWORD *scripts,
|
static unsigned int shape_select_script(const struct scriptshaping_cache *cache, DWORD kind, const DWORD *scripts,
|
||||||
unsigned int *script_index)
|
unsigned int *script_index)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue