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

dwrite: Update to IDWriteFont3.

parent 27ca16c7
......@@ -138,7 +138,7 @@ struct dwrite_fontfamily {
};
struct dwrite_font {
IDWriteFont2 IDWriteFont2_iface;
IDWriteFont3 IDWriteFont3_iface;
LONG ref;
IDWriteFontFamily *family;
......@@ -248,9 +248,9 @@ static inline struct dwrite_fontface *impl_from_IDWriteFontFace3(IDWriteFontFace
return CONTAINING_RECORD(iface, struct dwrite_fontface, IDWriteFontFace3_iface);
}
static inline struct dwrite_font *impl_from_IDWriteFont2(IDWriteFont2 *iface)
static inline struct dwrite_font *impl_from_IDWriteFont3(IDWriteFont3 *iface)
{
return CONTAINING_RECORD(iface, struct dwrite_font, IDWriteFont2_iface);
return CONTAINING_RECORD(iface, struct dwrite_font, IDWriteFont3_iface);
}
static inline struct dwrite_fontfile *impl_from_IDWriteFontFile(IDWriteFontFile *iface)
......@@ -1223,9 +1223,9 @@ static HRESULT get_fontface_from_font(struct dwrite_font *font, IDWriteFontFace3
return hr;
}
static HRESULT WINAPI dwritefont_QueryInterface(IDWriteFont2 *iface, REFIID riid, void **obj)
static HRESULT WINAPI dwritefont_QueryInterface(IDWriteFont3 *iface, REFIID riid, void **obj)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
......@@ -1235,7 +1235,7 @@ static HRESULT WINAPI dwritefont_QueryInterface(IDWriteFont2 *iface, REFIID riid
IsEqualIID(riid, &IID_IUnknown))
{
*obj = iface;
IDWriteFont2_AddRef(iface);
IDWriteFont3_AddRef(iface);
return S_OK;
}
......@@ -1243,17 +1243,17 @@ static HRESULT WINAPI dwritefont_QueryInterface(IDWriteFont2 *iface, REFIID riid
return E_NOINTERFACE;
}
static ULONG WINAPI dwritefont_AddRef(IDWriteFont2 *iface)
static ULONG WINAPI dwritefont_AddRef(IDWriteFont3 *iface)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
ULONG ref = InterlockedIncrement(&This->ref);
TRACE("(%p)->(%d)\n", This, ref);
return ref;
}
static ULONG WINAPI dwritefont_Release(IDWriteFont2 *iface)
static ULONG WINAPI dwritefont_Release(IDWriteFont3 *iface)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->(%d)\n", This, ref);
......@@ -1267,9 +1267,9 @@ static ULONG WINAPI dwritefont_Release(IDWriteFont2 *iface)
return ref;
}
static HRESULT WINAPI dwritefont_GetFontFamily(IDWriteFont2 *iface, IDWriteFontFamily **family)
static HRESULT WINAPI dwritefont_GetFontFamily(IDWriteFont3 *iface, IDWriteFontFamily **family)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
TRACE("(%p)->(%p)\n", This, family);
*family = This->family;
......@@ -1277,30 +1277,30 @@ static HRESULT WINAPI dwritefont_GetFontFamily(IDWriteFont2 *iface, IDWriteFontF
return S_OK;
}
static DWRITE_FONT_WEIGHT WINAPI dwritefont_GetWeight(IDWriteFont2 *iface)
static DWRITE_FONT_WEIGHT WINAPI dwritefont_GetWeight(IDWriteFont3 *iface)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
TRACE("(%p)\n", This);
return This->data->weight;
}
static DWRITE_FONT_STRETCH WINAPI dwritefont_GetStretch(IDWriteFont2 *iface)
static DWRITE_FONT_STRETCH WINAPI dwritefont_GetStretch(IDWriteFont3 *iface)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
TRACE("(%p)\n", This);
return This->data->stretch;
}
static DWRITE_FONT_STYLE WINAPI dwritefont_GetStyle(IDWriteFont2 *iface)
static DWRITE_FONT_STYLE WINAPI dwritefont_GetStyle(IDWriteFont3 *iface)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
TRACE("(%p)\n", This);
return This->style;
}
static BOOL WINAPI dwritefont_IsSymbolFont(IDWriteFont2 *iface)
static BOOL WINAPI dwritefont_IsSymbolFont(IDWriteFont3 *iface)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
IDWriteFontFace3 *fontface;
HRESULT hr;
......@@ -1313,17 +1313,17 @@ static BOOL WINAPI dwritefont_IsSymbolFont(IDWriteFont2 *iface)
return IDWriteFontFace3_IsSymbolFont(fontface);
}
static HRESULT WINAPI dwritefont_GetFaceNames(IDWriteFont2 *iface, IDWriteLocalizedStrings **names)
static HRESULT WINAPI dwritefont_GetFaceNames(IDWriteFont3 *iface, IDWriteLocalizedStrings **names)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
TRACE("(%p)->(%p)\n", This, names);
return clone_localizedstring(This->data->names, names);
}
static HRESULT WINAPI dwritefont_GetInformationalStrings(IDWriteFont2 *iface,
static HRESULT WINAPI dwritefont_GetInformationalStrings(IDWriteFont3 *iface,
DWRITE_INFORMATIONAL_STRING_ID stringid, IDWriteLocalizedStrings **strings, BOOL *exists)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
struct dwrite_font_data *data = This->data;
HRESULT hr;
......@@ -1367,24 +1367,24 @@ static HRESULT WINAPI dwritefont_GetInformationalStrings(IDWriteFont2 *iface,
return S_OK;
}
static DWRITE_FONT_SIMULATIONS WINAPI dwritefont_GetSimulations(IDWriteFont2 *iface)
static DWRITE_FONT_SIMULATIONS WINAPI dwritefont_GetSimulations(IDWriteFont3 *iface)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
TRACE("(%p)\n", This);
return This->data->simulations;
}
static void WINAPI dwritefont_GetMetrics(IDWriteFont2 *iface, DWRITE_FONT_METRICS *metrics)
static void WINAPI dwritefont_GetMetrics(IDWriteFont3 *iface, DWRITE_FONT_METRICS *metrics)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
TRACE("(%p)->(%p)\n", This, metrics);
memcpy(metrics, &This->data->metrics, sizeof(*metrics));
}
static HRESULT WINAPI dwritefont_HasCharacter(IDWriteFont2 *iface, UINT32 value, BOOL *exists)
static HRESULT WINAPI dwritefont_HasCharacter(IDWriteFont3 *iface, UINT32 value, BOOL *exists)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
IDWriteFontFace3 *fontface;
UINT16 index;
HRESULT hr;
......@@ -1406,9 +1406,9 @@ static HRESULT WINAPI dwritefont_HasCharacter(IDWriteFont2 *iface, UINT32 value,
return S_OK;
}
static HRESULT WINAPI dwritefont_CreateFontFace(IDWriteFont2 *iface, IDWriteFontFace **face)
static HRESULT WINAPI dwritefont_CreateFontFace(IDWriteFont3 *iface, IDWriteFontFace **face)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
HRESULT hr;
TRACE("(%p)->(%p)\n", This, face);
......@@ -1420,23 +1420,23 @@ static HRESULT WINAPI dwritefont_CreateFontFace(IDWriteFont2 *iface, IDWriteFont
return hr;
}
static void WINAPI dwritefont1_GetMetrics(IDWriteFont2 *iface, DWRITE_FONT_METRICS1 *metrics)
static void WINAPI dwritefont1_GetMetrics(IDWriteFont3 *iface, DWRITE_FONT_METRICS1 *metrics)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
TRACE("(%p)->(%p)\n", This, metrics);
*metrics = This->data->metrics;
}
static void WINAPI dwritefont1_GetPanose(IDWriteFont2 *iface, DWRITE_PANOSE *panose)
static void WINAPI dwritefont1_GetPanose(IDWriteFont3 *iface, DWRITE_PANOSE *panose)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
TRACE("(%p)->(%p)\n", This, panose);
*panose = This->data->panose;
}
static HRESULT WINAPI dwritefont1_GetUnicodeRanges(IDWriteFont2 *iface, UINT32 max_count, DWRITE_UNICODE_RANGE *ranges, UINT32 *count)
static HRESULT WINAPI dwritefont1_GetUnicodeRanges(IDWriteFont3 *iface, UINT32 max_count, DWRITE_UNICODE_RANGE *ranges, UINT32 *count)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
IDWriteFontFace3 *fontface;
HRESULT hr;
......@@ -1449,9 +1449,9 @@ static HRESULT WINAPI dwritefont1_GetUnicodeRanges(IDWriteFont2 *iface, UINT32 m
return IDWriteFontFace3_GetUnicodeRanges(fontface, max_count, ranges, count);
}
static BOOL WINAPI dwritefont1_IsMonospacedFont(IDWriteFont2 *iface)
static BOOL WINAPI dwritefont1_IsMonospacedFont(IDWriteFont3 *iface)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
IDWriteFontFace3 *fontface;
HRESULT hr;
......@@ -1464,9 +1464,9 @@ static BOOL WINAPI dwritefont1_IsMonospacedFont(IDWriteFont2 *iface)
return IDWriteFontFace3_IsMonospacedFont(fontface);
}
static BOOL WINAPI dwritefont2_IsColorFont(IDWriteFont2 *iface)
static BOOL WINAPI dwritefont2_IsColorFont(IDWriteFont3 *iface)
{
struct dwrite_font *This = impl_from_IDWriteFont2(iface);
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
IDWriteFontFace3 *fontface;
HRESULT hr;
......@@ -1479,7 +1479,42 @@ static BOOL WINAPI dwritefont2_IsColorFont(IDWriteFont2 *iface)
return IDWriteFontFace3_IsColorFont(fontface);
}
static const IDWriteFont2Vtbl dwritefontvtbl = {
static HRESULT WINAPI dwritefont3_CreateFontFace(IDWriteFont3 *iface, IDWriteFontFace3 **fontface)
{
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
FIXME("(%p)->(%p): stub\n", This, fontface);
return E_NOTIMPL;
}
static BOOL WINAPI dwritefont3_Equals(IDWriteFont3 *iface, IDWriteFont *font)
{
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
FIXME("(%p)->(%p): stub\n", This, font);
return FALSE;
}
static HRESULT WINAPI dwritefont3_GetFontFaceReference(IDWriteFont3 *iface, IDWriteFontFaceReference **reference)
{
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
FIXME("(%p)->(%p): stub\n", This, reference);
return E_NOTIMPL;
}
static BOOL WINAPI dwritefont3_HasCharacter(IDWriteFont3 *iface, UINT32 ch)
{
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
FIXME("(%p)->(0x%x): stub\n", This, ch);
return FALSE;
}
static DWRITE_LOCALITY WINAPI dwritefont3_GetLocality(IDWriteFont3 *iface)
{
struct dwrite_font *This = impl_from_IDWriteFont3(iface);
FIXME("(%p): stub\n", This);
return DWRITE_LOCALITY_LOCAL;
}
static const IDWriteFont3Vtbl dwritefontvtbl = {
dwritefont_QueryInterface,
dwritefont_AddRef,
dwritefont_Release,
......@@ -1498,7 +1533,12 @@ static const IDWriteFont2Vtbl dwritefontvtbl = {
dwritefont1_GetPanose,
dwritefont1_GetUnicodeRanges,
dwritefont1_IsMonospacedFont,
dwritefont2_IsColorFont
dwritefont2_IsColorFont,
dwritefont3_CreateFontFace,
dwritefont3_Equals,
dwritefont3_GetFontFaceReference,
dwritefont3_HasCharacter,
dwritefont3_GetLocality
};
static HRESULT create_font(struct dwrite_font_data *data, IDWriteFontFamily *family, IDWriteFont **font)
......@@ -1509,7 +1549,7 @@ static HRESULT create_font(struct dwrite_font_data *data, IDWriteFontFamily *fam
This = heap_alloc(sizeof(struct dwrite_font));
if (!This) return E_OUTOFMEMORY;
This->IDWriteFont2_iface.lpVtbl = &dwritefontvtbl;
This->IDWriteFont3_iface.lpVtbl = &dwritefontvtbl;
This->ref = 1;
This->family = family;
IDWriteFontFamily_AddRef(family);
......@@ -1517,7 +1557,7 @@ static HRESULT create_font(struct dwrite_font_data *data, IDWriteFontFamily *fam
This->data = data;
InterlockedIncrement(&This->data->ref);
*font = (IDWriteFont*)&This->IDWriteFont2_iface;
*font = (IDWriteFont*)&This->IDWriteFont3_iface;
return S_OK;
}
......
......@@ -26,7 +26,7 @@
#include "windows.h"
#include "winternl.h"
#include "dwrite_2.h"
#include "dwrite_3.h"
#include "initguid.h"
#include "d2d1.h"
......@@ -2415,8 +2415,6 @@ static void test_GetFontFromFontFace(void)
DELETE_FONTFILE(path);
}
static void test_GetFirstMatchingFont(void)
{
DWRITE_FONT_SIMULATIONS simulations;
......@@ -5268,6 +5266,39 @@ static void test_TranslateColorGlyphRun(void)
IDWriteFactory2_Release(factory2);
}
static void test_HasCharacter(void)
{
IDWriteFactory3 *factory3;
IDWriteFactory *factory;
IDWriteFont3 *font3;
IDWriteFont *font;
HRESULT hr;
BOOL ret;
factory = create_factory();
font = get_tahoma_instance(factory, DWRITE_FONT_STYLE_NORMAL);
ok(font != NULL, "failed to create font\n");
/* Win8 is broken, QI claims to support IDWriteFont3, but in fact it does not */
hr = IDWriteFactory_QueryInterface(factory, &IID_IDWriteFactory3, (void**)&factory3);
if (hr == S_OK) {
hr = IDWriteFont_QueryInterface(font, &IID_IDWriteFont3, (void**)&font3);
ok(hr == S_OK, "got 0x%08x\n", hr);
ret = IDWriteFont3_HasCharacter(font3, 'A');
ok(ret, "got %d\n", ret);
IDWriteFont3_Release(font3);
IDWriteFactory3_Release(factory3);
}
else
skip("IDWriteFont3 is not supported.\n");
IDWriteFont_Release(font);
IDWriteFactory_Release(factory);
}
START_TEST(font)
{
IDWriteFactory *factory;
......@@ -5320,6 +5351,7 @@ START_TEST(font)
test_IsSymbolFont();
test_GetPaletteEntries();
test_TranslateColorGlyphRun();
test_HasCharacter();
IDWriteFactory_Release(factory);
}
......@@ -252,3 +252,12 @@ interface IDWriteTextLayout3 : IDWriteTextLayout2
HRESULT GetLineSpacing(DWRITE_LINE_SPACING *spacing);
HRESULT GetLineMetrics(DWRITE_LINE_METRICS1 *metrics, UINT32 max_count, UINT32 *count);
}
[
local,
object,
uuid(9a1b41c3-d3bb-466a-87fc-fe67556a3b65)
]
interface IDWriteFactory3 : IDWriteFactory2
{
}
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