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

dwrite: Partially implement GetSystemFontCollection().

parent 3a5dd73b
......@@ -194,7 +194,7 @@ static const struct fallback_mapping fontfallback_neutral_data[] = {
struct dwrite_fontfallback {
IDWriteFontFallback IDWriteFontFallback_iface;
IDWriteFactory3 *factory;
IDWriteFontCollection *systemcollection;
IDWriteFontCollection1 *systemcollection;
const struct fallback_mapping *mappings;
UINT32 count;
};
......@@ -1879,10 +1879,10 @@ static HRESULT fallback_get_fallback_font(struct dwrite_fontfallback *fallback,
}
/* now let's see what fallback can handle */
hr = create_matching_font(fallback->systemcollection, mapping->family, weight, style, stretch, mapped_font);
hr = create_matching_font((IDWriteFontCollection*)fallback->systemcollection, mapping->family, weight, style, stretch, mapped_font);
if (FAILED(hr)) {
WARN("failed to create fallback font %s for range [0x%x,0x%x], 0x%08x\n", debugstr_w(mapping->family),
mapping->range.first, mapping->range.last, hr);
mapping->range.first, mapping->range.last, hr);
return hr;
}
......@@ -1922,7 +1922,7 @@ static HRESULT WINAPI fontfallback_MapCharacters(IDWriteFontFallback *iface, IDW
return S_OK;
if (!basecollection)
basecollection = fallback->systemcollection;
basecollection = (IDWriteFontCollection*)fallback->systemcollection;
hr = get_text_source_ptr(source, position, length, &text, &buff);
if (FAILED(hr))
......@@ -1982,7 +1982,7 @@ HRESULT create_system_fontfallback(IDWriteFactory3 *factory, IDWriteFontFallback
fallback->factory = factory;
fallback->mappings = fontfallback_neutral_data;
fallback->count = sizeof(fontfallback_neutral_data)/sizeof(fontfallback_neutral_data[0]);
IDWriteFactory2_GetSystemFontCollection((IDWriteFactory2*)fallback->factory, &fallback->systemcollection, FALSE);
IDWriteFactory3_GetSystemFontCollection(fallback->factory, FALSE, &fallback->systemcollection, FALSE);
*ret = &fallback->IDWriteFontFallback_iface;
return S_OK;
......@@ -1991,6 +1991,6 @@ HRESULT create_system_fontfallback(IDWriteFactory3 *factory, IDWriteFontFallback
void release_system_fontfallback(IDWriteFontFallback *iface)
{
struct dwrite_fontfallback *fallback = impl_from_IDWriteFontFallback(iface);
IDWriteFontCollection_Release(fallback->systemcollection);
IDWriteFontCollection1_Release(fallback->systemcollection);
heap_free(fallback);
}
......@@ -175,13 +175,13 @@ extern HRESULT create_localizedstrings(IDWriteLocalizedStrings**) DECLSPEC_HIDDE
extern HRESULT add_localizedstring(IDWriteLocalizedStrings*,const WCHAR*,const WCHAR*) DECLSPEC_HIDDEN;
extern HRESULT clone_localizedstring(IDWriteLocalizedStrings *iface, IDWriteLocalizedStrings **strings) DECLSPEC_HIDDEN;
extern void set_en_localizedstring(IDWriteLocalizedStrings*,const WCHAR*) DECLSPEC_HIDDEN;
extern HRESULT get_system_fontcollection(IDWriteFactory3*,IDWriteFontCollection**) DECLSPEC_HIDDEN;
extern HRESULT get_system_fontcollection(IDWriteFactory3*,IDWriteFontCollection1**) DECLSPEC_HIDDEN;
extern HRESULT get_eudc_fontcollection(IDWriteFactory3*,IDWriteFontCollection**) DECLSPEC_HIDDEN;
extern HRESULT get_textanalyzer(IDWriteTextAnalyzer**) DECLSPEC_HIDDEN;
extern HRESULT create_font_file(IDWriteFontFileLoader *loader, const void *reference_key, UINT32 key_size, IDWriteFontFile **font_file) DECLSPEC_HIDDEN;
extern HRESULT create_localfontfileloader(IDWriteLocalFontFileLoader** iface) DECLSPEC_HIDDEN;
extern HRESULT create_fontface(const struct fontface_desc*,IDWriteFontFace3**) DECLSPEC_HIDDEN;
extern HRESULT create_font_collection(IDWriteFactory3*,IDWriteFontFileEnumerator*,BOOL,IDWriteFontCollection**) DECLSPEC_HIDDEN;
extern HRESULT create_font_collection(IDWriteFactory3*,IDWriteFontFileEnumerator*,BOOL,IDWriteFontCollection1**) DECLSPEC_HIDDEN;
extern HRESULT create_glyphrunanalysis(const struct glyphrunanalysis_desc*,IDWriteGlyphRunAnalysis**) DECLSPEC_HIDDEN;
extern BOOL is_system_collection(IDWriteFontCollection*) DECLSPEC_HIDDEN;
extern HRESULT get_local_refkey(const WCHAR*,const FILETIME*,void**,UINT32*) DECLSPEC_HIDDEN;
......
......@@ -3497,7 +3497,8 @@ static void fontcollection_add_replacements(struct dwrite_fontcollection *collec
RegCloseKey(hkey);
}
HRESULT create_font_collection(IDWriteFactory3 *factory, IDWriteFontFileEnumerator *enumerator, BOOL is_system, IDWriteFontCollection **ret)
HRESULT create_font_collection(IDWriteFactory3 *factory, IDWriteFontFileEnumerator *enumerator, BOOL is_system,
IDWriteFontCollection1 **ret)
{
struct fontfile_enum {
struct list entry;
......@@ -3521,7 +3522,7 @@ HRESULT create_font_collection(IDWriteFactory3 *factory, IDWriteFontFileEnumerat
return hr;
}
*ret = (IDWriteFontCollection*)&collection->IDWriteFontCollection1_iface;
*ret = &collection->IDWriteFontCollection1_iface;
TRACE("building font collection:\n");
......@@ -3820,7 +3821,7 @@ static HRESULT create_system_fontfile_enumerator(IDWriteFactory3 *factory, IDWri
return S_OK;
}
HRESULT get_system_fontcollection(IDWriteFactory3 *factory, IDWriteFontCollection **collection)
HRESULT get_system_fontcollection(IDWriteFactory3 *factory, IDWriteFontCollection1 **collection)
{
IDWriteFontFileEnumerator *enumerator;
HRESULT hr;
......
......@@ -852,7 +852,7 @@ static HRESULT WINAPI gdiinterop1_CreateFontFromLOGFONT(IDWriteGdiInterop1 *ifac
if (collection)
IDWriteFontCollection_AddRef(collection);
else {
hr = IDWriteFactory2_GetSystemFontCollection((IDWriteFactory2*)This->factory, &collection, FALSE);
hr = IDWriteFactory3_GetSystemFontCollection(This->factory, FALSE, (IDWriteFontCollection1**)&collection, FALSE);
if (FAILED(hr)) {
ERR("failed to get system font collection: 0x%08x.\n", hr);
return hr;
......
......@@ -804,7 +804,7 @@ static HRESULT layout_compute_runs(struct dwrite_textlayout *layout)
IDWriteFontCollection_AddRef(collection);
}
else
IDWriteFactory_GetSystemFontCollection((IDWriteFactory*)layout->factory, &collection, FALSE);
IDWriteFactory3_GetSystemFontCollection(layout->factory, FALSE, (IDWriteFontCollection1**)&collection, FALSE);
hr = create_matching_font(collection, range->fontfamily, range->weight,
range->style, range->stretch, &font);
......
......@@ -522,7 +522,7 @@ struct dwritefactory {
IDWriteFactory3 IDWriteFactory3_iface;
LONG ref;
IDWriteFontCollection *system_collection;
IDWriteFontCollection1 *system_collection;
IDWriteFontCollection *eudc_collection;
struct gdiinterop interop;
IDWriteFontFallback *fallback;
......@@ -576,7 +576,7 @@ static void release_dwritefactory(struct dwritefactory *factory)
release_fileloader(fileloader);
if (factory->system_collection)
IDWriteFontCollection_Release(factory->system_collection);
IDWriteFontCollection1_Release(factory->system_collection);
if (factory->eudc_collection)
IDWriteFontCollection_Release(factory->eudc_collection);
if (factory->fallback)
......@@ -666,22 +666,7 @@ static ULONG WINAPI dwritefactory_Release(IDWriteFactory3 *iface)
static HRESULT WINAPI dwritefactory_GetSystemFontCollection(IDWriteFactory3 *iface,
IDWriteFontCollection **collection, BOOL check_for_updates)
{
HRESULT hr = S_OK;
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
TRACE("(%p)->(%p %d)\n", This, collection, check_for_updates);
if (check_for_updates)
FIXME("checking for system font updates not implemented\n");
if (!This->system_collection)
hr = get_system_fontcollection(iface, &This->system_collection);
if (SUCCEEDED(hr))
IDWriteFontCollection_AddRef(This->system_collection);
*collection = This->system_collection;
return hr;
return IDWriteFactory3_GetSystemFontCollection(iface, FALSE, (IDWriteFontCollection1**)collection, check_for_updates);
}
static HRESULT WINAPI dwritefactory_CreateCustomFontCollection(IDWriteFactory3 *iface,
......@@ -707,7 +692,7 @@ static HRESULT WINAPI dwritefactory_CreateCustomFontCollection(IDWriteFactory3 *
if (FAILED(hr))
return hr;
hr = create_font_collection(iface, enumerator, FALSE, collection);
hr = create_font_collection(iface, enumerator, FALSE, (IDWriteFontCollection1**)collection);
IDWriteFontFileEnumerator_Release(enumerator);
return hr;
}
......@@ -1062,7 +1047,7 @@ static HRESULT WINAPI dwritefactory_CreateTextFormat(IDWriteFactory3 *iface, WCH
size, debugstr_w(locale), format);
if (!collection) {
hr = IDWriteFactory2_GetSystemFontCollection((IDWriteFactory2*)iface, &syscollection, FALSE);
hr = IDWriteFactory3_GetSystemFontCollection(iface, FALSE, (IDWriteFontCollection1**)&syscollection, FALSE);
if (FAILED(hr))
return hr;
}
......@@ -1387,10 +1372,25 @@ static HRESULT WINAPI dwritefactory3_GetSystemFontCollection(IDWriteFactory3 *if
IDWriteFontCollection1 **collection, BOOL check_for_updates)
{
struct dwritefactory *This = impl_from_IDWriteFactory3(iface);
HRESULT hr = S_OK;
FIXME("(%p)->(%d %p %d): stub\n", This, include_downloadable, collection, check_for_updates);
TRACE("(%p)->(%d %p %d)\n", This, include_downloadable, collection, check_for_updates);
return E_NOTIMPL;
if (include_downloadable)
FIXME("remote fonts are not supported\n");
if (check_for_updates)
FIXME("checking for system font updates not implemented\n");
if (!This->system_collection)
hr = get_system_fontcollection(iface, &This->system_collection);
if (SUCCEEDED(hr))
IDWriteFontCollection1_AddRef(This->system_collection);
*collection = This->system_collection;
return hr;
}
static HRESULT WINAPI dwritefactory3_GetFontDownloadQueue(IDWriteFactory3 *iface, IDWriteFontDownloadQueue **queue)
......
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