From 733aca30f4976a858d4e7a36628922f1eb898197 Mon Sep 17 00:00:00 2001 From: Qian Hong Date: Fri, 7 Sep 2012 18:40:34 +0800 Subject: [PATCH] gdi32: Read otmpFullName from TT_NAME_ID_UNIQUE_ID. --- dlls/gdi32/freetype.c | 24 +++++++++++++++++------- dlls/gdi32/tests/font.c | 2 +- dlls/wineps.drv/download.c | 4 ++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c index 9d3d4c4633f..feca48a07e5 100644 --- a/dlls/gdi32/freetype.c +++ b/dlls/gdi32/freetype.c @@ -6528,13 +6528,12 @@ static BOOL get_outline_text_metrics(GdiFont *font) { BOOL ret = FALSE; FT_Face ft_face = font->ft_face; - UINT needed, lenfam, lensty, lenface; + UINT needed, lenfam, lensty, lenface, lenfull; TT_OS2 *pOS2; TT_HoriHeader *pHori; TT_Postscript *pPost; FT_Fixed x_scale, y_scale; - WCHAR *family_nameW, *style_nameW, *face_nameW; - static const WCHAR spaceW[] = {' ', '\0'}; + WCHAR *family_nameW, *style_nameW, *face_nameW, *full_nameW; char *cp; INT ascent, descent; @@ -6556,9 +6555,21 @@ static BOOL get_outline_text_metrics(GdiFont *font) face_nameW = get_face_name( ft_face, TT_NAME_ID_FULL_NAME, TT_MS_LANGID_ENGLISH_UNITED_STATES ); if (!face_nameW) + { + FIXME("failed to read face_nameW for font %s!\n", wine_dbgstr_w(font->name)); face_nameW = strdupW(font->name); + } lenface = (strlenW(face_nameW) + 1) * sizeof(WCHAR); + full_nameW = get_face_name( ft_face, TT_NAME_ID_UNIQUE_ID, TT_MS_LANGID_ENGLISH_UNITED_STATES ); + if (!full_nameW) + { + WCHAR fake_nameW[] = {'f','a','k','e',' ','n','a','m','e', 0}; + FIXME("failed to read full_nameW for font %s!\n", wine_dbgstr_w(font->name)); + full_nameW = strdupW(fake_nameW); + } + lenfull = (strlenW(full_nameW) + 1) * sizeof(WCHAR); + /* These names should be read from the TT name table */ /* length of otmpFamilyName */ @@ -6571,7 +6582,7 @@ static BOOL get_outline_text_metrics(GdiFont *font) needed += lensty; /* length of otmpFullName */ - needed += lenfam + lensty; + needed += lenfull; x_scale = ft_face->size->metrics.x_scale; @@ -6817,15 +6828,14 @@ static BOOL get_outline_text_metrics(GdiFont *font) strcpyW((WCHAR*)cp, face_nameW); cp += lenface; font->potm->otmpFullName = (LPSTR)(cp - (char*)font->potm); - strcpyW((WCHAR*)cp, family_nameW); - strcatW((WCHAR*)cp, spaceW); - strcatW((WCHAR*)cp, style_nameW); + strcpyW((WCHAR*)cp, full_nameW); ret = TRUE; end: HeapFree(GetProcessHeap(), 0, style_nameW); HeapFree(GetProcessHeap(), 0, family_nameW); HeapFree(GetProcessHeap(), 0, face_nameW); + HeapFree(GetProcessHeap(), 0, full_nameW); return ret; } diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index 4a1532a3833..10e015efa81 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -4142,7 +4142,7 @@ static void test_fullname2_helper(const char *Family) ok(ret, "UNIQUE_ID (full name) could not be read\n"); WideCharToMultiByte(CP_ACP, 0, bufW, -1, bufA, buf_size, NULL, FALSE); otmStr = (LPSTR)otm + (UINT_PTR)otm->otmpFullName; - todo_wine ok(!lstrcmpA(otmStr, bufA), "UNIQUE ID (full name) doesn't match: returned %s, expect %s\n", otmStr, bufA); + ok(!lstrcmpA(otmStr, bufA), "UNIQUE ID (full name) doesn't match: returned %s, expect %s\n", otmStr, bufA); SelectObject(hdc, of); DeleteObject(hfont); diff --git a/dlls/wineps.drv/download.c b/dlls/wineps.drv/download.c index 6b8717255c7..fbd868c8c44 100644 --- a/dlls/wineps.drv/download.c +++ b/dlls/wineps.drv/download.c @@ -118,9 +118,9 @@ static void get_download_name(PHYSDEV dev, LPOUTLINETEXTMETRICA potm, char **str } } - len = strlen((char*)potm + (ptrdiff_t)potm->otmpFullName) + 1; + len = strlen((char*)potm + (ptrdiff_t)potm->otmpFaceName) + 1; *str = HeapAlloc(GetProcessHeap(),0,len); - strcpy(*str, (char*)potm + (ptrdiff_t)potm->otmpFullName); + strcpy(*str, (char*)potm + (ptrdiff_t)potm->otmpFaceName); p = *str; while((p = strchr(p, ' ')))