dwrite: Implement IDWriteFont::Equals().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0a5747bfa1
commit
4d3e0ba0a5
|
@ -295,6 +295,8 @@ static inline struct dwrite_font *impl_from_IDWriteFont3(IDWriteFont3 *iface)
|
|||
return CONTAINING_RECORD(iface, struct dwrite_font, IDWriteFont3_iface);
|
||||
}
|
||||
|
||||
static struct dwrite_font *unsafe_impl_from_IDWriteFont(IDWriteFont *iface);
|
||||
|
||||
static inline struct dwrite_fontfile *impl_from_IDWriteFontFile(IDWriteFontFile *iface)
|
||||
{
|
||||
return CONTAINING_RECORD(iface, struct dwrite_fontfile, IDWriteFontFile_iface);
|
||||
|
@ -467,6 +469,29 @@ void fontface_detach_from_cache(IDWriteFontFace5 *iface)
|
|||
fontface->cached = NULL;
|
||||
}
|
||||
|
||||
static BOOL is_same_fontfile(IDWriteFontFile *left, IDWriteFontFile *right)
|
||||
{
|
||||
UINT32 left_key_size, right_key_size;
|
||||
const void *left_key, *right_key;
|
||||
HRESULT hr;
|
||||
|
||||
if (left == right)
|
||||
return TRUE;
|
||||
|
||||
hr = IDWriteFontFile_GetReferenceKey(left, &left_key, &left_key_size);
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
|
||||
hr = IDWriteFontFile_GetReferenceKey(right, &right_key, &right_key_size);
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
|
||||
if (left_key_size != right_key_size)
|
||||
return FALSE;
|
||||
|
||||
return !memcmp(left_key, right_key, left_key_size);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI dwritefontface_QueryInterface(IDWriteFontFace5 *iface, REFIID riid, void **obj)
|
||||
{
|
||||
struct dwrite_fontface *fontface = impl_from_IDWriteFontFace5(iface);
|
||||
|
@ -1814,11 +1839,18 @@ static HRESULT WINAPI dwritefont3_CreateFontFace(IDWriteFont3 *iface, IDWriteFon
|
|||
return get_fontface_from_font(font, (IDWriteFontFace5 **)fontface);
|
||||
}
|
||||
|
||||
static BOOL WINAPI dwritefont3_Equals(IDWriteFont3 *iface, IDWriteFont *font)
|
||||
static BOOL WINAPI dwritefont3_Equals(IDWriteFont3 *iface, IDWriteFont *other)
|
||||
{
|
||||
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
|
||||
FIXME("(%p)->(%p): stub\n", This, font);
|
||||
return FALSE;
|
||||
struct dwrite_font *font = impl_from_IDWriteFont3(iface), *other_font;
|
||||
|
||||
TRACE("%p, %p.\n", iface, other);
|
||||
|
||||
if (!(other_font = unsafe_impl_from_IDWriteFont(other)))
|
||||
return FALSE;
|
||||
|
||||
return font->data->face_index == other_font->data->face_index
|
||||
&& font->data->simulations == other_font->data->simulations
|
||||
&& is_same_fontfile(font->data->file, other_font->data->file);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI dwritefont3_GetFontFaceReference(IDWriteFont3 *iface, IDWriteFontFaceReference **reference)
|
||||
|
@ -2687,29 +2719,6 @@ static HRESULT WINAPI dwritefontcollection_FindFamilyName(IDWriteFontCollection3
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
static BOOL is_same_fontfile(IDWriteFontFile *left, IDWriteFontFile *right)
|
||||
{
|
||||
UINT32 left_key_size, right_key_size;
|
||||
const void *left_key, *right_key;
|
||||
HRESULT hr;
|
||||
|
||||
if (left == right)
|
||||
return TRUE;
|
||||
|
||||
hr = IDWriteFontFile_GetReferenceKey(left, &left_key, &left_key_size);
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
|
||||
hr = IDWriteFontFile_GetReferenceKey(right, &right_key, &right_key_size);
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
|
||||
if (left_key_size != right_key_size)
|
||||
return FALSE;
|
||||
|
||||
return !memcmp(left_key, right_key, left_key_size);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI dwritefontcollection_GetFontFromFontFace(IDWriteFontCollection3 *iface, IDWriteFontFace *face,
|
||||
IDWriteFont **font)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue