Stop mapping all Unicode through CJK fonts and cut D2D working-set growth
Custom font fallback no longer covers the whole BMP/SIP, so Segoe UI Emoji can paint color glyphs again; CJK still prefers Noto Sans SC then YaHei. Drop GaussianBlur compatible targets during BeginDraw (they retained GPU memory as the candidate window grew), grow the composition swapchain in 64px steps without shrinking, and reuse Card chrome plus cached text formats instead of reallocating them every layout.
This commit is contained in:
1 parent
5421c1dd1b
commit
2ac86ea0e2
5 files changed
+152
-122
No files matched your search
+46
-15
@@ -61,26 +61,57 @@ void ApplyUiFontFallback(IDWriteFactory *factory, IDWriteTextFormat *format)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ComPtr<IDWriteFontFallbackBuilder> builder;
|
||||
if (FAILED(factory2->CreateFontFallbackBuilder(builder.GetAddressOf())))
|
||||
|
||||
static ComPtr<IDWriteFontFallback> cachedFallback;
|
||||
static IDWriteFactory *cachedFactory = nullptr;
|
||||
if (!cachedFallback || cachedFactory != factory)
|
||||
{
|
||||
return;
|
||||
}
|
||||
WCHAR const *families[] = {L"Noto Sans SC", UiFontFallbackFamily()};
|
||||
DWRITE_UNICODE_RANGE allText{0, 0x10FFFF};
|
||||
if (FAILED(builder->AddMapping(&allText, 1, families, 2, nullptr, nullptr, nullptr, 1.0f)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
ComPtr<IDWriteFontFallback> customFallback;
|
||||
if (FAILED(builder->CreateFontFallback(customFallback.GetAddressOf())))
|
||||
{
|
||||
return;
|
||||
ComPtr<IDWriteFontFallbackBuilder> builder;
|
||||
if (FAILED(factory2->CreateFontFallbackBuilder(builder.GetAddressOf())))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Only CJK: mapping all of Unicode to Noto/YaHei replaces system fallback
|
||||
// and makes Segoe UI Emoji (COLR) tofu.
|
||||
static const DWRITE_UNICODE_RANGE kCjk[] = {
|
||||
{0x2E80, 0x2EFF}, {0x2F00, 0x2FDF}, {0x3000, 0x303F}, {0x3040, 0x30FF},
|
||||
{0x3100, 0x312F}, {0x31A0, 0x31BF}, {0x31C0, 0x31EF}, {0x3200, 0x32FF},
|
||||
{0x3300, 0x33FF}, {0x3400, 0x4DBF}, {0x4E00, 0x9FFF}, {0xF900, 0xFAFF},
|
||||
{0xFF00, 0xFFEF}, {0x20000, 0x2A6DF}, {0x2A700, 0x2B73F}, {0x2B740, 0x2B81F},
|
||||
{0x2B820, 0x2CEAF}, {0x2CEB0, 0x2EBEF}, {0x30000, 0x3134F},
|
||||
};
|
||||
WCHAR const *cjkFamilies[] = {L"Noto Sans SC", UiFontFallbackFamily()};
|
||||
if (FAILED(builder->AddMapping(kCjk, static_cast<UINT32>(sizeof(kCjk) / sizeof(kCjk[0])), cjkFamilies, 2,
|
||||
nullptr, nullptr, nullptr, 1.0f)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (FontFamilyExists(factory, L"Segoe UI Emoji"))
|
||||
{
|
||||
static const DWRITE_UNICODE_RANGE kEmoji[] = {
|
||||
{0x200D, 0x200D}, {0x2600, 0x27BF}, {0xFE00, 0xFE0F}, {0x1F000, 0x1F02F},
|
||||
{0x1F0A0, 0x1F0FF}, {0x1F300, 0x1FAFF}, {0x1F1E6, 0x1F1FF},
|
||||
};
|
||||
WCHAR const *emojiFamilies[] = {L"Segoe UI Emoji"};
|
||||
builder->AddMapping(kEmoji, static_cast<UINT32>(sizeof(kEmoji) / sizeof(kEmoji[0])), emojiFamilies, 1,
|
||||
nullptr, nullptr, nullptr, 1.0f);
|
||||
}
|
||||
|
||||
ComPtr<IDWriteFontFallback> customFallback;
|
||||
if (FAILED(builder->CreateFontFallback(customFallback.GetAddressOf())))
|
||||
{
|
||||
return;
|
||||
}
|
||||
cachedFallback = customFallback;
|
||||
cachedFactory = factory;
|
||||
}
|
||||
|
||||
ComPtr<IDWriteTextFormat1> format1;
|
||||
if (SUCCEEDED(format->QueryInterface(IID_PPV_ARGS(&format1))))
|
||||
{
|
||||
format1->SetFontFallback(customFallback.Get());
|
||||
format1->SetFontFallback(cachedFallback.Get());
|
||||
}
|
||||
}
|
||||
} // namespace msimeui
|
||||
Reference in new issue
Block a user