Commit fcd85089 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Use wide-char literals.

parent 9f4c4750
...@@ -207,9 +207,7 @@ const char *debugstr_sa_script(UINT16 script) ...@@ -207,9 +207,7 @@ const char *debugstr_sa_script(UINT16 script)
} }
/* system font falback configuration */ /* system font falback configuration */
static const WCHAR meiryoW[] = {'M','e','i','r','y','o',0}; static const WCHAR *cjk_families[] = { L"Meiryo" };
static const WCHAR *cjk_families[] = { meiryoW };
static const DWRITE_UNICODE_RANGE cjk_ranges[] = static const DWRITE_UNICODE_RANGE cjk_ranges[] =
{ {
...@@ -1102,12 +1100,12 @@ static void get_number_substitutes(IDWriteNumberSubstitution *substitution, BOOL ...@@ -1102,12 +1100,12 @@ static void get_number_substitutes(IDWriteNumberSubstitution *substitution, BOOL
break; break;
case DWRITE_NUMBER_SUBSTITUTION_METHOD_CONTEXTUAL: case DWRITE_NUMBER_SUBSTITUTION_METHOD_CONTEXTUAL:
case DWRITE_NUMBER_SUBSTITUTION_METHOD_TRADITIONAL: case DWRITE_NUMBER_SUBSTITUTION_METHOD_TRADITIONAL:
if (GetLocaleInfoEx(numbersubst->locale, LOCALE_SISO639LANGNAME, isolang, ARRAY_SIZE(isolang))) { if (GetLocaleInfoEx(numbersubst->locale, LOCALE_SISO639LANGNAME, isolang, ARRAY_SIZE(isolang)))
static const WCHAR arW[] = {'a','r',0}; {
static const WCHAR arabicW[] = {0x640,0x641,0x642,0x643,0x644,0x645,0x646,0x647,0x648,0x649,0}; static const WCHAR arabicW[] = {0x640,0x641,0x642,0x643,0x644,0x645,0x646,0x647,0x648,0x649,0};
/* For some Arabic locales Latin digits are returned for SNATIVEDIGITS */ /* For some Arabic locales Latin digits are returned for SNATIVEDIGITS */
if (!wcscmp(arW, isolang)) if (!wcscmp(L"ar", isolang))
{ {
wcscpy(digits, arabicW); wcscpy(digits, arabicW);
break; break;
......
...@@ -45,24 +45,6 @@ static const FLOAT RECOMMENDED_OUTLINE_AA_THRESHOLD = 100.0f; ...@@ -45,24 +45,6 @@ static const FLOAT RECOMMENDED_OUTLINE_AA_THRESHOLD = 100.0f;
static const FLOAT RECOMMENDED_OUTLINE_A_THRESHOLD = 350.0f; static const FLOAT RECOMMENDED_OUTLINE_A_THRESHOLD = 350.0f;
static const FLOAT RECOMMENDED_NATURAL_PPEM = 20.0f; static const FLOAT RECOMMENDED_NATURAL_PPEM = 20.0f;
static const WCHAR extraW[] = {'e','x','t','r','a',0};
static const WCHAR ultraW[] = {'u','l','t','r','a',0};
static const WCHAR semiW[] = {'s','e','m','i',0};
static const WCHAR extW[] = {'e','x','t',0};
static const WCHAR thinW[] = {'t','h','i','n',0};
static const WCHAR lightW[] = {'l','i','g','h','t',0};
static const WCHAR mediumW[] = {'m','e','d','i','u','m',0};
static const WCHAR blackW[] = {'b','l','a','c','k',0};
static const WCHAR condensedW[] = {'c','o','n','d','e','n','s','e','d',0};
static const WCHAR expandedW[] = {'e','x','p','a','n','d','e','d',0};
static const WCHAR italicW[] = {'i','t','a','l','i','c',0};
static const WCHAR boldW[] = {'B','o','l','d',0};
static const WCHAR obliqueW[] = {'O','b','l','i','q','u','e',0};
static const WCHAR regularW[] = {'R','e','g','u','l','a','r',0};
static const WCHAR demiW[] = {'d','e','m','i',0};
static const WCHAR spaceW[] = {' ',0};
static const WCHAR enusW[] = {'e','n','-','u','s',0};
static const struct font_backend_funcs *font_funcs; static const struct font_backend_funcs *font_funcs;
void dwrite_fontface_get_glyph_bbox(struct dwrite_glyphbitmap *bitmap) void dwrite_fontface_get_glyph_bbox(struct dwrite_glyphbitmap *bitmap)
...@@ -3320,7 +3302,7 @@ static void fontstrings_get_en_string(IDWriteLocalizedStrings *strings, WCHAR *b ...@@ -3320,7 +3302,7 @@ static void fontstrings_get_en_string(IDWriteLocalizedStrings *strings, WCHAR *b
HRESULT hr; HRESULT hr;
buffer[0] = 0; buffer[0] = 0;
hr = IDWriteLocalizedStrings_FindLocaleName(strings, enusW, &index, &exists); hr = IDWriteLocalizedStrings_FindLocaleName(strings, L"en-us", &index, &exists);
if (FAILED(hr) || !exists) if (FAILED(hr) || !exists)
return; return;
...@@ -3453,31 +3435,23 @@ static BOOL match_pattern_list(struct list *tokens, const struct name_pattern *p ...@@ -3453,31 +3435,23 @@ static BOOL match_pattern_list(struct list *tokens, const struct name_pattern *p
static DWRITE_FONT_STYLE font_extract_style(struct list *tokens, DWRITE_FONT_STYLE style, struct name_token *match) static DWRITE_FONT_STYLE font_extract_style(struct list *tokens, DWRITE_FONT_STYLE style, struct name_token *match)
{ {
static const WCHAR itaW[] = {'i','t','a',0}; static const struct name_pattern italic_patterns[] =
static const WCHAR italW[] = {'i','t','a','l',0}; {
static const WCHAR cursiveW[] = {'c','u','r','s','i','v','e',0}; { L"ita" },
static const WCHAR kursivW[] = {'k','u','r','s','i','v',0}; { L"ital" },
{ L"italic" },
static const WCHAR inclinedW[] = {'i','n','c','l','i','n','e','d',0}; { L"cursive" },
static const WCHAR backslantedW[] = {'b','a','c','k','s','l','a','n','t','e','d',0}; { L"kursiv" },
static const WCHAR backslantW[] = {'b','a','c','k','s','l','a','n','t',0};
static const WCHAR slantedW[] = {'s','l','a','n','t','e','d',0};
static const struct name_pattern italic_patterns[] = {
{ itaW },
{ italW },
{ italicW },
{ cursiveW },
{ kursivW },
{ NULL } { NULL }
}; };
static const struct name_pattern oblique_patterns[] = { static const struct name_pattern oblique_patterns[] =
{ inclinedW }, {
{ obliqueW }, { L"inclined" },
{ backslantedW }, { L"oblique" },
{ backslantW }, { L"backslanted" },
{ slantedW }, { L"backslant" },
{ L"slanted" },
{ NULL } { NULL }
}; };
...@@ -3495,69 +3469,70 @@ static DWRITE_FONT_STYLE font_extract_style(struct list *tokens, DWRITE_FONT_STY ...@@ -3495,69 +3469,70 @@ static DWRITE_FONT_STYLE font_extract_style(struct list *tokens, DWRITE_FONT_STY
static DWRITE_FONT_STRETCH font_extract_stretch(struct list *tokens, DWRITE_FONT_STRETCH stretch, static DWRITE_FONT_STRETCH font_extract_stretch(struct list *tokens, DWRITE_FONT_STRETCH stretch,
struct name_token *match) struct name_token *match)
{ {
static const WCHAR compressedW[] = {'c','o','m','p','r','e','s','s','e','d',0}; static const struct name_pattern ultracondensed_patterns[] =
static const WCHAR extendedW[] = {'e','x','t','e','n','d','e','d',0}; {
static const WCHAR compactW[] = {'c','o','m','p','a','c','t',0}; { L"extra", L"compressed" },
static const WCHAR narrowW[] = {'n','a','r','r','o','w',0}; { L"ext", L"compressed" },
static const WCHAR wideW[] = {'w','i','d','e',0}; { L"ultra", L"compressed" },
static const WCHAR condW[] = {'c','o','n','d',0}; { L"ultra", L"condensed" },
{ L"ultra", L"cond" },
static const struct name_pattern ultracondensed_patterns[] = {
{ extraW, compressedW },
{ extW, compressedW },
{ ultraW, compressedW },
{ ultraW, condensedW },
{ ultraW, condW },
{ NULL } { NULL }
}; };
static const struct name_pattern extracondensed_patterns[] = { static const struct name_pattern extracondensed_patterns[] =
{ compressedW }, {
{ extraW, condensedW }, { L"compressed" },
{ extW, condensedW }, { L"extra", L"condensed" },
{ extraW, condW }, { L"ext", L"condensed" },
{ extW, condW }, { L"extra", L"cond" },
{ L"ext", L"cond" },
{ NULL } { NULL }
}; };
static const struct name_pattern semicondensed_patterns[] = { static const struct name_pattern semicondensed_patterns[] =
{ narrowW }, {
{ compactW }, { L"narrow" },
{ semiW, condensedW }, { L"compact" },
{ semiW, condW }, { L"semi", L"condensed" },
{ L"semi", L"cond" },
{ NULL } { NULL }
}; };
static const struct name_pattern semiexpanded_patterns[] = { static const struct name_pattern semiexpanded_patterns[] =
{ wideW }, {
{ semiW, expandedW }, { L"wide" },
{ semiW, extendedW }, { L"semi", L"expanded" },
{ L"semi", L"extended" },
{ NULL } { NULL }
}; };
static const struct name_pattern extraexpanded_patterns[] = { static const struct name_pattern extraexpanded_patterns[] =
{ extraW, expandedW }, {
{ extW, expandedW }, { L"extra", L"expanded" },
{ extraW, extendedW }, { L"ext", L"expanded" },
{ extW, extendedW }, { L"extra", L"extended" },
{ L"ext", L"extended" },
{ NULL } { NULL }
}; };
static const struct name_pattern ultraexpanded_patterns[] = { static const struct name_pattern ultraexpanded_patterns[] =
{ ultraW, expandedW }, {
{ ultraW, extendedW }, { L"ultra", L"expanded" },
{ L"ultra", L"extended" },
{ NULL } { NULL }
}; };
static const struct name_pattern condensed_patterns[] = { static const struct name_pattern condensed_patterns[] =
{ condensedW }, {
{ condW }, { L"condensed" },
{ L"cond" },
{ NULL } { NULL }
}; };
static const struct name_pattern expanded_patterns[] = { static const struct name_pattern expanded_patterns[] =
{ expandedW }, {
{ extendedW }, { L"expanded" },
{ L"extended" },
{ NULL } { NULL }
}; };
...@@ -3591,82 +3566,92 @@ static DWRITE_FONT_STRETCH font_extract_stretch(struct list *tokens, DWRITE_FONT ...@@ -3591,82 +3566,92 @@ static DWRITE_FONT_STRETCH font_extract_stretch(struct list *tokens, DWRITE_FONT
static DWRITE_FONT_WEIGHT font_extract_weight(struct list *tokens, DWRITE_FONT_WEIGHT weight, static DWRITE_FONT_WEIGHT font_extract_weight(struct list *tokens, DWRITE_FONT_WEIGHT weight,
struct name_token *match) struct name_token *match)
{ {
static const WCHAR heavyW[] = {'h','e','a','v','y',0}; static const struct name_pattern thin_patterns[] =
static const WCHAR nordW[] = {'n','o','r','d',0}; {
{ L"extra", L"thin" },
static const struct name_pattern thin_patterns[] = { { L"ext", L"thin" },
{ extraW, thinW }, { L"ultra", L"thin" },
{ extW, thinW },
{ ultraW, thinW },
{ NULL } { NULL }
}; };
static const struct name_pattern extralight_patterns[] = { static const struct name_pattern extralight_patterns[] =
{ extraW, lightW }, {
{ extW, lightW }, { L"extra", L"light" },
{ ultraW, lightW }, { L"ext", L"light" },
{ L"ultra", L"light" },
{ NULL } { NULL }
}; };
static const struct name_pattern semilight_patterns[] = { static const struct name_pattern semilight_patterns[] =
{ semiW, lightW }, {
{ L"semi", L"light" },
{ NULL } { NULL }
}; };
static const struct name_pattern demibold_patterns[] = { static const struct name_pattern demibold_patterns[] =
{ semiW, boldW }, {
{ demiW, boldW }, { L"semi", L"bold" },
{ L"demi", L"bold" },
{ NULL } { NULL }
}; };
static const struct name_pattern extrabold_patterns[] = { static const struct name_pattern extrabold_patterns[] =
{ extraW, boldW }, {
{ extW, boldW }, { L"extra", L"bold" },
{ ultraW, boldW }, { L"ext", L"bold" },
{ L"ultra", L"bold" },
{ NULL } { NULL }
}; };
static const struct name_pattern extrablack_patterns[] = { static const struct name_pattern extrablack_patterns[] =
{ extraW, blackW }, {
{ extW, blackW }, { L"extra", L"black" },
{ ultraW, blackW }, { L"ext", L"black" },
{ L"ultra", L"black" },
{ NULL } { NULL }
}; };
static const struct name_pattern bold_patterns[] = { static const struct name_pattern bold_patterns[] =
{ boldW }, {
{ L"bold" },
{ NULL } { NULL }
}; };
static const struct name_pattern thin2_patterns[] = { static const struct name_pattern thin2_patterns[] =
{ thinW }, {
{ L"thin" },
{ NULL } { NULL }
}; };
static const struct name_pattern light_patterns[] = { static const struct name_pattern light_patterns[] =
{ lightW }, {
{ L"light" },
{ NULL } { NULL }
}; };
static const struct name_pattern medium_patterns[] = { static const struct name_pattern medium_patterns[] =
{ mediumW }, {
{ L"medium" },
{ NULL } { NULL }
}; };
static const struct name_pattern black_patterns[] = { static const struct name_pattern black_patterns[] =
{ blackW }, {
{ heavyW }, { L"black" },
{ nordW }, { L"heavy" },
{ L"nord" },
{ NULL } { NULL }
}; };
static const struct name_pattern demibold2_patterns[] = { static const struct name_pattern demibold2_patterns[] =
{ demiW }, {
{ L"demi" },
{ NULL } { NULL }
}; };
static const struct name_pattern extrabold2_patterns[] = { static const struct name_pattern extrabold2_patterns[] =
{ ultraW }, {
{ L"ultra" },
{ NULL } { NULL }
}; };
...@@ -3742,31 +3727,22 @@ static int __cdecl compare_knownweights(const void *a, const void* b) ...@@ -3742,31 +3727,22 @@ static int __cdecl compare_knownweights(const void *a, const void* b)
static BOOL is_known_weight_value(DWRITE_FONT_WEIGHT weight, WCHAR *nameW) static BOOL is_known_weight_value(DWRITE_FONT_WEIGHT weight, WCHAR *nameW)
{ {
static const WCHAR extralightW[] = {'E','x','t','r','a',' ','L','i','g','h','t',0}; static const struct knownweight_entry knownweights[] =
static const WCHAR semilightW[] = {'S','e','m','i',' ','L','i','g','h','t',0}; {
static const WCHAR extrablackW[] = {'E','x','t','r','a',' ','B','l','a','c','k',0}; { L"Thin", DWRITE_FONT_WEIGHT_THIN },
static const WCHAR extraboldW[] = {'E','x','t','r','a',' ','B','o','l','d',0}; { L"Extra Light", DWRITE_FONT_WEIGHT_EXTRA_LIGHT },
static const WCHAR demiboldW[] = {'D','e','m','i',' ','B','o','l','d',0}; { L"Light", DWRITE_FONT_WEIGHT_LIGHT },
static const WCHAR thinW[] = {'T','h','i','n',0}; { L"Semi Light", DWRITE_FONT_WEIGHT_SEMI_LIGHT },
static const WCHAR lightW[] = {'L','i','g','h','t',0}; { L"Medium", DWRITE_FONT_WEIGHT_MEDIUM },
static const WCHAR mediumW[] = {'M','e','d','i','u','m',0}; { L"Demi Bold", DWRITE_FONT_WEIGHT_DEMI_BOLD },
static const WCHAR blackW[] = {'B','l','a','c','k',0}; { L"Bold", DWRITE_FONT_WEIGHT_BOLD },
const struct knownweight_entry *ptr; { L"Extra Bold", DWRITE_FONT_WEIGHT_EXTRA_BOLD },
{ L"Black", DWRITE_FONT_WEIGHT_BLACK },
static const struct knownweight_entry knownweights[] = { { L"Extra Black", DWRITE_FONT_WEIGHT_EXTRA_BLACK }
{ thinW, DWRITE_FONT_WEIGHT_THIN },
{ extralightW, DWRITE_FONT_WEIGHT_EXTRA_LIGHT },
{ lightW, DWRITE_FONT_WEIGHT_LIGHT },
{ semilightW, DWRITE_FONT_WEIGHT_SEMI_LIGHT },
{ mediumW, DWRITE_FONT_WEIGHT_MEDIUM },
{ demiboldW, DWRITE_FONT_WEIGHT_DEMI_BOLD },
{ boldW, DWRITE_FONT_WEIGHT_BOLD },
{ extraboldW, DWRITE_FONT_WEIGHT_EXTRA_BOLD },
{ blackW, DWRITE_FONT_WEIGHT_BLACK },
{ extrablackW, DWRITE_FONT_WEIGHT_EXTRA_BLACK }
}; };
const struct knownweight_entry *ptr;
ptr = bsearch(&weight, knownweights, ARRAY_SIZE(knownweights), sizeof(knownweights[0]), ptr = bsearch(&weight, knownweights, ARRAY_SIZE(knownweights), sizeof(*knownweights),
compare_knownweights); compare_knownweights);
if (!ptr) { if (!ptr) {
nameW[0] = 0; nameW[0] = 0;
...@@ -3786,18 +3762,13 @@ static inline void font_name_token_to_str(const struct name_token *name, WCHAR * ...@@ -3786,18 +3762,13 @@ static inline void font_name_token_to_str(const struct name_token *name, WCHAR *
/* Modifies facenameW string, and returns pointer to regular term that was removed */ /* Modifies facenameW string, and returns pointer to regular term that was removed */
static const WCHAR *facename_remove_regular_term(WCHAR *facenameW, INT len) static const WCHAR *facename_remove_regular_term(WCHAR *facenameW, INT len)
{ {
static const WCHAR bookW[] = {'B','o','o','k',0}; static const WCHAR *regular_patterns[] =
static const WCHAR normalW[] = {'N','o','r','m','a','l',0}; {
static const WCHAR regularW[] = {'R','e','g','u','l','a','r',0}; L"Book",
static const WCHAR romanW[] = {'R','o','m','a','n',0}; L"Normal",
static const WCHAR uprightW[] = {'U','p','r','i','g','h','t',0}; L"Regular",
L"Roman",
static const WCHAR *regular_patterns[] = { L"Upright",
bookW,
normalW,
regularW,
romanW,
uprightW,
NULL NULL
}; };
...@@ -3902,7 +3873,7 @@ static BOOL font_apply_differentiation_rules(struct dwrite_font_data *font, WCHA ...@@ -3902,7 +3873,7 @@ static BOOL font_apply_differentiation_rules(struct dwrite_font_data *font, WCHA
/* append face name to family name, FIXME check if face name is a substring of family name */ /* append face name to family name, FIXME check if face name is a substring of family name */
if (*facenameW) if (*facenameW)
{ {
wcscat(familynameW, spaceW); wcscat(familynameW, L" ");
wcscat(familynameW, facenameW); wcscat(familynameW, facenameW);
} }
...@@ -3968,10 +3939,7 @@ static BOOL font_apply_differentiation_rules(struct dwrite_font_data *font, WCHA ...@@ -3968,10 +3939,7 @@ static BOOL font_apply_differentiation_rules(struct dwrite_font_data *font, WCHA
} }
/* use Wnnn format as a fallback in case weight is not one of known values */ /* use Wnnn format as a fallback in case weight is not one of known values */
else else
{ swprintf(weightW, ARRAY_SIZE(weightW), L"W%d", font->weight);
static const WCHAR fmtW[] = {'W','%','d',0};
swprintf(weightW, ARRAY_SIZE(weightW), fmtW, font->weight);
}
/* resolved stretch name */ /* resolved stretch name */
if (stretch_name.ptr) if (stretch_name.ptr)
...@@ -3980,25 +3948,20 @@ static BOOL font_apply_differentiation_rules(struct dwrite_font_data *font, WCHA ...@@ -3980,25 +3948,20 @@ static BOOL font_apply_differentiation_rules(struct dwrite_font_data *font, WCHA
else if (font->stretch == DWRITE_FONT_STRETCH_NORMAL) else if (font->stretch == DWRITE_FONT_STRETCH_NORMAL)
stretchW[0] = 0; stretchW[0] = 0;
/* use predefined stretch names */ /* use predefined stretch names */
else { else
static const WCHAR ultracondensedW[] = {'U','l','t','r','a',' ','C','o','n','d','e','n','s','e','d',0}; {
static const WCHAR extracondensedW[] = {'E','x','t','r','a',' ','C','o','n','d','e','n','s','e','d',0}; static const WCHAR *stretchnamesW[] =
static const WCHAR semicondensedW[] = {'S','e','m','i',' ','C','o','n','d','e','n','s','e','d',0}; {
static const WCHAR semiexpandedW[] = {'S','e','m','i',' ','E','x','p','a','n','d','e','d',0};
static const WCHAR extraexpandedW[] = {'E','x','t','r','a',' ','E','x','p','a','n','d','e','d',0};
static const WCHAR ultraexpandedW[] = {'U','l','t','r','a',' ','E','x','p','a','n','d','e','d',0};
static const WCHAR *stretchnamesW[] = {
NULL, /* DWRITE_FONT_STRETCH_UNDEFINED */ NULL, /* DWRITE_FONT_STRETCH_UNDEFINED */
ultracondensedW, L"Ultra Condensed",
extracondensedW, L"Extra Condensed",
condensedW, L"Condensed",
semicondensedW, L"Semi Condensed",
NULL, /* DWRITE_FONT_STRETCH_NORMAL */ NULL, /* DWRITE_FONT_STRETCH_NORMAL */
semiexpandedW, L"Semi Expanded",
expandedW, L"Expanded",
extraexpandedW, L"Extra Expanded",
ultraexpandedW L"Ultra Expanded"
}; };
wcscpy(stretchW, stretchnamesW[font->stretch]); wcscpy(stretchW, stretchnamesW[font->stretch]);
} }
...@@ -4009,16 +3972,12 @@ static BOOL font_apply_differentiation_rules(struct dwrite_font_data *font, WCHA ...@@ -4009,16 +3972,12 @@ static BOOL font_apply_differentiation_rules(struct dwrite_font_data *font, WCHA
else if (font->style == DWRITE_FONT_STYLE_NORMAL) else if (font->style == DWRITE_FONT_STYLE_NORMAL)
styleW[0] = 0; styleW[0] = 0;
/* use predefined names */ /* use predefined names */
else { else
if (font->style == DWRITE_FONT_STYLE_ITALIC) wcscpy(styleW, font->style == DWRITE_FONT_STYLE_ITALIC ? L"Italic" : L"Oblique");
wcscpy(styleW, italicW);
else
wcscpy(styleW, obliqueW);
}
/* use Regular match if it was found initially */ /* use Regular match if it was found initially */
if (!*weightW && !*stretchW && !*styleW) if (!*weightW && !*stretchW && !*styleW)
wcscpy(faceW, regular_ptr ? regular_ptr : regularW); wcscpy(faceW, regular_ptr ? regular_ptr : L"Regular");
else else
{ {
faceW[0] = 0; faceW[0] = 0;
...@@ -4027,13 +3986,13 @@ static BOOL font_apply_differentiation_rules(struct dwrite_font_data *font, WCHA ...@@ -4027,13 +3986,13 @@ static BOOL font_apply_differentiation_rules(struct dwrite_font_data *font, WCHA
if (*weightW) if (*weightW)
{ {
if (*faceW) wcscat(faceW, spaceW); if (*faceW) wcscat(faceW, L" ");
wcscat(faceW, weightW); wcscat(faceW, weightW);
} }
if (*styleW) if (*styleW)
{ {
if (*faceW) wcscat(faceW, spaceW); if (*faceW) wcscat(faceW, L" ");
wcscat(faceW, styleW); wcscat(faceW, styleW);
} }
} }
...@@ -4143,7 +4102,7 @@ static HRESULT init_font_data_from_font(const struct dwrite_font_data *src, DWRI ...@@ -4143,7 +4102,7 @@ static HRESULT init_font_data_from_font(const struct dwrite_font_data *src, DWRI
IDWriteLocalizedStrings_AddRef(data->family_names); IDWriteLocalizedStrings_AddRef(data->family_names);
create_localizedstrings(&data->names); create_localizedstrings(&data->names);
add_localizedstring(data->names, enusW, facenameW); add_localizedstring(data->names, L"en-us", facenameW);
init_font_prop_vec(data->weight, data->stretch, data->style, &data->propvec); init_font_prop_vec(data->weight, data->stretch, data->style, &data->propvec);
...@@ -4196,19 +4155,21 @@ static void fontfamily_add_bold_simulated_face(struct dwrite_fontfamily_data *fa ...@@ -4196,19 +4155,21 @@ static void fontfamily_add_bold_simulated_face(struct dwrite_fontfamily_data *fa
} }
} }
if (weight >= DWRITE_FONT_WEIGHT_SEMI_LIGHT && weight <= 550) { if (weight >= DWRITE_FONT_WEIGHT_SEMI_LIGHT && weight <= 550)
static const struct name_pattern weightsim_patterns[] = { {
{ extraW, lightW }, static const struct name_pattern weightsim_patterns[] =
{ extW, lightW }, {
{ ultraW, lightW }, { L"extra", L"light" },
{ semiW, lightW }, { L"ext", L"light" },
{ semiW, boldW }, { L"ultra", L"light" },
{ demiW, boldW }, { L"semi", L"light" },
{ boldW }, { L"semi", L"bold" },
{ thinW }, { L"demi", L"bold" },
{ lightW }, { L"bold" },
{ mediumW }, { L"thin" },
{ demiW }, { L"light" },
{ L"medium" },
{ L"demi" },
{ NULL } { NULL }
}; };
...@@ -4229,8 +4190,8 @@ static void fontfamily_add_bold_simulated_face(struct dwrite_fontfamily_data *fa ...@@ -4229,8 +4190,8 @@ static void fontfamily_add_bold_simulated_face(struct dwrite_fontfamily_data *fa
fontname_tokens_to_str(&tokens, facenameW); fontname_tokens_to_str(&tokens, facenameW);
/* Bold suffix for new name */ /* Bold suffix for new name */
if (*facenameW) wcscat(facenameW, spaceW); if (*facenameW) wcscat(facenameW, L" ");
wcscat(facenameW, boldW); wcscat(facenameW, L"Bold");
if (init_font_data_from_font(family->fonts[heaviest], DWRITE_FONT_SIMULATIONS_BOLD, facenameW, &boldface) == S_OK) { if (init_font_data_from_font(family->fonts[heaviest], DWRITE_FONT_SIMULATIONS_BOLD, facenameW, &boldface) == S_OK) {
boldface->bold_sim_tested = 1; boldface->bold_sim_tested = 1;
...@@ -4295,8 +4256,8 @@ static void fontfamily_add_oblique_simulated_face(struct dwrite_fontfamily_data ...@@ -4295,8 +4256,8 @@ static void fontfamily_add_oblique_simulated_face(struct dwrite_fontfamily_data
fontstrings_get_en_string(family->fonts[regular]->names, facenameW, ARRAY_SIZE(facenameW)); fontstrings_get_en_string(family->fonts[regular]->names, facenameW, ARRAY_SIZE(facenameW));
facename_remove_regular_term(facenameW, -1); facename_remove_regular_term(facenameW, -1);
if (*facenameW) wcscat(facenameW, spaceW); if (*facenameW) wcscat(facenameW, L" ");
wcscat(facenameW, obliqueW); wcscat(facenameW, L"Oblique");
if (init_font_data_from_font(family->fonts[regular], DWRITE_FONT_SIMULATIONS_OBLIQUE, facenameW, &obliqueface) == S_OK) { if (init_font_data_from_font(family->fonts[regular], DWRITE_FONT_SIMULATIONS_OBLIQUE, facenameW, &obliqueface) == S_OK) {
obliqueface->oblique_sim_tested = 1; obliqueface->oblique_sim_tested = 1;
...@@ -4323,7 +4284,7 @@ static BOOL fontcollection_add_replacement(struct dwrite_fontcollection *collect ...@@ -4323,7 +4284,7 @@ static BOOL fontcollection_add_replacement(struct dwrite_fontcollection *collect
return FALSE; return FALSE;
/* add a new family with target name, reuse font data from replacement */ /* add a new family with target name, reuse font data from replacement */
add_localizedstring(strings, enusW, target_name); add_localizedstring(strings, L"en-us", target_name);
hr = init_fontfamily_data(strings, &target); hr = init_fontfamily_data(strings, &target);
if (hr == S_OK) { if (hr == S_OK) {
struct dwrite_fontfamily_data *replacement = collection->family_data[i]; struct dwrite_fontfamily_data *replacement = collection->family_data[i];
...@@ -4612,11 +4573,10 @@ static HRESULT create_local_file_reference(IDWriteFactory7 *factory, const WCHAR ...@@ -4612,11 +4573,10 @@ static HRESULT create_local_file_reference(IDWriteFactory7 *factory, const WCHAR
/* Fonts installed in 'Fonts' system dir don't get full path in registry font files cache */ /* Fonts installed in 'Fonts' system dir don't get full path in registry font files cache */
if (!wcschr(filename, '\\')) if (!wcschr(filename, '\\'))
{ {
static const WCHAR fontsW[] = {'\\','f','o','n','t','s','\\',0};
WCHAR fullpathW[MAX_PATH]; WCHAR fullpathW[MAX_PATH];
GetWindowsDirectoryW(fullpathW, ARRAY_SIZE(fullpathW)); GetWindowsDirectoryW(fullpathW, ARRAY_SIZE(fullpathW));
wcscat(fullpathW, fontsW); wcscat(fullpathW, L"\\fonts\\");
wcscat(fullpathW, filename); wcscat(fullpathW, filename);
hr = IDWriteFactory7_CreateFontFileReference(factory, fullpathW, NULL, file); hr = IDWriteFactory7_CreateFontFileReference(factory, fullpathW, NULL, file);
...@@ -4707,11 +4667,6 @@ static const IDWriteFontFileEnumeratorVtbl systemfontfileenumeratorvtbl = ...@@ -4707,11 +4667,6 @@ static const IDWriteFontFileEnumeratorVtbl systemfontfileenumeratorvtbl =
static HRESULT create_system_fontfile_enumerator(IDWriteFactory7 *factory, IDWriteFontFileEnumerator **ret) static HRESULT create_system_fontfile_enumerator(IDWriteFactory7 *factory, IDWriteFontFileEnumerator **ret)
{ {
struct system_fontfile_enumerator *enumerator; struct system_fontfile_enumerator *enumerator;
static const WCHAR fontslistW[] = {
'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'F','o','n','t','s',0
};
*ret = NULL; *ret = NULL;
...@@ -4732,7 +4687,8 @@ static HRESULT create_system_fontfile_enumerator(IDWriteFactory7 *factory, IDWri ...@@ -4732,7 +4687,8 @@ static HRESULT create_system_fontfile_enumerator(IDWriteFactory7 *factory, IDWri
IDWriteFactory7_AddRef(factory); IDWriteFactory7_AddRef(factory);
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, fontslistW, 0, GENERIC_READ, &enumerator->hkey)) if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Fonts", 0,
GENERIC_READ, &enumerator->hkey))
{ {
ERR("failed to open fonts list key\n"); ERR("failed to open fonts list key\n");
IDWriteFactory7_Release(factory); IDWriteFactory7_Release(factory);
...@@ -4766,8 +4722,6 @@ HRESULT get_system_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollectio ...@@ -4766,8 +4722,6 @@ HRESULT get_system_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollectio
static HRESULT eudc_collection_add_family(IDWriteFactory7 *factory, struct dwrite_fontcollection *collection, static HRESULT eudc_collection_add_family(IDWriteFactory7 *factory, struct dwrite_fontcollection *collection,
const WCHAR *keynameW, const WCHAR *pathW) const WCHAR *keynameW, const WCHAR *pathW)
{ {
static const WCHAR defaultfontW[] = {'S','y','s','t','e','m','D','e','f','a','u','l','t','E','U','D','C','F','o','n','t',0};
static const WCHAR emptyW[] = {0};
struct dwrite_fontfamily_data *family_data; struct dwrite_fontfamily_data *family_data;
IDWriteLocalizedStrings *names; IDWriteLocalizedStrings *names;
DWRITE_FONT_FACE_TYPE face_type; DWRITE_FONT_FACE_TYPE face_type;
...@@ -4802,10 +4756,10 @@ static HRESULT eudc_collection_add_family(IDWriteFactory7 *factory, struct dwrit ...@@ -4802,10 +4756,10 @@ static HRESULT eudc_collection_add_family(IDWriteFactory7 *factory, struct dwrit
/* Family names are added for non-specific locale, represented with empty string. /* Family names are added for non-specific locale, represented with empty string.
Default family appears with empty family name. */ Default family appears with empty family name. */
create_localizedstrings(&names); create_localizedstrings(&names);
if (!wcsicmp(keynameW, defaultfontW)) if (!wcsicmp(keynameW, L"SystemDefaultEUDCFont"))
add_localizedstring(names, emptyW, emptyW); add_localizedstring(names, L"", L"");
else else
add_localizedstring(names, emptyW, keynameW); add_localizedstring(names, L"", keynameW);
hr = init_fontfamily_data(names, &family_data); hr = init_fontfamily_data(names, &family_data);
IDWriteLocalizedStrings_Release(names); IDWriteLocalizedStrings_Release(names);
...@@ -4850,9 +4804,7 @@ static HRESULT eudc_collection_add_family(IDWriteFactory7 *factory, struct dwrit ...@@ -4850,9 +4804,7 @@ static HRESULT eudc_collection_add_family(IDWriteFactory7 *factory, struct dwrit
HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 **ret) HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 **ret)
{ {
static const WCHAR eudckeyfmtW[] = {'E','U','D','C','\\','%','u',0};
struct dwrite_fontcollection *collection; struct dwrite_fontcollection *collection;
static const WCHAR emptyW[] = {0};
WCHAR eudckeypathW[16]; WCHAR eudckeypathW[16];
HKEY eudckey; HKEY eudckey;
DWORD index; DWORD index;
...@@ -4879,7 +4831,7 @@ HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 ...@@ -4879,7 +4831,7 @@ HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3
IDWriteFactory7_AddRef(factory); IDWriteFactory7_AddRef(factory);
/* return empty collection if EUDC fonts are not configured */ /* return empty collection if EUDC fonts are not configured */
swprintf(eudckeypathW, ARRAY_SIZE(eudckeypathW), eudckeyfmtW, GetACP()); swprintf(eudckeypathW, ARRAY_SIZE(eudckeypathW), L"EUDC\\%u", GetACP());
if (RegOpenKeyExW(HKEY_CURRENT_USER, eudckeypathW, 0, GENERIC_READ, &eudckey)) if (RegOpenKeyExW(HKEY_CURRENT_USER, eudckeypathW, 0, GENERIC_READ, &eudckey))
return S_OK; return S_OK;
...@@ -4903,11 +4855,11 @@ HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3 ...@@ -4903,11 +4855,11 @@ HRESULT get_eudc_fontcollection(IDWriteFactory7 *factory, IDWriteFontCollection3
/* try to add global default if not defined for specific codepage */ /* try to add global default if not defined for specific codepage */
exists = FALSE; exists = FALSE;
hr = IDWriteFontCollection3_FindFamilyName(&collection->IDWriteFontCollection3_iface, emptyW, hr = IDWriteFontCollection3_FindFamilyName(&collection->IDWriteFontCollection3_iface, L"",
&index, &exists); &index, &exists);
if (FAILED(hr) || !exists) { if (FAILED(hr) || !exists)
static const WCHAR globaldefaultW[] = {'E','U','D','C','.','T','T','E',0}; {
hr = eudc_collection_add_family(factory, collection, emptyW, globaldefaultW); hr = eudc_collection_add_family(factory, collection, L"", L"EUDC.TTE");
if (hr != S_OK) if (hr != S_OK)
WARN("failed to add global default EUDC font, 0x%08x\n", hr); WARN("failed to add global default EUDC font, 0x%08x\n", hr);
} }
......
...@@ -531,13 +531,12 @@ HRESULT clone_localizedstrings(IDWriteLocalizedStrings *iface, IDWriteLocalizedS ...@@ -531,13 +531,12 @@ HRESULT clone_localizedstrings(IDWriteLocalizedStrings *iface, IDWriteLocalizedS
void set_en_localizedstring(IDWriteLocalizedStrings *iface, const WCHAR *string) void set_en_localizedstring(IDWriteLocalizedStrings *iface, const WCHAR *string)
{ {
static const WCHAR enusW[] = {'e','n','-','U','S',0};
struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface); struct localizedstrings *strings = impl_from_IDWriteLocalizedStrings(iface);
UINT32 i; UINT32 i;
for (i = 0; i < strings->count; i++) for (i = 0; i < strings->count; i++)
{ {
if (!wcsicmp(strings->data[i].locale, enusW)) if (!wcsicmp(strings->data[i].locale, L"en-US"))
{ {
heap_free(strings->data[i].string); heap_free(strings->data[i].string);
strings->data[i].string = heap_strdupW(string); strings->data[i].string = heap_strdupW(string);
...@@ -1573,12 +1572,11 @@ static HRESULT create_system_path_list(WCHAR ***ret, unsigned int *ret_count) ...@@ -1573,12 +1572,11 @@ static HRESULT create_system_path_list(WCHAR ***ret, unsigned int *ret_count)
{ {
if (!wcschr(value, '\\')) if (!wcschr(value, '\\'))
{ {
static const WCHAR fontsW[] = {'\\','f','o','n','t','s','\\',0};
WCHAR *ptrW; WCHAR *ptrW;
ptrW = heap_alloc((MAX_PATH + wcslen(value)) * sizeof(WCHAR)); ptrW = heap_alloc((MAX_PATH + wcslen(value)) * sizeof(WCHAR));
GetWindowsDirectoryW(ptrW, MAX_PATH); GetWindowsDirectoryW(ptrW, MAX_PATH);
wcscat(ptrW, fontsW); wcscat(ptrW, L"\\fonts\\");
wcscat(ptrW, value); wcscat(ptrW, value);
heap_free(value); heap_free(value);
......
...@@ -2252,9 +2252,8 @@ static UINT get_name_record_codepage(enum OPENTYPE_PLATFORM_ID platform, USHORT ...@@ -2252,9 +2252,8 @@ static UINT get_name_record_codepage(enum OPENTYPE_PLATFORM_ID platform, USHORT
static void get_name_record_locale(enum OPENTYPE_PLATFORM_ID platform, USHORT lang_id, WCHAR *locale, USHORT locale_len) static void get_name_record_locale(enum OPENTYPE_PLATFORM_ID platform, USHORT lang_id, WCHAR *locale, USHORT locale_len)
{ {
static const WCHAR enusW[] = {'e','n','-','U','S',0}; switch (platform)
{
switch (platform) {
case OPENTYPE_PLATFORM_MAC: case OPENTYPE_PLATFORM_MAC:
{ {
const char *locale_name = NULL; const char *locale_name = NULL;
...@@ -2269,18 +2268,18 @@ static void get_name_record_locale(enum OPENTYPE_PLATFORM_ID platform, USHORT la ...@@ -2269,18 +2268,18 @@ static void get_name_record_locale(enum OPENTYPE_PLATFORM_ID platform, USHORT la
if (locale_name) if (locale_name)
MultiByteToWideChar(CP_ACP, 0, name_mac_langid_to_locale[lang_id], -1, locale, locale_len); MultiByteToWideChar(CP_ACP, 0, name_mac_langid_to_locale[lang_id], -1, locale, locale_len);
else else
wcscpy(locale, enusW); wcscpy(locale, L"en-US");
break; break;
} }
case OPENTYPE_PLATFORM_WIN: case OPENTYPE_PLATFORM_WIN:
if (!LCIDToLocaleName(MAKELCID(lang_id, SORT_DEFAULT), locale, locale_len, 0)) if (!LCIDToLocaleName(MAKELCID(lang_id, SORT_DEFAULT), locale, locale_len, 0))
{ {
FIXME("failed to get locale name for lcid=0x%08x\n", MAKELCID(lang_id, SORT_DEFAULT)); FIXME("failed to get locale name for lcid=0x%08x\n", MAKELCID(lang_id, SORT_DEFAULT));
wcscpy(locale, enusW); wcscpy(locale, L"en-US");
} }
break; break;
case OPENTYPE_PLATFORM_UNICODE: case OPENTYPE_PLATFORM_UNICODE:
wcscpy(locale, enusW); wcscpy(locale, L"en-US");
break; break;
default: default:
FIXME("unknown platform %d\n", platform); FIXME("unknown platform %d\n", platform);
...@@ -2301,7 +2300,6 @@ static BOOL opentype_is_english_namerecord(const struct dwrite_fonttable *table, ...@@ -2301,7 +2300,6 @@ static BOOL opentype_is_english_namerecord(const struct dwrite_fonttable *table,
static BOOL opentype_decode_namerecord(const struct dwrite_fonttable *table, unsigned int idx, static BOOL opentype_decode_namerecord(const struct dwrite_fonttable *table, unsigned int idx,
IDWriteLocalizedStrings *strings) IDWriteLocalizedStrings *strings)
{ {
static const WCHAR enusW[] = {'e','n','-','U','S',0};
USHORT lang_id, length, offset, encoding, platform; USHORT lang_id, length, offset, encoding, platform;
const struct name_header *header = (const struct name_header *)table->data; const struct name_header *header = (const struct name_header *)table->data;
const struct name_record *record; const struct name_record *record;
...@@ -2350,7 +2348,7 @@ static BOOL opentype_decode_namerecord(const struct dwrite_fonttable *table, uns ...@@ -2350,7 +2348,7 @@ static BOOL opentype_decode_namerecord(const struct dwrite_fonttable *table, uns
add_localizedstring(strings, locale, name_string); add_localizedstring(strings, locale, name_string);
heap_free(name_string); heap_free(name_string);
ret = !wcscmp(locale, enusW); ret = !wcscmp(locale, L"en-US");
} }
else else
FIXME("handle NAME format 1\n"); FIXME("handle NAME format 1\n");
...@@ -2443,14 +2441,13 @@ static HRESULT opentype_get_font_strings_from_id(const struct dwrite_fonttable * ...@@ -2443,14 +2441,13 @@ static HRESULT opentype_get_font_strings_from_id(const struct dwrite_fonttable *
static WCHAR *meta_get_lng_name(WCHAR *str, WCHAR **ctx) static WCHAR *meta_get_lng_name(WCHAR *str, WCHAR **ctx)
{ {
static const WCHAR delimW[] = {',',' ',0};
WCHAR *ret; WCHAR *ret;
if (!str) str = *ctx; if (!str) str = *ctx;
while (*str && wcschr(delimW, *str)) str++; while (*str && wcschr(L", ", *str)) str++;
if (!*str) return NULL; if (!*str) return NULL;
ret = str++; ret = str++;
while (*str && !wcschr(delimW, *str)) str++; while (*str && !wcschr(L", ", *str)) str++;
if (*str) *str++ = 0; if (*str) *str++ = 0;
*ctx = str; *ctx = str;
...@@ -2460,7 +2457,6 @@ static WCHAR *meta_get_lng_name(WCHAR *str, WCHAR **ctx) ...@@ -2460,7 +2457,6 @@ static WCHAR *meta_get_lng_name(WCHAR *str, WCHAR **ctx)
static HRESULT opentype_get_font_strings_from_meta(const struct file_stream_desc *stream_desc, static HRESULT opentype_get_font_strings_from_meta(const struct file_stream_desc *stream_desc,
DWRITE_INFORMATIONAL_STRING_ID id, IDWriteLocalizedStrings **ret) DWRITE_INFORMATIONAL_STRING_ID id, IDWriteLocalizedStrings **ret)
{ {
static const WCHAR emptyW[] = { 0 };
const struct meta_data_map *maps; const struct meta_data_map *maps;
IDWriteLocalizedStrings *strings; IDWriteLocalizedStrings *strings;
struct dwrite_fonttable meta; struct dwrite_fonttable meta;
...@@ -2528,7 +2524,7 @@ static HRESULT opentype_get_font_strings_from_meta(const struct file_stream_desc ...@@ -2528,7 +2524,7 @@ static HRESULT opentype_get_font_strings_from_meta(const struct file_stream_desc
while (token) while (token)
{ {
add_localizedstring(strings, emptyW, token); add_localizedstring(strings, L"", token);
token = meta_get_lng_name(NULL, &ctx); token = meta_get_lng_name(NULL, &ctx);
} }
...@@ -2632,7 +2628,6 @@ HRESULT opentype_get_font_facename(struct file_stream_desc *stream_desc, WCHAR * ...@@ -2632,7 +2628,6 @@ HRESULT opentype_get_font_facename(struct file_stream_desc *stream_desc, WCHAR *
*lfname = 0; *lfname = 0;
if (SUCCEEDED(opentype_get_font_strings_from_id(&name, OPENTYPE_STRING_FAMILY_NAME, &lfnames))) if (SUCCEEDED(opentype_get_font_strings_from_id(&name, OPENTYPE_STRING_FAMILY_NAME, &lfnames)))
{ {
static const WCHAR enusW[] = {'e','n','-','u','s',0};
WCHAR localeW[LOCALE_NAME_MAX_LENGTH]; WCHAR localeW[LOCALE_NAME_MAX_LENGTH];
UINT32 index; UINT32 index;
BOOL exists; BOOL exists;
...@@ -2642,7 +2637,7 @@ HRESULT opentype_get_font_facename(struct file_stream_desc *stream_desc, WCHAR * ...@@ -2642,7 +2637,7 @@ HRESULT opentype_get_font_facename(struct file_stream_desc *stream_desc, WCHAR *
IDWriteLocalizedStrings_FindLocaleName(lfnames, localeW, &index, &exists); IDWriteLocalizedStrings_FindLocaleName(lfnames, localeW, &index, &exists);
if (!exists) if (!exists)
IDWriteLocalizedStrings_FindLocaleName(lfnames, enusW, &index, &exists); IDWriteLocalizedStrings_FindLocaleName(lfnames, L"en-us", &index, &exists);
if (exists) { if (exists) {
UINT32 length = 0; UINT32 length = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment