A new style desktop shell for Windows 11: menu bar, Dock, Finder, Spotlight, Control Center and Liquid Glass, in native C++.
Rust
Korean, Japanese and Chinese text in a matching font (CJK font fallback)
Eternity07062804cb450fb875
diff --git a/src/ajustes/main.cpp b/src/ajustes/main.cppindex 668fd40..c382ac9 100644--- a/src/ajustes/main.cpp+++ b/src/ajustes/main.cpp@@ -1,6 +1,7 @@// Ajustes do Sistema: janela, barra lateral, barra de ferramentas, grupos e controles no visual do// macOS Sequoia. As medidas vêm de capturas do Ajustes do Sequoia (janela de 715 pt de largura).#include "ajustes.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include "../menu/context_menu.h"#include "../comum/simbolos.h"#include "../comum/vidro.h"@@ -476,7 +477,7 @@ namespace {// ================= FontesIDWriteTextFormat* Format(const wchar_t* family, float size, DWRITE_FONT_WEIGHT weight, DWRITE_TEXT_ALIGNMENT a, bool wrap = false) {IDWriteTextFormat* tf = nullptr;- gfx::dw->CreateTextFormat(family, nullptr, weight, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf);+ cjk::Format(gfx::dw, family, nullptr, weight, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf);if (!tf) return nullptr;tf->SetTextAlignment(a);tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);diff --git a/src/ajustes/paginas.cpp b/src/ajustes/paginas.cppindex d77a881..cc06f48 100644--- a/src/ajustes/paginas.cpp+++ b/src/ajustes/paginas.cpp@@ -1,6 +1,7 @@// As páginas do Ajustes do Sistema, na ordem e com os nomes do macOS Sequoia (pt-BR). Cada uma// mostra e muda o equivalente do Windows; o que não tem como ser feito aqui abre a página do Windows.#include "ajustes.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <set>#include <mutex>#include <thread>@@ -99,7 +100,7 @@ Row Buttons(std::vector<std::pair<std::wstring, std::function<void()>>> bs) {float w = 0;IDWriteTextLayout* tl = nullptr;IDWriteTextFormat* tf = nullptr;- gfx::dw->CreateTextFormat(L"SF Pro Text", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"pt-br", &tf);+ cjk::Format(gfx::dw, L"SF Pro Text", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"pt-br", &tf);if (tf && SUCCEEDED(gfx::dw->CreateTextLayout(bs[i].first.c_str(), (UINT32)bs[i].first.size(), tf, 400, 30, &tl))) { DWRITE_TEXT_METRICS m{}; tl->GetMetrics(&m); w = m.width; tl->Release(); }if (tf) tf->Release();w = std::max(w + (tahoe::On() ? 28 : 22), 60.f);@@ -118,7 +119,7 @@ Row Hero(wchar_t glyph, UINT32 color, const std::wstring& title, const std::wstrfloat cx = (rr.left + rr.right) / 2;Tile(c, D2D1::RectF(cx - 24, rr.top + 14, cx + 24, rr.top + 62), glyph, color, SymbolFor(title));IDWriteTextFormat* tf = nullptr;- gfx::dw->CreateTextFormat(L"SF Pro Display", nullptr, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 15, L"pt-br", &tf);+ cjk::Format(gfx::dw, L"SF Pro Display", nullptr, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 15, L"pt-br", &tf);if (tf) { tf->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); Text(c, title, D2D1::RectF(rr.left + 10, rr.top + 66, rr.right - 10, rr.top + 86), tf, c.text); tf->Release(); }c.note->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);c.note->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR);@@ -162,7 +163,7 @@ Page Conta() {c.dc->FillEllipse(D2D1::Ellipse(m, 40, 40), c.br);}IDWriteTextFormat* tf = nullptr;- gfx::dw->CreateTextFormat(L"SF Pro Display", nullptr, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 20, L"pt-br", &tf);+ cjk::Format(gfx::dw, L"SF Pro Display", nullptr, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 20, L"pt-br", &tf);if (tf) { tf->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); Text(c, inf.fullName, D2D1::RectF(rr.left, rr.top + 100, rr.right, rr.top + 126), tf, c.text); tf->Release(); }c.note->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);Text(c, inf.user + L" · " + inf.computer, D2D1::RectF(rr.left, rr.top + 126, rr.right, rr.top + 144), c.note, c.text2);@@ -357,7 +358,7 @@ Page Sobre() {c.dc->FillRectangle(D2D1::RectF(cx - 8, scr.bottom, cx + 8, scr.bottom + 12), c.br);c.dc->FillRoundedRectangle(D2D1::RoundedRect(D2D1::RectF(cx - 24, scr.bottom + 11, cx + 24, scr.bottom + 15), 2, 2), c.br);IDWriteTextFormat* tf = nullptr;- gfx::dw->CreateTextFormat(L"SF Pro Display", nullptr, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 20, L"pt-br", &tf);+ cjk::Format(gfx::dw, L"SF Pro Display", nullptr, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 20, L"pt-br", &tf);if (tf) { tf->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); Text(c, model, D2D1::RectF(rr.left, rr.top + 102, rr.right, rr.top + 128), tf, c.text); tf->Release(); }};p.groups.push_back(Plain(head));@@ -649,7 +650,7 @@ Page Geral() {Tile(c, D2D1::RectF(cx - 25, rr.top + 25, cx + 25, rr.top + 75), 0xE713, C_GRAY, L"gearshape.fill");static IDWriteTextFormat* tfBig = nullptr;if (!tfBig) { IDWriteFactory* dw = nullptr; DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown**)&dw);- if (dw) { dw->CreateTextFormat(L"SF Pro Display", nullptr, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 22, L"", &tfBig); dw->Release(); }+ if (dw) { cjk::Format(dw, L"SF Pro Display", nullptr, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 22, L"", &tfBig); dw->Release(); }if (tfBig) { tfBig->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); tfBig->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); } }if (tfBig) Text(c, L"Geral", D2D1::RectF(rr.left, rr.top + 85, rr.right, rr.top + 113), tfBig, c.text);DWRITE_WORD_WRAPPING ww = c.noteCenter->GetWordWrapping();diff --git a/src/calculadora/main.cpp b/src/calculadora/main.cppindex a4388aa..8e236bb 100644--- a/src/calculadora/main.cpp+++ b/src/calculadora/main.cpp@@ -7,6 +7,7 @@// %APPDATA%\Shell\calculadora-historico.txt.#define NOMINMAX#include <windows.h>+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <windowsx.h>#include <d2d1.h>#include <dwrite.h>@@ -454,7 +455,7 @@ IDWriteTextFormat* Font(float size, DWRITE_FONT_WEIGHT w = DWRITE_FONT_WEIGHT_NOif (it != g_fonts.end()) return it->second;IDWriteTextFormat* tf = nullptr;const wchar_t* family = serif ? L"Times New Roman" : fam ? g_textFamily.c_str() : g_family.c_str();- g_dw->CreateTextFormat(family, nullptr, w, serif ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf);+ cjk::Format(g_dw, family, nullptr, w, serif ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf);if (tf) {tf->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR);@@ -1583,7 +1584,7 @@ void Render() {static IDWriteTextFormat* tt = [] {IDWriteTextFormat* f = nullptr; IDWriteFactory* dw = nullptr;DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown**)&dw);- if (dw) { dw->CreateTextFormat(L"Lucida Sans Unicode", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"pt-br", &f); dw->Release(); }+ if (dw) { cjk::Format(dw, L"Lucida Sans Unicode", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"pt-br", &f); dw->Release(); }if (f) { f->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); f->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); }return f;}();diff --git a/src/captura/main.cpp b/src/captura/main.cppindex d6f9fbd..1f4a713 100644--- a/src/captura/main.cpp+++ b/src/captura/main.cpp@@ -11,6 +11,7 @@// processo é Per-Monitor V2): DPI alto e vários monitores saem certos.#define NOMINMAX#include <windows.h>+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <windowsx.h>#include <unknwn.h>#include <d2d1.h>@@ -507,7 +508,7 @@ static IDWriteTextFormat* Fmt(float px, DWRITE_FONT_WEIGHT wt = DWRITE_FONT_WEIGauto it = cache.find(key);if (it != cache.end()) return it->second;IDWriteTextFormat* f = nullptr;- g_dw->CreateTextFormat(g_family.c_str(), nullptr, wt, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, px, idioma::Locale(), &f);+ cjk::Format(g_dw, g_family.c_str(), nullptr, wt, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, px, idioma::Locale(), &f);if (f) { f->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); f->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); }cache[key] = f;return f;diff --git a/src/clima/main.cpp b/src/clima/main.cppindex 032ef73..1695102 100644--- a/src/clima/main.cpp+++ b/src/clima/main.cpp@@ -5,6 +5,7 @@// (vai para os Ajustes, o mesmo do widget) ou apagar (o "Meu Local" também, se houver outra para ficar no lugar).// Cidades em %APPDATA%\Shell\clima.txt.#include "../comum/app2d.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include "../comum/cidade_padrao.h"#include <winhttp.h>#include <map>@@ -669,7 +670,7 @@ int WINAPI wWinMain(HINSTANCE hi, HINSTANCE, PWSTR, int show) {g_tfCard = Fmt(14, DWRITE_FONT_WEIGHT_MEDIUM, DWRITE_TEXT_ALIGNMENT_CENTER);g_tfCardBig = Fmt(18, DWRITE_FONT_WEIGHT_MEDIUM, DWRITE_TEXT_ALIGNMENT_CENTER);g_tfRowR = Fmt(16, DWRITE_FONT_WEIGHT_MEDIUM, DWRITE_TEXT_ALIGNMENT_TRAILING);- g_tfEmojiSmall = nullptr; dw->CreateTextFormat(L"Segoe UI Emoji", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 20, L"", &g_tfEmojiSmall);+ g_tfEmojiSmall = nullptr; cjk::Format(dw, L"Segoe UI Emoji", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 20, L"", &g_tfEmojiSmall);if (g_tfEmojiSmall) { g_tfEmojiSmall->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); g_tfEmojiSmall->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); }g_tfSide = Fmt(15, DWRITE_FONT_WEIGHT_SEMI_BOLD);g_tfSideTemp = Fmt(30, DWRITE_FONT_WEIGHT_LIGHT, DWRITE_TEXT_ALIGNMENT_TRAILING, false, disp.c_str());diff --git a/src/comum/app2d.h b/src/comum/app2d.hindex 768e27d..9d8506f 100644--- a/src/comum/app2d.h+++ b/src/comum/app2d.h@@ -6,6 +6,7 @@#define WIN32_LEAN_AND_MEAN#define NOMINMAX#include <windows.h>+#include "fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <windowsx.h>#include <d2d1.h>#include <dwrite.h>@@ -80,7 +81,7 @@ inline float Sc() { return GetDpiForWindow(wnd) / 96.f; }inline IDWriteTextFormat* Fmt(float size, DWRITE_FONT_WEIGHT w = DWRITE_FONT_WEIGHT_NORMAL, DWRITE_TEXT_ALIGNMENT a = DWRITE_TEXT_ALIGNMENT_LEADING,bool wrap = false, const wchar_t* fam = nullptr) {IDWriteTextFormat* f = nullptr;- dw->CreateTextFormat(fam ? fam : family.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"", &f);+ cjk::Format(dw, fam ? fam : family.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"", &f);if (!f) return nullptr;f->SetTextAlignment(a);f->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);diff --git a/src/comum/dica.h b/src/comum/dica.hindex 9e30eb6..4c062d2 100644--- a/src/comum/dica.h+++ b/src/comum/dica.h@@ -6,6 +6,7 @@// no WM_MOUSEMOVE: dica::Quer(hwnd, Tr(L"Fechar"), escuro) (texto vazio = nenhum botão sob o mouse)// no WM_MOUSELEAVE / clique / fechar: dica::Esconde()#include <windows.h>+#include "fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <d2d1.h>#include <dwrite.h>#include <string>@@ -40,7 +41,7 @@ inline IDWriteTextFormat* Fonte() {for (const wchar_t* f : { L"SF Pro Text", L"Inter" }) { UINT32 i; BOOL ex = FALSE; c->FindFamilyName(f, &i, &ex); if (ex) { fam = f; break; } }c->Release();}- dw->CreateTextFormat(fam, nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 11.5f, L"", &tf);+ cjk::Format(dw, fam, nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 11.5f, L"", &tf);if (tf) { tf->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); }dw->Release();return tf;diff --git a/src/comum/docicone.h b/src/comum/docicone.hindex 3e2af39..27d9acf 100644--- a/src/comum/docicone.h+++ b/src/comum/docicone.h@@ -8,6 +8,7 @@#define NOMINMAX#endif#include <windows.h>+#include "fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <d2d1.h>#include <dwrite.h>#include <wincodec.h>@@ -96,7 +97,7 @@ inline bool Pixels(const std::wstring& name, int px, UINT& w, UINT& h, std::vectfloat mx = (pg.left + pg.right) / 2;auto text = [&](const std::wstring& t, const wchar_t* fam, float size, DWRITE_FONT_WEIGHT wt, D2D1_RECT_F box) {IDWriteTextFormat* tf = nullptr;- if (FAILED(dw->CreateTextFormat(fam, nullptr, wt, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf)) || !tf) return;+ if (FAILED(cjk::Format(dw, fam, nullptr, wt, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf)) || !tf) return;tf->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);tf->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);diff --git a/src/comum/fonte_cjk.h b/src/comum/fonte_cjk.hnew file mode 100644index 0000000..f56ffea--- /dev/null+++ b/src/comum/fonte_cjk.h@@ -0,0 +1,104 @@+// Fonte para coreano, japonês e chinês em todo o WacOS.+// As fontes SF Pro do pacote não têm hangul, kana nem ideogramas: o DirectWrite caía na reserva do Windows+// (Malgun Gothic, Yu Gothic, Microsoft YaHei), com outro peso, outra altura e outro espaçamento que o SF ao+// lado, e o texto em coreano parecia de outro sistema. Aqui todo formato de texto ganha uma reserva própria:+// cada escrita vai para a fonte que o macOS usa para ela, se estiver instalada, e depois para as equivalentes+// livres e as do Windows (a primeira instalada da lista vence). Nenhuma fonte vem junto com o WacOS.+// coreano: Apple SD Gothic Neo -> Pretendard -> Noto Sans KR -> Malgun Gothic+// japonês: Hiragino Sans -> Noto Sans JP -> Yu Gothic UI -> Meiryo UI+// chinês: PingFang SC -> Noto Sans SC -> Microsoft YaHei UI+// Os ideogramas (hanja/kanji/hanzi) e a pontuação CJK seguem o idioma do WacOS (ajustes.txt idioma=ko/ja/zh);+// nos outros idiomas ficam com a reserva do Windows, como antes. fonte_cjk=<família> no ajustes.txt põe uma+// fonte escolhida na frente da lista do idioma (para o coreano nos idiomas que não são CJK).+// Uso: cjk::Format(fábrica, ...) no lugar de fábrica->CreateTextFormat(...), mesmos argumentos.+#pragma once+#include <windows.h>+#include <dwrite_2.h>+#include <cstdio>+#include <string>+#include <vector>++namespace cjk {++struct Prefs { std::wstring lang, font; };++// idioma e fonte escolhida, lidos uma vez do %APPDATA%\Shell\ajustes.txt (o mesmo arquivo dos Ajustes)+inline const Prefs& ReadPrefs() {+ static Prefs p = [] {+ Prefs r;+ wchar_t ad[MAX_PATH] = {};+ if (!GetEnvironmentVariableW(L"APPDATA", ad, MAX_PATH)) return r;+ FILE* f = nullptr;+ if (_wfopen_s(&f, (std::wstring(ad) + L"\\Shell\\ajustes.txt").c_str(), L"r, ccs=UTF-8") || !f) return r;+ wchar_t line[512];+ while (fgetws(line, 512, f)) {+ std::wstring l = line;+ while (!l.empty() && (l.back() == L'\n' || l.back() == L'\r' || l.back() == L' ')) l.pop_back();+ if (!l.empty() && l[0] == 0xFEFF) l.erase(0, 1);+ if (!l.compare(0, 7, L"idioma=")) r.lang = l.substr(7, 2);+ else if (!l.compare(0, 10, L"fonte_cjk=")) r.font = l.substr(10);+ }+ fclose(f);+ return r;+ }();+ return p;+}++// a reserva (uma por processo; os formatos guardam a referência deles)+inline IDWriteFontFallback* Fallback(IDWriteFactory* factory) {+ static IDWriteFontFallback* fb = nullptr;+ static bool tried = false;+ if (tried) return fb;+ tried = true;+ IDWriteFactory2* f2 = nullptr;+ if (!factory || FAILED(factory->QueryInterface(__uuidof(IDWriteFactory2), (void**)&f2)) || !f2) return nullptr;+ IDWriteFontFallbackBuilder* b = nullptr;+ IDWriteFontFallback* sys = nullptr;+ if (SUCCEEDED(f2->CreateFontFallbackBuilder(&b)) && b) {+ const Prefs& p = ReadPrefs();+ const bool ko = p.lang == L"ko", ja = p.lang == L"ja", zh = p.lang == L"zh";+ auto chain = [&](std::vector<const wchar_t*> v, bool mine) {+ if (mine && !p.font.empty()) v.insert(v.begin(), p.font.c_str());+ return v;+ };+ std::vector<const wchar_t*> kr = chain({ L"Apple SD Gothic Neo", L"Pretendard", L"Pretendard Variable", L"Noto Sans KR", L"Malgun Gothic" }, ko || (!ja && !zh));+ std::vector<const wchar_t*> jp = chain({ L"Hiragino Sans", L"Hiragino Kaku Gothic ProN", L"Noto Sans JP", L"Yu Gothic UI", L"Meiryo UI" }, ja);+ std::vector<const wchar_t*> cn = chain({ L"PingFang SC", L"Noto Sans SC", L"Microsoft YaHei UI" }, zh);+ const DWRITE_UNICODE_RANGE hangul[] = {+ { 0x1100, 0x11FF }, { 0x3130, 0x318F }, { 0xA960, 0xA97F }, { 0xAC00, 0xD7AF }, { 0xD7B0, 0xD7FF }, { 0xFFA0, 0xFFDC } };+ const DWRITE_UNICODE_RANGE kana[] = { { 0x3040, 0x30FF }, { 0x31F0, 0x31FF }, { 0xFF66, 0xFF9F } };+ // ideogramas, pontuação CJK e formas de largura cheia: a fonte do idioma do WacOS+ const DWRITE_UNICODE_RANGE han[] = {+ { 0x3000, 0x303F }, { 0x3400, 0x4DBF }, { 0x4E00, 0x9FFF }, { 0xF900, 0xFAFF }, { 0xFF00, 0xFF65 }, { 0xFFE0, 0xFFEF } };+ b->AddMapping(hangul, ARRAYSIZE(hangul), kr.data(), (UINT32)kr.size(), nullptr, L"ko-KR", nullptr, 1.0f);+ b->AddMapping(kana, ARRAYSIZE(kana), jp.data(), (UINT32)jp.size(), nullptr, L"ja-JP", nullptr, 1.0f);+ if (ko) b->AddMapping(han, ARRAYSIZE(han), kr.data(), (UINT32)kr.size(), nullptr, L"ko-KR", nullptr, 1.0f);+ else if (ja) b->AddMapping(han, ARRAYSIZE(han), jp.data(), (UINT32)jp.size(), nullptr, L"ja-JP", nullptr, 1.0f);+ else if (zh) b->AddMapping(han, ARRAYSIZE(han), cn.data(), (UINT32)cn.size(), nullptr, L"zh-CN", nullptr, 1.0f);+ if (SUCCEEDED(f2->GetSystemFontFallback(&sys)) && sys) b->AddMappings(sys); // o resto: a reserva do Windows+ b->CreateFontFallback(&fb);+ }+ if (sys) sys->Release();+ if (b) b->Release();+ f2->Release();+ return fb;+}++inline void Apply(IDWriteFactory* factory, IDWriteTextFormat* tf) {+ if (!tf) return;+ IDWriteFontFallback* fb = Fallback(factory);+ if (!fb) return; // Windows sem IDWriteFactory2 (8.0 e antes): como antes+ IDWriteTextFormat1* t1 = nullptr;+ if (SUCCEEDED(tf->QueryInterface(__uuidof(IDWriteTextFormat1), (void**)&t1)) && t1) { t1->SetFontFallback(fb); t1->Release(); }+}++// factory->CreateTextFormat(...) com a reserva CJK+inline HRESULT Format(IDWriteFactory* factory, const wchar_t* family, IDWriteFontCollection* collection, DWRITE_FONT_WEIGHT weight,+ DWRITE_FONT_STYLE style, DWRITE_FONT_STRETCH stretch, float size, const wchar_t* locale, IDWriteTextFormat** out) {+ if (!factory) return E_POINTER;+ HRESULT hr = factory->CreateTextFormat(family, collection, weight, style, stretch, size, locale, out);+ if (SUCCEEDED(hr) && out && *out) Apply(factory, *out);+ return hr;+}++} // namespace cjkdiff --git a/src/finder/info.cpp b/src/finder/info.cppindex ad98974..914bb5a 100644--- a/src/finder/info.cpp+++ b/src/finder/info.cpp@@ -7,6 +7,7 @@// a senha de administrador (UAC) e reabre a janela como administrador, onde cada privilégio pode ser// trocado (Leitura e Gravação, Somente Leitura, Somente Gravação, Sem Acesso), como no Mac.#include "finder.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include "../menu/context_menu.h"#include <aclapi.h>#include <sddl.h>@@ -81,7 +82,7 @@ std::wstring g_packDir;IDWriteTextFormat* Fmt(float size, DWRITE_FONT_WEIGHT w, DWRITE_TEXT_ALIGNMENT a = DWRITE_TEXT_ALIGNMENT_LEADING) {IDWriteTextFormat* tf = nullptr;- if (FAILED(gfx::dw->CreateTextFormat(g_family.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf))) return nullptr;+ if (FAILED(cjk::Format(gfx::dw, g_family.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf))) return nullptr;tf->SetTextAlignment(a);tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR);return tf;diff --git a/src/finder/main.cpp b/src/finder/main.cppindex c1a0a98..1d918bf 100644--- a/src/finder/main.cpp+++ b/src/finder/main.cpp@@ -5,6 +5,7 @@// Arquivos.exe [pasta]#include "finder.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <d2d1effects.h> // Leopard: a perspectiva 3D do Cover Flow#pragma comment(lib, "dxguid.lib")#include <windowsx.h>@@ -2233,7 +2234,7 @@ static void DrawFolder(ID2D1DeviceContext* dc, D2D1_RECT_F box, wchar_t emblem,if (!g_tfEmblem || g_tfEmblemSize != size) {if (g_tfEmblem) g_tfEmblem->Release();IDWriteTextFormat* tf = nullptr;- gfx::dw->CreateTextFormat(g_iconFamily.c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,+ cjk::Format(gfx::dw, g_iconFamily.c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL,DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf);tf->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);@@ -2348,7 +2349,7 @@ static void DrawDocument(ID2D1DeviceContext* dc, D2D1_RECT_F box, const std::wstfloat size = std::round(std::max(6.f, 0.15f * S));if (!g_tfDocExt || g_tfDocExtSize != size) {if (g_tfDocExt) g_tfDocExt->Release();- gfx::dw->CreateTextFormat(g_uiFamily.c_str(), nullptr, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &g_tfDocExt);+ cjk::Format(gfx::dw, g_uiFamily.c_str(), nullptr, DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &g_tfDocExt);g_tfDocExt->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);g_tfDocExt->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);g_tfDocExtSize = size;@@ -2359,7 +2360,7 @@ static void DrawDocument(ID2D1DeviceContext* dc, D2D1_RECT_F box, const std::wstfloat gs = std::round(0.34f * S);if (!tfGlyph || tfGlyphSize != gs) {if (tfGlyph) tfGlyph->Release();- gfx::dw->CreateTextFormat(g_iconFamily.c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, gs, L"pt-br", &tfGlyph);+ cjk::Format(gfx::dw, g_iconFamily.c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, gs, L"pt-br", &tfGlyph);tfGlyph->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);tfGlyph->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);tfGlyphSize = gs;@@ -2941,7 +2942,7 @@ static void DrawListHeader(ID2D1DeviceContext* dc, const Palette& pal, ID2D1Solidc->DrawLine({ Lay::SIDEBAR_W, bottom - 0.5f }, { s.width, bottom - 0.5f }, br, 1);static IDWriteTextFormat* tfH = [] {IDWriteTextFormat* f = nullptr;- gfx::dw->CreateTextFormat(L"Lucida Sans Unicode", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 11, L"pt-br", &f);+ cjk::Format(gfx::dw, L"Lucida Sans Unicode", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 11, L"pt-br", &f);if (f) { f->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); f->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); }return f;}();@@ -7113,7 +7114,7 @@ static void MoveFavorite(int from, int to) { // `to` = posição de inserçãostatic IDWriteTextFormat* Format(const wchar_t* family, float size, DWRITE_FONT_WEIGHT weight,DWRITE_TEXT_ALIGNMENT align, DWRITE_PARAGRAPH_ALIGNMENT para, bool wrap) {IDWriteTextFormat* tf = nullptr;- gfx::dw->CreateTextFormat(family, nullptr, weight, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf);+ cjk::Format(gfx::dw, family, nullptr, weight, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf);tf->SetTextAlignment(align);tf->SetParagraphAlignment(para);tf->SetWordWrapping(wrap ? (DWRITE_WORD_WRAPPING)2 /*EMERGENCY_BREAK*/ : DWRITE_WORD_WRAPPING_NO_WRAP);diff --git a/src/finder/pastacor.cpp b/src/finder/pastacor.cppindex d2f7d45..87430c0 100644--- a/src/finder/pastacor.cpp+++ b/src/finder/pastacor.cpp@@ -6,6 +6,7 @@#define WIN32_LEAN_AND_MEAN#define NOMINMAX#include <windows.h>+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <shlobj.h>#include <shlwapi.h>#include <d2d1_1.h>@@ -122,7 +123,7 @@ bool TintedPixels(bool tahoe, int color, std::vector<BYTE>& px, UINT& w, UINT& hIDWriteTextFormat* EmojiFormat(IDWriteFactory* dw, float size) {IDWriteTextFormat* tf = nullptr;- dw->CreateTextFormat(L"Segoe UI Emoji", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"", &tf);+ cjk::Format(dw, L"Segoe UI Emoji", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"", &tf);if (tf) { tf->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); }return tf;}diff --git a/src/janelas/controles.cpp b/src/janelas/controles.cppindex 6c0da60..d3b2871 100644--- a/src/janelas/controles.cpp+++ b/src/janelas/controles.cpp@@ -9,6 +9,7 @@#define NOMINMAX#define SEMAFORO_SEM_ESPERA // antes dos includes, igual nos dois .cpp da DLL (semaforo.h)#include <windows.h>+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <windowsx.h>#include <commctrl.h>#include <uxtheme.h>@@ -168,7 +169,7 @@ struct Canvas {DWRITE_FONT_WEIGHT w = DWRITE_FONT_WEIGHT_NORMAL, bool wrap = false) {if (!g_dw || s.empty()) return;IDWriteTextFormat* tf = nullptr;- if (FAILED(g_dw->CreateTextFormat(g_face.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf))) return;+ if (FAILED(cjk::Format(g_dw, g_face.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf))) return;if (!wrap) { // a SF Pro é mais larga que a fonte do Windows: encolhe até 85% para caber no controleIDWriteTextLayout* lay = nullptr;if (SUCCEEDED(g_dw->CreateTextLayout(s.c_str(), (UINT32)s.size(), tf, 10000, 1000, &lay))) {@@ -177,7 +178,7 @@ struct Canvas {if (m.widthIncludingTrailingWhitespace > avail && avail > 0) {float k = std::max(0.85f, avail / m.widthIncludingTrailingWhitespace);tf->Release(); tf = nullptr;- if (FAILED(g_dw->CreateTextFormat(g_face.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size * k, L"pt-br", &tf))) return;+ if (FAILED(cjk::Format(g_dw, g_face.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size * k, L"pt-br", &tf))) return;}}}@@ -369,7 +370,7 @@ void PaintTab(HWND h, HDC dc) {names[i] = t;// largura aproximada pelo DirectWriteIDWriteTextFormat* tf = nullptr; IDWriteTextLayout* lay = nullptr; float w = 40 * s;- if (g_dw && SUCCEEDED(g_dw->CreateTextFormat(g_face.c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, fs, L"pt-br", &tf))) {+ if (g_dw && SUCCEEDED(cjk::Format(g_dw, g_face.c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, fs, L"pt-br", &tf))) {if (SUCCEEDED(g_dw->CreateTextLayout(t.c_str(), (UINT32)t.size(), tf, 2000, 100, &lay))) { DWRITE_TEXT_METRICS m; lay->GetMetrics(&m); w = m.widthIncludingTrailingWhitespace; lay->Release(); }tf->Release();}@@ -536,7 +537,7 @@ void PaintGroups(HWND dlg, HDC dc) {if (!t.empty()) {float tw = 0;IDWriteTextFormat* tf = nullptr; IDWriteTextLayout* lay = nullptr;- if (g_dw && SUCCEEDED(g_dw->CreateTextFormat(g_face.c_str(), nullptr, DWRITE_FONT_WEIGHT_SEMI_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, fs * 0.92f, L"pt-br", &tf))) {+ if (g_dw && SUCCEEDED(cjk::Format(g_dw, g_face.c_str(), nullptr, DWRITE_FONT_WEIGHT_SEMI_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, fs * 0.92f, L"pt-br", &tf))) {if (SUCCEEDED(g_dw->CreateTextLayout(t.c_str(), (UINT32)t.size(), tf, 2000, 100, &lay))) { DWRITE_TEXT_METRICS m; lay->GetMetrics(&m); tw = m.width; lay->Release(); }tf->Release();}@@ -601,7 +602,7 @@ const float LW = 420, LTX = 104, LTOP = 15, LBTN = 21;float TextWidthD(const std::wstring& s, float size) {if (s.empty() || !g_dw) return 0;IDWriteTextFormat* tf = nullptr; IDWriteTextLayout* lay = nullptr; float w = 0;- if (SUCCEEDED(g_dw->CreateTextFormat(g_face.c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf))) {+ if (SUCCEEDED(cjk::Format(g_dw, g_face.c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf))) {if (SUCCEEDED(g_dw->CreateTextLayout(s.c_str(), (UINT32)s.size(), tf, 4000, 400, &lay))) { DWRITE_TEXT_METRICS m; lay->GetMetrics(&m); w = m.widthIncludingTrailingWhitespace; lay->Release(); }tf->Release();}@@ -628,7 +629,7 @@ bool IsMessageBox(HWND dlg) {float TextHeight(const std::wstring& s, float size, DWRITE_FONT_WEIGHT w, float width) {if (s.empty() || !g_dw) return 0;IDWriteTextFormat* tf = nullptr; IDWriteTextLayout* lay = nullptr; float h = 0;- if (SUCCEEDED(g_dw->CreateTextFormat(g_face.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf))) {+ if (SUCCEEDED(cjk::Format(g_dw, g_face.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf))) {tf->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);if (SUCCEEDED(g_dw->CreateTextLayout(s.c_str(), (UINT32)s.size(), tf, width, 4000, &lay))) { DWRITE_TEXT_METRICS m; lay->GetMetrics(&m); h = m.height; lay->Release(); }tf->Release();diff --git a/src/janelas/macjanela.cpp b/src/janelas/macjanela.cppindex cf25860..e57b086 100644--- a/src/janelas/macjanela.cpp+++ b/src/janelas/macjanela.cpp@@ -8,6 +8,7 @@#define NOMINMAX#define SEMAFORO_SEM_ESPERA // antes dos includes, igual nos dois .cpp da DLL (semaforo.h)#include <windows.h>+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <commctrl.h>#include <uxtheme.h>#include <dwmapi.h>@@ -2685,8 +2686,8 @@ void Attach(HWND h, int mode) {if (ok) { fam = n; break; }}if (fc) fc->Release();- g_dw->CreateTextFormat(fam, nullptr, DWRITE_FONT_WEIGHT_SEMI_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"pt-br", &g_tf);- if (g_dw->CreateTextFormat(L"Lucida Sans Unicode", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"pt-br", &g_tfLeo) == S_OK && g_tfLeo) {+ cjk::Format(g_dw, fam, nullptr, DWRITE_FONT_WEIGHT_SEMI_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"pt-br", &g_tf);+ if (cjk::Format(g_dw, L"Lucida Sans Unicode", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"pt-br", &g_tfLeo) == S_OK && g_tfLeo) {g_tfLeo->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);g_tfLeo->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);g_tfLeo->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);@@ -2701,7 +2702,7 @@ void Attach(HWND h, int mode) {g_tf->SetTrimming(&tr, ell);if (ell) ell->Release();}- g_dw->CreateTextFormat(fam, nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 12, L"pt-br", &g_tfTool);+ cjk::Format(g_dw, fam, nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 12, L"pt-br", &g_tfTool);if (g_tfTool) {g_tfTool->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);g_tfTool->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);diff --git a/src/menu/context_menu.cpp b/src/menu/context_menu.cppindex 8ef0860..4323cb9 100644--- a/src/menu/context_menu.cpp+++ b/src/menu/context_menu.cpp@@ -3,6 +3,7 @@#define WIN32_LEAN_AND_MEAN#define NOMINMAX#include <windows.h>+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <windowsx.h>#include <shlobj.h>#include <shlwapi.h>@@ -775,7 +776,7 @@ static float TextWidth(IDWriteTextFormat* tf, const std::wstring& s) {static IDWriteTextFormat* MakeFormat(float size, DWRITE_FONT_WEIGHT w) {IDWriteTextFormat* tf = nullptr;- g_dw->CreateTextFormat(g_font.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf);+ cjk::Format(g_dw, g_font.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf);tf->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);IDWriteInlineObject* ell = nullptr;@@ -860,7 +861,7 @@ static void OpenLevel(Session& s, std::vector<MItem>* items, POINT anchor, const}if (maxShort > 0) maxW += maxShort + 28 * sc; // atalhos alinhados à direita, como na barra de menus do Macif (hasIcon) { // ícones do Tahoe: coluna de ícones à esquerda, texto depois dela- g_dw->CreateTextFormat(L"Segoe Fluent Icons", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13 * sc, L"", &L.tfIcon);+ cjk::Format(g_dw, L"Segoe Fluent Icons", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13 * sc, L"", &L.tfIcon);if (L.tfIcon) { L.tfIcon->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); L.tfIcon->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); }}L.textL = (hasIcon ? (Golden() ? 41.f : Tahoe() ? 33.f : ICON_TEXT_L) : hasCheck ? 26.f : Golden() ? 16.f : Tahoe() ? 14.f : 16.f) * sc;diff --git a/src/monitor/main.cpp b/src/monitor/main.cppindex a655690..dbf3d64 100644--- a/src/monitor/main.cpp+++ b/src/monitor/main.cpp@@ -7,6 +7,7 @@#define WIN32_LEAN_AND_MEAN#define NOMINMAX#include <winsock2.h>+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <ws2tcpip.h>#include <windows.h>#include <windowsx.h>@@ -604,7 +605,7 @@ Pal ColorsBase() {IDWriteTextFormat* Fmt(float size, DWRITE_FONT_WEIGHT w, DWRITE_TEXT_ALIGNMENT a = DWRITE_TEXT_ALIGNMENT_LEADING) {IDWriteTextFormat* tf = nullptr;- if (FAILED(g_dw->CreateTextFormat(g_family.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf))) return nullptr;+ if (FAILED(cjk::Format(g_dw, g_family.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf))) return nullptr;tf->SetTextAlignment(a);tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);tf->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);@@ -801,7 +802,7 @@ void DrawToolbarLeopard(ID2D1RenderTarget* rt, ID2D1SolidColorBrush* br, const PDrawLights(rt, br);static IDWriteTextFormat* tt = [] {IDWriteTextFormat* f = nullptr;- g_dw->CreateTextFormat(L"Lucida Sans Unicode", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"pt-br", &f);+ cjk::Format(g_dw, L"Lucida Sans Unicode", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"pt-br", &f);if (f) { f->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); f->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); f->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); }return f;}();@@ -850,7 +851,7 @@ void DrawToolbarLeopard(ID2D1RenderTarget* rt, ID2D1SolidColorBrush* br, const P}static IDWriteTextFormat* ts = [] {IDWriteTextFormat* f = nullptr;- g_dw->CreateTextFormat(L"Lucida Sans Unicode", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 12, L"pt-br", &f);+ cjk::Format(g_dw, L"Lucida Sans Unicode", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 12, L"pt-br", &f);if (f) { f->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); f->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); f->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); }return f;}();diff --git a/src/notas/editor.cpp b/src/notas/editor.cppindex 407b492..c8687a6 100644--- a/src/notas/editor.cpp+++ b/src/notas/editor.cpp@@ -3,6 +3,7 @@// listas (marcadores, traços, números, verificação com bolinhas), seções recolhíveis nos títulos,// desfazer/refazer e área de transferência com formatação (formato próprio + texto puro).#include "notas.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <cwctype>#include <algorithm>#include <cmath>@@ -429,7 +430,7 @@ void SetFormats(const std::wstring& fam, const std::wstring& mono) {family = fam; monoFamily = mono;for (int s = 0; s < 5; s++) {if (fmt[s]) fmt[s]->Release();- gfx::dw->CreateTextFormat(s == S_MONO ? monoFamily.c_str() : family.c_str(), nullptr, SM[s].w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, SM[s].size, L"pt-br", &fmt[s]);+ cjk::Format(gfx::dw, s == S_MONO ? monoFamily.c_str() : family.c_str(), nullptr, SM[s].w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, SM[s].size, L"pt-br", &fmt[s]);if (fmt[s]) fmt[s]->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP);}ReleaseLayouts();@@ -516,8 +517,8 @@ void DrawFile(ID2D1DeviceContext* dc, ID2D1SolidColorBrush* br, const Para& p, cstd::wstring ext = name.substr(name.find_last_of(L'.') + 1);if (ext.size() < name.size() && ext.size() <= 5) { for (auto& c : ext) c = towupper(c); info = ext + L" · " + info; }IDWriteTextFormat *t1 = nullptr, *t2 = nullptr;- gfx::dw->CreateTextFormat(family.c_str(), nullptr, DWRITE_FONT_WEIGHT_SEMI_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"pt-br", &t1);- gfx::dw->CreateTextFormat(family.c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 11, L"pt-br", &t2);+ cjk::Format(gfx::dw, family.c_str(), nullptr, DWRITE_FONT_WEIGHT_SEMI_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"pt-br", &t1);+ cjk::Format(gfx::dw, family.c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 11, L"pt-br", &t2);DWRITE_TRIMMING tr{ DWRITE_TRIMMING_GRANULARITY_CHARACTER, 0, 0 };if (t1) { t1->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); t1->SetTrimming(&tr, nullptr); br->SetColor(TextColor()); dc->DrawTextW(name.c_str(), (UINT32)name.size(), t1, D2D1::RectF(r.left + 48, r.top + 9, r.right - 10, r.top + 27), br); t1->Release(); }if (t2) { br->SetColor(Text2()); dc->DrawTextW(info.c_str(), (UINT32)info.size(), t2, D2D1::RectF(r.left + 48, r.top + 28, r.right - 10, r.top + 44), br); t2->Release(); }@@ -556,7 +557,7 @@ void Draw(ID2D1DeviceContext* dc, D2D1_RECT_F a) {{std::wstring d = LongDate(N->modified);IDWriteTextFormat* tf = nullptr;- gfx::dw->CreateTextFormat(family.c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 12, L"pt-br", &tf);+ cjk::Format(gfx::dw, family.c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 12, L"pt-br", &tf);if (tf) {tf->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);br->SetColor(Text2());diff --git a/src/notas/main.cpp b/src/notas/main.cppindex ed1fc82..7e32bea 100644--- a/src/notas/main.cpp+++ b/src/notas/main.cpp@@ -4,6 +4,7 @@// tema claro/escuro do sistema. Dados em %APPDATA%\Shell\Notas (grava sozinho enquanto digita).// Notas.exe [--dados=<pasta>] [--captura=<arquivo.png> --escuro|--claro --tamanho=LxA --pasta=<id> --nota=<n> --galeria --aa]#include "notas.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <windowsx.h>#include <dwmapi.h>#include <shellapi.h>@@ -2233,7 +2234,7 @@ std::wstring PickFamily(std::initializer_list<const wchar_t*> names) {IDWriteTextFormat* Fmt(float size, DWRITE_FONT_WEIGHT w, DWRITE_TEXT_ALIGNMENT a = DWRITE_TEXT_ALIGNMENT_LEADING, const std::wstring& fam = L"") {IDWriteTextFormat* tf = nullptr;- if (FAILED(gfx::dw->CreateTextFormat((fam.empty() ? g_family : fam).c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf))) return nullptr;+ if (FAILED(cjk::Format(gfx::dw, (fam.empty() ? g_family : fam).c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf))) return nullptr;tf->SetTextAlignment(a);tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);tf->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);diff --git a/src/preview/main.cpp b/src/preview/main.cppindex 0ceb36c..01faea0 100644--- a/src/preview/main.cpp+++ b/src/preview/main.cpp@@ -9,6 +9,7 @@#define WIN32_LEAN_AND_MEAN#define NOMINMAX#include <windows.h>+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <windowsx.h>#include <shellapi.h>#include <shobjidl.h>@@ -431,8 +432,8 @@ void DrawAnn(ID2D1RenderTarget* rt, const Ann& a, D2D1_RECT_F r, float z) {}if (a.tool == T_TEXT && !a.text.empty()) {IDWriteTextFormat* f = nullptr;- g_dw->CreateTextFormat(L"Helvetica", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, std::max(1.f, 18 * z), L"", &f);- if (!f) g_dw->CreateTextFormat(L"Arial", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, std::max(1.f, 18 * z), L"", &f);+ cjk::Format(g_dw, L"Helvetica", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, std::max(1.f, 18 * z), L"", &f);+ if (!f) cjk::Format(g_dw, L"Arial", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, std::max(1.f, 18 * z), L"", &f);if (f) { D2D1_POINT_2F p = P(a.pts[0]); rt->DrawTextW(a.text.c_str(), (UINT32)a.text.size(), f, D2D1::RectF(p.x, p.y, p.x + 4000, p.y + 400), b); f->Release(); }}if (round) round->Release();@@ -1044,7 +1045,7 @@ LRESULT CALLBACK Proc(HWND h, UINT m, WPARAM w, LPARAM l) {IDWriteTextFormat* Fmt(const wchar_t* fam, float size, DWRITE_FONT_WEIGHT wt, DWRITE_TEXT_ALIGNMENT a, DWRITE_PARAGRAPH_ALIGNMENT pa) {IDWriteTextFormat* f = nullptr;- g_dw->CreateTextFormat(fam, nullptr, wt, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"", &f);+ cjk::Format(g_dw, fam, nullptr, wt, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"", &f);if (f) { f->SetTextAlignment(a); f->SetParagraphAlignment(pa); f->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP); }return f;}diff --git a/src/setup/main.cpp b/src/setup/main.cppindex 4a47299..bfa53df 100644--- a/src/setup/main.cpp+++ b/src/setup/main.cpp@@ -14,6 +14,7 @@#define WIN32_LEAN_AND_MEAN#define NOMINMAX#include <windows.h>+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <windowsx.h>#include <d2d1.h>#include <dwrite.h>@@ -896,7 +897,7 @@ static D2D1_COLOR_F Fg2() { return g_dark ? C(0xFFFFFF, 0.55f) : C(0x6E6E73); }static IDWriteTextFormat* Fmt(float size, DWRITE_FONT_WEIGHT w, bool title = false, DWRITE_TEXT_ALIGNMENT al = DWRITE_TEXT_ALIGNMENT_LEADING) {IDWriteTextFormat* f = nullptr;- g_dw->CreateTextFormat((title ? g_fontTitle : g_fontUI).c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, g_pt ? L"pt-BR" : L"en-US", &f);+ cjk::Format(g_dw, (title ? g_fontTitle : g_fontUI).c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, g_pt ? L"pt-BR" : L"en-US", &f);if (f) { f->SetTextAlignment(al); f->SetWordWrapping(DWRITE_WORD_WRAPPING_WRAP); }return f;}diff --git a/src/shell/barras.cpp b/src/shell/barras.cppindex 01c68b9..16706e2 100644--- a/src/shell/barras.cpp+++ b/src/shell/barras.cpp@@ -26,6 +26,7 @@// ajustes.txt ou C:\Users\Public\MacTitulo-desligado.txt. Roda numa thread própria (um programa travado// não segura o Dock nem a barra de menus).#include "shell.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <dwmapi.h>#include <d2d1.h>#include <dwrite.h>@@ -1197,7 +1198,7 @@ void Fontes() {}fc->Release();}- g_dw->CreateTextFormat(fam, nullptr, DWRITE_FONT_WEIGHT_SEMI_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"pt-br", &g_tf);+ cjk::Format(g_dw, fam, nullptr, DWRITE_FONT_WEIGHT_SEMI_BOLD, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"pt-br", &g_tf);if (g_tf) {g_tf->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);g_tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);diff --git a/src/shell/bloqueio.cpp b/src/shell/bloqueio.cppindex 6c57f59..04a7a27 100644--- a/src/shell/bloqueio.cpp+++ b/src/shell/bloqueio.cpp@@ -16,6 +16,7 @@// - erros do LogonUserW que não são "senha errada" aceitam e ficam no shell.log;// - depois de 3 erros a tela espera antes de tentar de novo, para não disparar o bloqueio de conta do Windows.#include "shell.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <d2d1effects.h>#include <wincodec.h>#include <sddl.h>@@ -193,8 +194,8 @@ void LoadUser() {// ---- textoIDWriteTextLayout* Lay(const std::wstring& s, const wchar_t* fam, float size, DWRITE_FONT_WEIGHT wt, float boxW, bool wrap = false) {IDWriteTextFormat* tf = nullptr;- if (FAILED(ui::dw->CreateTextFormat(fam, nullptr, wt, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf)) &&- FAILED(ui::dw->CreateTextFormat(ui::family.c_str(), nullptr, wt, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf)))+ if (FAILED(cjk::Format(ui::dw, fam, nullptr, wt, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf)) &&+ FAILED(cjk::Format(ui::dw, ui::family.c_str(), nullptr, wt, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf)))return nullptr;tf->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);tf->SetWordWrapping(wrap ? DWRITE_WORD_WRAPPING_WRAP : DWRITE_WORD_WRAPPING_NO_WRAP);diff --git a/src/shell/menus.cpp b/src/shell/menus.cppindex ac396fb..f0b1583 100644--- a/src/shell/menus.cpp+++ b/src/shell/menus.cpp@@ -7,6 +7,7 @@// 4. O teclado continua indo para o menu nativo; acompanhamos o destaque pelo evento de foco.// Programas que desenham o próprio menu (Chrome, Electron, WinUI) não usam #32768 e ficam como estão.#include "shell.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include "../menu/context_menu.h"#include <dwmapi.h>#include <dcomp.h>@@ -129,7 +130,7 @@ void Formats(float scale) {if (!g_tfIcon) {IDWriteFactory* dw = nullptr;if (SUCCEEDED(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown**)&dw))) {- dw->CreateTextFormat(L"Segoe Fluent Icons", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"", &g_tfIcon);+ cjk::Format(dw, L"Segoe Fluent Icons", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"", &g_tfIcon);if (g_tfIcon) { g_tfIcon->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); g_tfIcon->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); }dw->Release();}diff --git a/src/shell/mesa.cpp b/src/shell/mesa.cppindex 95bcab7..181eea9 100644--- a/src/shell/mesa.cpp+++ b/src/shell/mesa.cpp@@ -17,6 +17,7 @@// da mesa ou para outra casa da grade), soltar arquivos de fora, F2 renomeia, Delete vai para a Lixeira,// Ctrl+C/X/V, menu de contexto (o nosso, com as extensões do Windows) e o menu do fundo do Mac.#include "shell.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include "../comum/ajustes_arquivo.h"#include <dwmapi.h>#include "../menu/context_menu.h"@@ -742,7 +743,7 @@ void EnsureFormat() {if (g_tf && g_tfScale == s && pt == g_textoPt) return;if (g_tf) g_tf->Release();g_tf = nullptr; g_tfScale = s; pt = g_textoPt;- ui::dw->CreateTextFormat(ui::family.c_str(), nullptr, DWRITE_FONT_WEIGHT_MEDIUM, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL,+ cjk::Format(ui::dw, ui::family.c_str(), nullptr, DWRITE_FONT_WEIGHT_MEDIUM, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL,g_textoPt * s, L"", &g_tf);if (!g_tf) return;g_tf->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER);diff --git a/src/shell/notificacoes.cpp b/src/shell/notificacoes.cppindex 14b8b6f..1971ab8 100644--- a/src/shell/notificacoes.cpp+++ b/src/shell/notificacoes.cpp@@ -10,6 +10,7 @@// conteúdo por cima (Direct2D na GPU). O Windows não avisa quando chega notificação para app sem pacote// (NotificationChanged dá "Elemento não encontrado"), então uma thread relê a lista a cada 2 s com o painel aberto.#include "shell.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include "../comum/ajustes_arquivo.h"#include "vidro_wuc.h"#include "../menu/context_menu.h"@@ -442,7 +443,7 @@ std::wstring When(long long ft) {IDWriteTextFormat* Fmt(float size, DWRITE_FONT_WEIGHT w, const wchar_t* family = nullptr, bool wrap = false) {IDWriteTextFormat* tf = nullptr;- if (family) ui::dw->CreateTextFormat(family, nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf);+ if (family) cjk::Format(ui::dw, family, nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf);if (!tf) tf = ui::Format(size, w);if (!tf) return nullptr;tf->SetWordWrapping(wrap ? DWRITE_WORD_WRAPPING_WRAP : DWRITE_WORD_WRAPPING_NO_WRAP);diff --git a/src/shell/sobre.cpp b/src/shell/sobre.cppindex ba91db7..9092f6d 100644--- a/src/shell/sobre.cpp+++ b/src/shell/sobre.cpp@@ -5,6 +5,7 @@// (rótulos alinhados à direita), botão "Mais Informações…" e o rodapé de direitos.// Vidro desfocado atrás (backdrop.cpp), como as outras janelas do Shell.#include "shell.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <dwmapi.h>#include <algorithm>#include <cmath>@@ -151,7 +152,7 @@ void Text(ID2D1DeviceContext* dc, ID2D1SolidColorBrush* br, const std::wstring&DWRITE_TEXT_ALIGNMENT al, D2D1_RECT_F r, D2D1_COLOR_F c, bool underline = false, bool display = false) {IDWriteTextFormat* tf = nullptr;if (display) { // nome grande: SF Pro Display (mais justa que a Text nos tamanhos grandes)- if (SUCCEEDED(ui::dw->CreateTextFormat(L"SF Pro Display", nullptr, wgt, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf)))+ if (SUCCEEDED(cjk::Format(ui::dw, L"SF Pro Display", nullptr, wgt, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf)))tf->SetTextAlignment(al);} else tf = ui::Format(size, wgt, false, al);if (!tf) return;diff --git a/src/shell/ui.cpp b/src/shell/ui.cppindex 66937a6..097a84d 100644--- a/src/shell/ui.cpp+++ b/src/shell/ui.cpp@@ -1,6 +1,7 @@// Desenho comum do shell: Direct2D numa DIB de 32 bits (como o menu de contexto), acrílico,// fontes e os ícones próprios (pasta azul do Arquivos, lixeira).#include "shell.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <shlobj.h>#include <shobjidl.h>#include <wincodec.h>@@ -45,7 +46,7 @@ bool ui::Init() {for (const std::wstring& f : { fam, ic, std::wstring(L"SF Pro Display"), std::wstring(L"SF Pro Rounded"), std::wstring(L"Segoe UI") })for (DWRITE_FONT_WEIGHT w : { DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_WEIGHT_MEDIUM, DWRITE_FONT_WEIGHT_SEMI_BOLD, DWRITE_FONT_WEIGHT_BOLD }) {IDWriteTextFormat* tf = nullptr;- if (FAILED(dw->CreateTextFormat(f.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"", &tf)) || !tf) continue;+ if (FAILED(cjk::Format(dw, f.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 13, L"", &tf)) || !tf) continue;IDWriteTextLayout* tl = nullptr;const wchar_t txt[] = L"Ag 0123 \xE7B8\xE8C8\xE73E\xE7C3";if (SUCCEEDED(dw->CreateTextLayout(txt, (UINT32)wcslen(txt), tf, 400, 40, &tl)) && tl) {@@ -722,7 +723,7 @@ void ui::Acrylic(HWND h, DWORD tint) {IDWriteTextFormat* ui::Format(float size, DWRITE_FONT_WEIGHT w, bool icons, DWRITE_TEXT_ALIGNMENT a) {IDWriteTextFormat* tf = nullptr;- dw->CreateTextFormat((icons ? iconFamily : family).c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL,+ cjk::Format(dw, (icons ? iconFamily : family).c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL,DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf);tf->SetTextAlignment(a);tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);@@ -732,7 +733,7 @@ IDWriteTextFormat* ui::Format(float size, DWRITE_FONT_WEIGHT w, bool icons, DWRIIDWriteTextFormat* ui::FormatFace(const wchar_t* face, float size, DWRITE_FONT_WEIGHT w) {IDWriteTextFormat* tf = nullptr;- if (FAILED(dw->CreateTextFormat(face, nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf)) || !tf)+ if (FAILED(cjk::Format(dw, face, nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf)) || !tf)return Format(size, w);tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);tf->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);diff --git a/src/shell/widgets.cpp b/src/shell/widgets.cppindex 6cc1c77..2ce5663 100644--- a/src/shell/widgets.cpp+++ b/src/shell/widgets.cpp@@ -6,6 +6,7 @@// O tempo vem do Open-Meteo (sem chave), a cada 15 min, para a cidade em ajustes.txt (padrão: a do fuso do Windows, comum/cidade_padrao.h);// a última resposta fica em %APPDATA%\Shell\tempo.json para aparecer já ao ligar.#include "shell.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include "../comum/cidade_padrao.h"#include "../menu/context_menu.h"#include <dwmapi.h>@@ -218,7 +219,7 @@ const D2D1_COLOR_F WHITE = { 1, 1, 1, 1 }, ORANGE = { 1, 0.584f, 0, 1 }, RED = {void Txt(ID2D1DeviceContext* dc, ID2D1SolidColorBrush* br, const std::wstring& s, float size, DWRITE_FONT_WEIGHT wgt,DWRITE_TEXT_ALIGNMENT al, D2D1_RECT_F r, D2D1_COLOR_F c, bool display = false) {IDWriteTextFormat* tf = nullptr;- if (FAILED(ui::dw->CreateTextFormat(display ? L"SF Pro Display" : ui::family.c_str(), nullptr, wgt, DWRITE_FONT_STYLE_NORMAL,+ if (FAILED(cjk::Format(ui::dw, display ? L"SF Pro Display" : ui::family.c_str(), nullptr, wgt, DWRITE_FONT_STYLE_NORMAL,DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf)) || !tf) return;tf->SetTextAlignment(al);tf->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);@@ -229,7 +230,7 @@ void Txt(ID2D1DeviceContext* dc, ID2D1SolidColorBrush* br, const std::wstring& s}float Width(const std::wstring& s, float size, DWRITE_FONT_WEIGHT wgt, bool display = false) {IDWriteTextFormat* tf = nullptr;- if (FAILED(ui::dw->CreateTextFormat(display ? L"SF Pro Display" : ui::family.c_str(), nullptr, wgt, DWRITE_FONT_STYLE_NORMAL,+ if (FAILED(cjk::Format(ui::dw, display ? L"SF Pro Display" : ui::family.c_str(), nullptr, wgt, DWRITE_FONT_STYLE_NORMAL,DWRITE_FONT_STRETCH_NORMAL, size, L"pt-br", &tf)) || !tf) return 0;float w = ui::TextWidth(tf, s);tf->Release();diff --git a/src/terminal/main.cpp b/src/terminal/main.cppindex 80d4969..3632a97 100644--- a/src/terminal/main.cpp+++ b/src/terminal/main.cpp@@ -11,6 +11,7 @@#define WIN32_LEAN_AND_MEAN#define NOMINMAX#include <windows.h>+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include <windowsx.h>#include <d2d1.h>#include <dwrite.h>@@ -438,7 +439,7 @@ void MakeFonts() {g_mono = PickFont({ L"SF Mono", L"Menlo", L"Cascadia Mono", L"Consolas" }, L"Consolas");g_ui = PickFont({ L"SF Pro Text", L"Inter", L"Segoe UI Variable Text" }, L"Segoe UI");auto mk = [&](const std::wstring& fam, float sz, DWRITE_FONT_WEIGHT w, IDWriteTextFormat** out) {- g_dw->CreateTextFormat(fam.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, sz, L"pt-br", out);+ cjk::Format(g_dw, fam.c_str(), nullptr, w, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, sz, L"pt-br", out);(*out)->SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);};mk(g_mono, FONT_PT * 96 / 72.f, DWRITE_FONT_WEIGHT_NORMAL, &g_tfMono);diff --git a/src/textedit/main.cpp b/src/textedit/main.cppindex b82faf3..cf0474e 100644--- a/src/textedit/main.cpp+++ b/src/textedit/main.cpp@@ -3,6 +3,7 @@// Ctrl+N novo (outra janela), Ctrl+O abrir, Ctrl+S salvar, Ctrl+Shift+S salvar como, Ctrl+Shift+T texto simples// / formatado, Ctrl+B/I/U, Ctrl+W fechar (pergunta se há alterações). Título: nome — Editado.#include "../comum/app2d.h"+#include "../comum/fonte_cjk.h" // a reserva para coreano, japonês e chinês#include "../menu/context_menu.h"#include <richedit.h>#include <shobjidl.h>@@ -547,13 +548,13 @@ int WINAPI wWinMain(HINSTANCE hi, HINSTANCE, PWSTR, int show) {g_tfBtn = Fmt(12.5f, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_TEXT_ALIGNMENT_CENTER);g_tfIcon = Fmt(13, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_TEXT_ALIGNMENT_CENTER, false, IconFamily());g_tfB = Fmt(14, DWRITE_FONT_WEIGHT_BOLD, DWRITE_TEXT_ALIGNMENT_CENTER, false, L"Georgia");- g_tfI = nullptr; dw->CreateTextFormat(L"Georgia", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_ITALIC, DWRITE_FONT_STRETCH_NORMAL, 14, L"", &g_tfI);+ g_tfI = nullptr; cjk::Format(dw, L"Georgia", nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_ITALIC, DWRITE_FONT_STRETCH_NORMAL, 14, L"", &g_tfI);if (g_tfI) { g_tfI->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); g_tfI->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); }g_tfU = Fmt(14, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_TEXT_ALIGNMENT_CENTER, false, L"Georgia");g_tfTitleG = Fmt(13, DWRITE_FONT_WEIGHT_BOLD);g_tfCtl = Fmt(12.5f, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_TEXT_ALIGNMENT_CENTER);g_tfCtlB = Fmt(12.5f, DWRITE_FONT_WEIGHT_BOLD, DWRITE_TEXT_ALIGNMENT_CENTER);- g_tfCtlI = nullptr; dw->CreateTextFormat(family.c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_ITALIC, DWRITE_FONT_STRETCH_NORMAL, 12.5f, L"", &g_tfCtlI);+ g_tfCtlI = nullptr; cjk::Format(dw, family.c_str(), nullptr, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_ITALIC, DWRITE_FONT_STRETCH_NORMAL, 12.5f, L"", &g_tfCtlI);if (g_tfCtlI) { g_tfCtlI->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); g_tfCtlI->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); }g_tfRuler = Fmt(9.5f);barWanted = 32; // macOS 27: a barra de título é do app (o nome à esquerda, com o ícone)