[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)) //if (SUCCEEDED(hr))
{ //{
IDWriteFactory* dwrite = d2d_res_->GetDWriteFactory(); // IDWriteFactory* dwrite = d2d_res_->GetDWriteFactory();
if (dwrite) // if (dwrite)
{ // {
ComPtr<IDWriteFontCollection> system_collection; // ComPtr<IDWriteFontCollection> system_collection;
if (SUCCEEDED(dwrite->GetSystemFontCollection(&system_collection, FALSE))) // if (SUCCEEDED(dwrite->GetSystemFontCollection(&system_collection, FALSE)))
{ // {
Vector<String> family_names; // Vector<String> family_names;
if (SUCCEEDED(d2d_res_->GetFontFamilyNames(family_names, system_collection))) // if (SUCCEEDED(d2d_res_->GetFontFamilyNames(family_names, system_collection)))
{ // {
// dummy font // // dummy font
FontPtr font = MakePtr<Font>(); // FontPtr font = MakePtr<Font>();
for (const auto& name : family_names) // for (const auto& name : family_names)
{ // {
FontCache::GetInstance().AddFontByFamily(name, font); // FontCache::GetInstance().AddFontByFamily(name, font);
} // }
} // }
} // }
} // }
} //}
KGE_THROW_IF_FAILED(hr, "Create render resources failed"); 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) , weight_(weight)
, posture_(posture) , posture_(posture)
, stretch_(stretch) , stretch_(stretch)
, family_name_(family_name)
{ {
if (family_name.empty()) if (family_name.empty())
return; return;
@ -105,11 +106,6 @@ Font::Font(const String& family_name, float size, uint32_t weight, FontPosture p
if (found) if (found)
{ {
this->ResetNativePointer(found->GetNativePointer()); 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()));
} }
} }