Commit 5a318c3e authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Set facename field of a LOGFONT in ConvertFontFaceToLOGFONT().

parent 5196be77
...@@ -121,6 +121,7 @@ extern BOOL is_system_collection(IDWriteFontCollection*) DECLSPEC_HIDDEN; ...@@ -121,6 +121,7 @@ extern BOOL is_system_collection(IDWriteFontCollection*) DECLSPEC_HIDDEN;
extern HRESULT get_local_refkey(const WCHAR*,const FILETIME*,void**,UINT32*) DECLSPEC_HIDDEN; extern HRESULT get_local_refkey(const WCHAR*,const FILETIME*,void**,UINT32*) DECLSPEC_HIDDEN;
extern HRESULT get_filestream_from_file(IDWriteFontFile*,IDWriteFontFileStream**) DECLSPEC_HIDDEN; extern HRESULT get_filestream_from_file(IDWriteFontFile*,IDWriteFontFileStream**) DECLSPEC_HIDDEN;
extern BOOL is_face_type_supported(DWRITE_FONT_FACE_TYPE) DECLSPEC_HIDDEN; extern BOOL is_face_type_supported(DWRITE_FONT_FACE_TYPE) DECLSPEC_HIDDEN;
extern HRESULT get_family_names_from_stream(IDWriteFontFileStream*,UINT32,DWRITE_FONT_FACE_TYPE,IDWriteLocalizedStrings**) DECLSPEC_HIDDEN;
/* Opentype font table functions */ /* Opentype font table functions */
extern HRESULT opentype_analyze_font(IDWriteFontFileStream*,UINT32*,DWRITE_FONT_FILE_TYPE*,DWRITE_FONT_FACE_TYPE*,BOOL*) DECLSPEC_HIDDEN; extern HRESULT opentype_analyze_font(IDWriteFontFileStream*,UINT32*,DWRITE_FONT_FILE_TYPE*,DWRITE_FONT_FACE_TYPE*,BOOL*) DECLSPEC_HIDDEN;
......
...@@ -773,45 +773,22 @@ static const IDWriteFontFace2Vtbl dwritefontfacevtbl = { ...@@ -773,45 +773,22 @@ static const IDWriteFontFace2Vtbl dwritefontfacevtbl = {
dwritefontface2_GetRecommendedRenderingMode dwritefontface2_GetRecommendedRenderingMode
}; };
HRESULT convert_fontface_to_logfont(IDWriteFontFace *face, LOGFONTW *logfont) HRESULT get_family_names_from_stream(IDWriteFontFileStream *stream, UINT32 index, DWRITE_FONT_FACE_TYPE facetype,
IDWriteLocalizedStrings **names)
{ {
DWRITE_FONT_SIMULATIONS simulations; const void *name_table = NULL;
DWRITE_FONT_FACE_TYPE face_type; void *name_context;
IDWriteFontFileStream *stream; HRESULT hr = S_OK;
DWRITE_FONT_STRETCH stretch;
DWRITE_FONT_STYLE style;
DWRITE_FONT_WEIGHT weight;
IDWriteFontFile *file = NULL;
UINT32 index;
HRESULT hr;
memset(logfont, 0, sizeof(*logfont));
index = 1;
hr = IDWriteFontFace_GetFiles(face, &index, &file);
if (FAILED(hr) || !file)
return hr;
hr = get_filestream_from_file(file, &stream); opentype_get_font_table(stream, facetype, index, MS_NAME_TAG, &name_table, &name_context, NULL, NULL);
if (FAILED(hr)) { if (name_table) {
IDWriteFontFile_Release(file); hr = opentype_get_font_strings_from_id(name_table, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, names);
return hr; IDWriteFontFileStream_ReleaseFileFragment(stream, name_context);
} }
else
names = NULL;
index = IDWriteFontFace_GetIndex(face); return hr;
face_type = IDWriteFontFace_GetType(face);
opentype_get_font_properties(stream, face_type, index, &stretch, &weight, &style);
IDWriteFontFileStream_Release(stream);
simulations = IDWriteFontFace_GetSimulations(face);
logfont->lfCharSet = DEFAULT_CHARSET;
logfont->lfWeight = weight;
logfont->lfItalic = style == DWRITE_FONT_STYLE_ITALIC || (simulations & DWRITE_FONT_SIMULATIONS_OBLIQUE);
logfont->lfOutPrecision = OUT_OUTLINE_PRECIS;
/* TODO: set facename */
return S_OK;
} }
static HRESULT get_fontface_from_font(struct dwrite_font *font, IDWriteFontFace2 **fontface) static HRESULT get_fontface_from_font(struct dwrite_font *font, IDWriteFontFace2 **fontface)
...@@ -1730,8 +1707,6 @@ HRESULT create_font_collection(IDWriteFactory2* factory, IDWriteFontFileEnumerat ...@@ -1730,8 +1707,6 @@ HRESULT create_font_collection(IDWriteFactory2* factory, IDWriteFontFileEnumerat
for (i = 0; i < face_count; i++) { for (i = 0; i < face_count; i++) {
IDWriteLocalizedStrings *family_name = NULL; IDWriteLocalizedStrings *family_name = NULL;
struct dwrite_font_data *font_data; struct dwrite_font_data *font_data;
const void *name_table;
void *name_context;
IDWriteFontFileStream *stream; IDWriteFontFileStream *stream;
WCHAR buffer[255]; WCHAR buffer[255];
UINT32 index; UINT32 index;
...@@ -1742,15 +1717,9 @@ HRESULT create_font_collection(IDWriteFactory2* factory, IDWriteFontFileEnumerat ...@@ -1742,15 +1717,9 @@ HRESULT create_font_collection(IDWriteFactory2* factory, IDWriteFontFileEnumerat
break; break;
/* get family name from font file */ /* get family name from font file */
name_table = NULL; hr = get_family_names_from_stream(stream, i, face_type, &family_name);
opentype_get_font_table(stream, face_type, i, MS_NAME_TAG, &name_table, &name_context, NULL, NULL);
if (name_table) {
hr = opentype_get_font_strings_from_id(name_table, DWRITE_INFORMATIONAL_STRING_WIN32_FAMILY_NAMES, &family_name);
IDWriteFontFileStream_ReleaseFileFragment(stream, name_context);
}
IDWriteFontFileStream_Release(stream); IDWriteFontFileStream_Release(stream);
if (FAILED(hr)) {
if (FAILED(hr) || !family_name) {
WARN("unable to get family name from font\n"); WARN("unable to get family name from font\n");
release_font_data(font_data); release_font_data(font_data);
continue; continue;
......
...@@ -406,9 +406,68 @@ static HRESULT WINAPI gdiinterop_ConvertFontToLOGFONT(IDWriteGdiInterop *iface, ...@@ -406,9 +406,68 @@ static HRESULT WINAPI gdiinterop_ConvertFontToLOGFONT(IDWriteGdiInterop *iface,
static HRESULT WINAPI gdiinterop_ConvertFontFaceToLOGFONT(IDWriteGdiInterop *iface, static HRESULT WINAPI gdiinterop_ConvertFontFaceToLOGFONT(IDWriteGdiInterop *iface,
IDWriteFontFace *fontface, LOGFONTW *logfont) IDWriteFontFace *fontface, LOGFONTW *logfont)
{ {
static const WCHAR enusW[] = {'e','n','-','u','s',0};
struct gdiinterop *This = impl_from_IDWriteGdiInterop(iface); struct gdiinterop *This = impl_from_IDWriteGdiInterop(iface);
IDWriteLocalizedStrings *familynames;
DWRITE_FONT_SIMULATIONS simulations;
DWRITE_FONT_FACE_TYPE face_type;
IDWriteFontFileStream *stream;
DWRITE_FONT_STRETCH stretch;
DWRITE_FONT_STYLE style;
DWRITE_FONT_WEIGHT weight;
IDWriteFontFile *file = NULL;
UINT32 index;
BOOL exists;
HRESULT hr;
TRACE("(%p)->(%p %p)\n", This, fontface, logfont); TRACE("(%p)->(%p %p)\n", This, fontface, logfont);
return convert_fontface_to_logfont(fontface, logfont);
memset(logfont, 0, sizeof(*logfont));
index = 1;
hr = IDWriteFontFace_GetFiles(fontface, &index, &file);
if (FAILED(hr) || !file)
return hr;
hr = get_filestream_from_file(file, &stream);
if (FAILED(hr)) {
IDWriteFontFile_Release(file);
return hr;
}
index = IDWriteFontFace_GetIndex(fontface);
face_type = IDWriteFontFace_GetType(fontface);
opentype_get_font_properties(stream, face_type, index, &stretch, &weight, &style);
hr = get_family_names_from_stream(stream, index, face_type, &familynames);
IDWriteFontFile_Release(file);
IDWriteFontFileStream_Release(stream);
if (FAILED(hr))
return hr;
simulations = IDWriteFontFace_GetSimulations(fontface);
logfont->lfCharSet = DEFAULT_CHARSET;
logfont->lfWeight = weight;
logfont->lfItalic = style == DWRITE_FONT_STYLE_ITALIC || (simulations & DWRITE_FONT_SIMULATIONS_OBLIQUE);
logfont->lfOutPrecision = OUT_OUTLINE_PRECIS;
logfont->lfFaceName[0] = 0;
exists = FALSE;
hr = IDWriteLocalizedStrings_FindLocaleName(familynames, enusW, &index, &exists);
if (FAILED(hr) || !exists) {
/* fallback to 0 index */
if (IDWriteLocalizedStrings_GetCount(familynames) > 0)
index = 0;
else {
IDWriteLocalizedStrings_Release(familynames);
return E_FAIL;
}
}
hr = IDWriteLocalizedStrings_GetString(familynames, index, logfont->lfFaceName, sizeof(logfont->lfFaceName)/sizeof(WCHAR));
IDWriteLocalizedStrings_Release(familynames);
return hr;
} }
static HRESULT WINAPI gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop *iface, static HRESULT WINAPI gdiinterop_CreateFontFaceFromHdc(IDWriteGdiInterop *iface,
......
...@@ -1467,7 +1467,6 @@ if (0) /* crashes on native */ ...@@ -1467,7 +1467,6 @@ if (0) /* crashes on native */
ok(logfont.lfItalic == 1, "got %d\n", logfont.lfItalic); ok(logfont.lfItalic == 1, "got %d\n", logfont.lfItalic);
ok(logfont.lfUnderline == 0, "got %d\n", logfont.lfUnderline); ok(logfont.lfUnderline == 0, "got %d\n", logfont.lfUnderline);
ok(logfont.lfStrikeOut == 0, "got %d\n", logfont.lfStrikeOut); ok(logfont.lfStrikeOut == 0, "got %d\n", logfont.lfStrikeOut);
todo_wine
ok(!lstrcmpW(logfont.lfFaceName, tahomaW), "got %s\n", wine_dbgstr_w(logfont.lfFaceName)); ok(!lstrcmpW(logfont.lfFaceName, tahomaW), "got %s\n", wine_dbgstr_w(logfont.lfFaceName));
IDWriteGdiInterop_Release(interop); IDWriteGdiInterop_Release(interop);
......
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