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

dwrite: Added a helper to check for supported characters.

parent fb5079d8
...@@ -1192,7 +1192,7 @@ static BOOL WINAPI dwritefontface3_HasCharacter(IDWriteFontFace4 *iface, UINT32 ...@@ -1192,7 +1192,7 @@ static BOOL WINAPI dwritefontface3_HasCharacter(IDWriteFontFace4 *iface, UINT32
struct dwrite_fontface *This = impl_from_IDWriteFontFace4(iface); struct dwrite_fontface *This = impl_from_IDWriteFontFace4(iface);
UINT16 index; UINT16 index;
TRACE("(%p)->(0x%08x)\n", This, ch); TRACE("(%p)->(%#x)\n", This, ch);
index = 0; index = 0;
if (FAILED(fontface_get_glyphs(This, &ch, 1, &index))) if (FAILED(fontface_get_glyphs(This, &ch, 1, &index)))
...@@ -1566,31 +1566,37 @@ static void WINAPI dwritefont_GetMetrics(IDWriteFont3 *iface, DWRITE_FONT_METRIC ...@@ -1566,31 +1566,37 @@ static void WINAPI dwritefont_GetMetrics(IDWriteFont3 *iface, DWRITE_FONT_METRIC
memcpy(metrics, &This->data->metrics, sizeof(*metrics)); memcpy(metrics, &This->data->metrics, sizeof(*metrics));
} }
static HRESULT WINAPI dwritefont_HasCharacter(IDWriteFont3 *iface, UINT32 value, BOOL *exists) static HRESULT font_has_character(struct dwrite_font *font, UINT32 ch, BOOL *exists)
{ {
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
IDWriteFontFace4 *fontface; IDWriteFontFace4 *fontface;
UINT16 index; UINT16 index;
HRESULT hr; HRESULT hr;
TRACE("(%p)->(0x%08x %p)\n", This, value, exists);
*exists = FALSE; *exists = FALSE;
hr = get_fontface_from_font(This, &fontface); hr = get_fontface_from_font(font, &fontface);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
index = 0; index = 0;
hr = IDWriteFontFace4_GetGlyphIndices(fontface, &value, 1, &index); hr = IDWriteFontFace4_GetGlyphIndices(fontface, &ch, 1, &index);
IDWriteFontFace4_Release(fontface);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
IDWriteFontFace4_Release(fontface);
*exists = index != 0; *exists = index != 0;
return S_OK; return S_OK;
} }
static HRESULT WINAPI dwritefont_HasCharacter(IDWriteFont3 *iface, UINT32 ch, BOOL *exists)
{
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
TRACE("(%p)->(%#x %p)\n", This, ch, exists);
return font_has_character(This, ch, exists);
}
static HRESULT WINAPI dwritefont_CreateFontFace(IDWriteFont3 *iface, IDWriteFontFace **fontface) static HRESULT WINAPI dwritefont_CreateFontFace(IDWriteFont3 *iface, IDWriteFontFace **fontface)
{ {
struct dwrite_font *This = impl_from_IDWriteFont3(iface); struct dwrite_font *This = impl_from_IDWriteFont3(iface);
...@@ -1694,13 +1700,11 @@ static HRESULT WINAPI dwritefont3_GetFontFaceReference(IDWriteFont3 *iface, IDWr ...@@ -1694,13 +1700,11 @@ static HRESULT WINAPI dwritefont3_GetFontFaceReference(IDWriteFont3 *iface, IDWr
static BOOL WINAPI dwritefont3_HasCharacter(IDWriteFont3 *iface, UINT32 ch) static BOOL WINAPI dwritefont3_HasCharacter(IDWriteFont3 *iface, UINT32 ch)
{ {
struct dwrite_font *This = impl_from_IDWriteFont3(iface); struct dwrite_font *This = impl_from_IDWriteFont3(iface);
HRESULT hr;
BOOL ret; BOOL ret;
TRACE("(%p)->(0x%x)\n", This, ch); TRACE("(%p)->(%#x)\n", This, ch);
hr = IDWriteFont_HasCharacter((IDWriteFont*)iface, ch, &ret); return font_has_character(This, ch, &ret) == S_OK && ret;
return hr == S_OK && ret;
} }
static DWRITE_LOCALITY WINAPI dwritefont3_GetLocality(IDWriteFont3 *iface) static DWRITE_LOCALITY WINAPI dwritefont3_GetLocality(IDWriteFont3 *iface)
......
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