Commit abc8f2c6 authored by Qian Hong's avatar Qian Hong Committed by Alexandre Julliard

gdi32: Read otmpFaceName from TT_NAME_ID_FULL_NAME.

parent 180185d8
...@@ -2624,13 +2624,12 @@ static void update_reg_entries(void) ...@@ -2624,13 +2624,12 @@ static void update_reg_entries(void)
{ {
HKEY winnt_key = 0, win9x_key = 0, external_key = 0; HKEY winnt_key = 0, win9x_key = 0, external_key = 0;
LPWSTR valueW; LPWSTR valueW;
DWORD len, len_fam; DWORD len;
Family *family; Family *family;
Face *face; Face *face;
struct list *family_elem_ptr, *face_elem_ptr; struct list *family_elem_ptr, *face_elem_ptr;
WCHAR *file; WCHAR *file;
static const WCHAR TrueType[] = {' ','(','T','r','u','e','T','y','p','e',')','\0'}; static const WCHAR TrueType[] = {' ','(','T','r','u','e','T','y','p','e',')','\0'};
static const WCHAR spaceW[] = {' ', '\0'};
char *path; char *path;
if(RegCreateKeyExW(HKEY_LOCAL_MACHINE, winnt_font_reg_key, if(RegCreateKeyExW(HKEY_LOCAL_MACHINE, winnt_font_reg_key,
...@@ -2655,20 +2654,22 @@ static void update_reg_entries(void) ...@@ -2655,20 +2654,22 @@ static void update_reg_entries(void)
LIST_FOR_EACH(family_elem_ptr, &font_list) { LIST_FOR_EACH(family_elem_ptr, &font_list) {
family = LIST_ENTRY(family_elem_ptr, Family, entry); family = LIST_ENTRY(family_elem_ptr, Family, entry);
len_fam = strlenW(family->FamilyName) + sizeof(TrueType) / sizeof(WCHAR) + 1;
LIST_FOR_EACH(face_elem_ptr, &family->faces) { LIST_FOR_EACH(face_elem_ptr, &family->faces) {
face = LIST_ENTRY(face_elem_ptr, Face, entry); face = LIST_ENTRY(face_elem_ptr, Face, entry);
if(!face->external) continue; if(!face->external) continue;
len = len_fam;
if (!(face->ntmFlags & NTM_REGULAR)) if(face->FullName)
len = len_fam + strlenW(face->StyleName) + 1; {
len = strlenW(face->FullName) + sizeof(TrueType) / sizeof(WCHAR) + 1;
valueW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
strcpyW(valueW, face->FullName);
}
else
{
len = strlenW(family->FamilyName) + sizeof(TrueType) / sizeof(WCHAR) + 1;
valueW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); valueW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
strcpyW(valueW, family->FamilyName); strcpyW(valueW, family->FamilyName);
if(len != len_fam) {
strcatW(valueW, spaceW);
strcatW(valueW, face->StyleName);
} }
strcatW(valueW, TrueType);
file = wine_get_dos_file_name(face->file); file = wine_get_dos_file_name(face->file);
if(file) if(file)
...@@ -5078,7 +5079,7 @@ static void GetEnumStructs(Face *face, LPENUMLOGFONTEXW pelf, ...@@ -5078,7 +5079,7 @@ static void GetEnumStructs(Face *face, LPENUMLOGFONTEXW pelf,
(WCHAR*)((char*)font->potm + (ULONG_PTR)font->potm->otmpFamilyName), (WCHAR*)((char*)font->potm + (ULONG_PTR)font->potm->otmpFamilyName),
LF_FACESIZE); LF_FACESIZE);
lstrcpynW(pelf->elfFullName, lstrcpynW(pelf->elfFullName,
(WCHAR*)((char*)font->potm + (ULONG_PTR)font->potm->otmpFullName), (WCHAR*)((char*)font->potm + (ULONG_PTR)font->potm->otmpFaceName),
LF_FULLFACESIZE); LF_FULLFACESIZE);
lstrcpynW(pelf->elfStyle, lstrcpynW(pelf->elfStyle,
(WCHAR*)((char*)font->potm + (ULONG_PTR)font->potm->otmpStyleName), (WCHAR*)((char*)font->potm + (ULONG_PTR)font->potm->otmpStyleName),
...@@ -5138,15 +5139,6 @@ static void GetEnumStructs(Face *face, LPENUMLOGFONTEXW pelf, ...@@ -5138,15 +5139,6 @@ static void GetEnumStructs(Face *face, LPENUMLOGFONTEXW pelf,
free_font(font); free_font(font);
} }
static void create_full_name(WCHAR *full_name, const WCHAR *family_name, const WCHAR *style_name)
{
static const WCHAR spaceW[] = { ' ', 0 };
strcpyW(full_name, family_name);
strcatW(full_name, spaceW);
strcatW(full_name, style_name);
}
static BOOL family_matches(Family *family, const LOGFONTW *lf) static BOOL family_matches(Family *family, const LOGFONTW *lf)
{ {
const struct list *face_list, *face_elem_ptr; const struct list *face_list, *face_elem_ptr;
...@@ -5156,18 +5148,9 @@ static BOOL family_matches(Family *family, const LOGFONTW *lf) ...@@ -5156,18 +5148,9 @@ static BOOL family_matches(Family *family, const LOGFONTW *lf)
face_list = get_face_list_from_family(family); face_list = get_face_list_from_family(family);
LIST_FOR_EACH(face_elem_ptr, face_list) LIST_FOR_EACH(face_elem_ptr, face_list)
{ {
WCHAR full_family_name[LF_FULLFACESIZE];
Face *face = LIST_ENTRY(face_elem_ptr, Face, entry); Face *face = LIST_ENTRY(face_elem_ptr, Face, entry);
if (strlenW(family->FamilyName) + strlenW(face->StyleName) + 2 > LF_FULLFACESIZE) if (face->FullName && !strcmpiW(lf->lfFaceName, face->FullName)) return TRUE;
{
FIXME("Length of %s + %s + 2 is longer than LF_FULLFACESIZE\n",
debugstr_w(family->FamilyName), debugstr_w(face->StyleName));
continue;
}
create_full_name(full_family_name, family->FamilyName, face->StyleName);
if (!strcmpiW(lf->lfFaceName, full_family_name)) return TRUE;
} }
return FALSE; return FALSE;
...@@ -5175,19 +5158,9 @@ static BOOL family_matches(Family *family, const LOGFONTW *lf) ...@@ -5175,19 +5158,9 @@ static BOOL family_matches(Family *family, const LOGFONTW *lf)
static BOOL face_matches(const WCHAR *family_name, Face *face, const LOGFONTW *lf) static BOOL face_matches(const WCHAR *family_name, Face *face, const LOGFONTW *lf)
{ {
WCHAR full_family_name[LF_FULLFACESIZE];
if (!strcmpiW(lf->lfFaceName, family_name)) return TRUE; if (!strcmpiW(lf->lfFaceName, family_name)) return TRUE;
if (strlenW(family_name) + strlenW(face->StyleName) + 2 > LF_FULLFACESIZE) return (face->FullName && !strcmpiW(lf->lfFaceName, face->FullName));
{
FIXME("Length of %s + %s + 2 is longer than LF_FULLFACESIZE\n",
debugstr_w(family_name), debugstr_w(face->StyleName));
return FALSE;
}
create_full_name(full_family_name, family_name, face->StyleName);
return !strcmpiW(lf->lfFaceName, full_family_name);
} }
static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_charset_list *list, static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_charset_list *list,
...@@ -5216,7 +5189,10 @@ static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_cha ...@@ -5216,7 +5189,10 @@ static BOOL enum_face_charsets(const Family *family, Face *face, struct enum_cha
if (family != face->family) if (family != face->family)
{ {
strcpyW(elf.elfLogFont.lfFaceName, family->FamilyName); strcpyW(elf.elfLogFont.lfFaceName, family->FamilyName);
create_full_name(elf.elfFullName, family->FamilyName, face->StyleName); if (face->FullName)
strcpyW(elf.elfFullName, face->FullName);
else
strcpyW(elf.elfFullName, family->FamilyName);
} }
TRACE("enuming face %s full %s style %s charset = %d type %d script %s it %d weight %d ntmflags %08x\n", TRACE("enuming face %s full %s style %s charset = %d type %d script %s it %d weight %d ntmflags %08x\n",
debugstr_w(elf.elfLogFont.lfFaceName), debugstr_w(elf.elfLogFont.lfFaceName),
...@@ -6552,12 +6528,12 @@ static BOOL get_outline_text_metrics(GdiFont *font) ...@@ -6552,12 +6528,12 @@ static BOOL get_outline_text_metrics(GdiFont *font)
{ {
BOOL ret = FALSE; BOOL ret = FALSE;
FT_Face ft_face = font->ft_face; FT_Face ft_face = font->ft_face;
UINT needed, lenfam, lensty; UINT needed, lenfam, lensty, lenface;
TT_OS2 *pOS2; TT_OS2 *pOS2;
TT_HoriHeader *pHori; TT_HoriHeader *pHori;
TT_Postscript *pPost; TT_Postscript *pPost;
FT_Fixed x_scale, y_scale; FT_Fixed x_scale, y_scale;
WCHAR *family_nameW, *style_nameW; WCHAR *family_nameW, *style_nameW, *face_nameW;
static const WCHAR spaceW[] = {' ', '\0'}; static const WCHAR spaceW[] = {' ', '\0'};
char *cp; char *cp;
INT ascent, descent; INT ascent, descent;
...@@ -6578,17 +6554,18 @@ static BOOL get_outline_text_metrics(GdiFont *font) ...@@ -6578,17 +6554,18 @@ static BOOL get_outline_text_metrics(GdiFont *font)
MultiByteToWideChar(CP_ACP, 0, ft_face->style_name, -1, MultiByteToWideChar(CP_ACP, 0, ft_face->style_name, -1,
style_nameW, lensty/sizeof(WCHAR)); style_nameW, lensty/sizeof(WCHAR));
face_nameW = get_face_name( ft_face, TT_NAME_ID_FULL_NAME, TT_MS_LANGID_ENGLISH_UNITED_STATES );
if (!face_nameW)
face_nameW = strdupW(font->name);
lenface = (strlenW(face_nameW) + 1) * sizeof(WCHAR);
/* These names should be read from the TT name table */ /* These names should be read from the TT name table */
/* length of otmpFamilyName */ /* length of otmpFamilyName */
needed += lenfam; needed += lenfam;
/* length of otmpFaceName */ /* length of otmpFaceName */
if ((ft_face->style_flags & (FT_STYLE_FLAG_ITALIC | FT_STYLE_FLAG_BOLD)) == 0) { needed += lenface;
needed += lenfam; /* just the family name */
} else {
needed += lenfam + lensty; /* family + " " + style */
}
/* length of otmpStyleName */ /* length of otmpStyleName */
needed += lensty; needed += lensty;
...@@ -6837,13 +6814,8 @@ static BOOL get_outline_text_metrics(GdiFont *font) ...@@ -6837,13 +6814,8 @@ static BOOL get_outline_text_metrics(GdiFont *font)
strcpyW((WCHAR*)cp, style_nameW); strcpyW((WCHAR*)cp, style_nameW);
cp += lensty; cp += lensty;
font->potm->otmpFaceName = (LPSTR)(cp - (char*)font->potm); font->potm->otmpFaceName = (LPSTR)(cp - (char*)font->potm);
strcpyW((WCHAR*)cp, family_nameW); strcpyW((WCHAR*)cp, face_nameW);
if (ft_face->style_flags & (FT_STYLE_FLAG_ITALIC | FT_STYLE_FLAG_BOLD)) { cp += lenface;
strcatW((WCHAR*)cp, spaceW);
strcatW((WCHAR*)cp, style_nameW);
cp += lenfam + lensty;
} else
cp += lenfam;
font->potm->otmpFullName = (LPSTR)(cp - (char*)font->potm); font->potm->otmpFullName = (LPSTR)(cp - (char*)font->potm);
strcpyW((WCHAR*)cp, family_nameW); strcpyW((WCHAR*)cp, family_nameW);
strcatW((WCHAR*)cp, spaceW); strcatW((WCHAR*)cp, spaceW);
...@@ -6853,6 +6825,7 @@ static BOOL get_outline_text_metrics(GdiFont *font) ...@@ -6853,6 +6825,7 @@ static BOOL get_outline_text_metrics(GdiFont *font)
end: end:
HeapFree(GetProcessHeap(), 0, style_nameW); HeapFree(GetProcessHeap(), 0, style_nameW);
HeapFree(GetProcessHeap(), 0, family_nameW); HeapFree(GetProcessHeap(), 0, family_nameW);
HeapFree(GetProcessHeap(), 0, face_nameW);
return ret; return ret;
} }
......
...@@ -4125,9 +4125,6 @@ static void test_fullname2_helper(const char *Family) ...@@ -4125,9 +4125,6 @@ static void test_fullname2_helper(const char *Family)
WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE); WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE);
ok(!lstrcmpA(FaceName, bufA), "font face names don't match: returned %s, expect %s\n", FaceName, bufA); ok(!lstrcmpA(FaceName, bufA), "font face names don't match: returned %s, expect %s\n", FaceName, bufA);
otmStr = (LPSTR)otm + (UINT_PTR)otm->otmpFaceName; otmStr = (LPSTR)otm + (UINT_PTR)otm->otmpFaceName;
if(!lstrcmpA(FaceName, "Lucida Sans Regular"))
todo_wine ok(!lstrcmpA(FaceName, otmStr), "FaceName %s doesn't match otmpFaceName %s\n", FaceName, otmStr);
else
ok(!lstrcmpA(FaceName, otmStr), "FaceName %s doesn't match otmpFaceName %s\n", FaceName, otmStr); ok(!lstrcmpA(FaceName, otmStr), "FaceName %s doesn't match otmpFaceName %s\n", FaceName, otmStr);
bufW[0] = 0; bufW[0] = 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