[deploy] fix font

This commit is contained in:
Nomango 2022-10-24 19:09:48 +08:00
parent abac7c9444
commit c6d15dfd08
2 changed files with 22 additions and 26 deletions

View File

@ -110,27 +110,27 @@ void RendererImpl::MakeContextForWindow(WindowPtr window)
}
}
if (SUCCEEDED(hr))
{
IDWriteFactory* dwrite = d2d_res_->GetDWriteFactory();
if (dwrite)
{
ComPtr<IDWriteFontCollection> system_collection;
if (SUCCEEDED(dwrite->GetSystemFontCollection(&system_collection, FALSE)))
{
Vector<String> family_names;
if (SUCCEEDED(d2d_res_->GetFontFamilyNames(family_names, system_collection)))
{
// dummy font
FontPtr font = MakePtr<Font>();
for (const auto& name : family_names)
{
FontCache::GetInstance().AddFontByFamily(name, font);
}
}
}
}
}
//if (SUCCEEDED(hr))
//{
// IDWriteFactory* dwrite = d2d_res_->GetDWriteFactory();
// if (dwrite)
// {
// ComPtr<IDWriteFontCollection> system_collection;
// if (SUCCEEDED(dwrite->GetSystemFontCollection(&system_collection, FALSE)))
// {
// Vector<String> family_names;
// if (SUCCEEDED(d2d_res_->GetFontFamilyNames(family_names, system_collection)))
// {
// // dummy font
// FontPtr font = MakePtr<Font>();
// for (const auto& name : family_names)
// {
// FontCache::GetInstance().AddFontByFamily(name, font);
// }
// }
// }
// }
//}
KGE_THROW_IF_FAILED(hr, "Create render resources failed");
}

View File

@ -97,6 +97,7 @@ Font::Font(const String& family_name, float size, uint32_t weight, FontPosture p
, weight_(weight)
, posture_(posture)
, stretch_(stretch)
, family_name_(family_name)
{
if (family_name.empty())
return;
@ -105,11 +106,6 @@ Font::Font(const String& family_name, float size, uint32_t weight, FontPosture p
if (found)
{
this->ResetNativePointer(found->GetNativePointer());
this->SetFamilyName(family_name);
}
else
{
this->Fail(strings::Format("Font::Load failed: cannot find family name \"%s\"", family_name.c_str()));
}
}