mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Gfx: Add support for local fonts with D2D
This does not yet work with family names containing e.g. 'Light'.
This commit is contained in:
parent
4b95f07ca6
commit
d50c2ed33f
@ -121,10 +121,23 @@ void TextFormatD2D::SetProperties(
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
IDWriteFontCollection* dwriteFontCollection = nullptr;
|
||||
auto fontCollectionD2D = (FontCollectionD2D*)fontCollection;
|
||||
|
||||
// If |fontFamily| is not in the system collection, use the font collection from
|
||||
// |fontCollectionD2D| if possible.
|
||||
//
|
||||
// TODO: Need to check GDI family names of the collection in |fontCollectionD2D|.
|
||||
if (!Util::IsFamilyInSystemFontCollection(CanvasD2D::c_DWFactory, fontFamily) &&
|
||||
(fontCollectionD2D && fontCollectionD2D->InitializeCollection()))
|
||||
{
|
||||
dwriteFontCollection = fontCollectionD2D->m_Collection;
|
||||
}
|
||||
|
||||
// Fallback in case above fails.
|
||||
hr = CanvasD2D::c_DWFactory->CreateTextFormat(
|
||||
fontFamily,
|
||||
nullptr,
|
||||
dwriteFontCollection,
|
||||
bold ? DWRITE_FONT_WEIGHT_BOLD : DWRITE_FONT_WEIGHT_REGULAR,
|
||||
italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL,
|
||||
DWRITE_FONT_STRETCH_NORMAL,
|
||||
|
@ -138,7 +138,7 @@ bool IsFamilyInSystemFontCollection(IDWriteFactory* factory, const WCHAR* family
|
||||
BOOL familyNameFound;
|
||||
HRESULT hr = systemFontCollection->FindFamilyName(
|
||||
familyName, &familyNameIndex, &familyNameFound);
|
||||
if (SUCCEEDED(hr) && !familyNameFound)
|
||||
if (SUCCEEDED(hr) && familyNameFound)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user