Skip to content

feat: replace Japanese font with BIZ UDP Gothic and fix CJK glyph pri… - #49

Open
tosakax2 wants to merge 4 commits into
Blue-Protocol-Source:masterfrom
tosakax2:improve-japanese-font
Open

tosakax2 wants to merge 4 commits into
Blue-Protocol-Source:masterfrom
tosakax2:improve-japanese-font

Conversation

@tosakax2

Copy link
Copy Markdown

Summary of Changes

This PR improves Japanese text rendering across the UI and damage meter while ensuring existing Chinese glyph variants remain intact for non-Japanese users.

1. Replaced Japanese Fallback Font

  • Added BIZ UDP Gothic (BIZUDPGothic-Regular.ttf, SIL Open Font License by Morisawa) as an embedded resource.
  • Merged at 13.5f to match the cap-height of Segoe UI (18f) and Cascadia Mono (18f), resolving the oversized Japanese text and the stretched/thin kana in the meter.
  • Enabled GlyphOffset assignment in FontFile.BindToImGui() for proper baseline alignment.

2. Language-Sensitive CJK Glyph Priority

Because ImGui resolves glyph collisions using the first-loaded font:

  • When Language == "ja": BIZ UDP Gothic is merged first (Japanese glyph variants take priority), with SourceHanSansSC / CascadiaNextSC as fallback for remaining Chinese-only glyphs.
  • For all other languages (zh, en, etc.): SourceHanSansSC / CascadiaNextSC are merged first (Simplified Chinese glyph variants take priority), with BIZ UDP Gothic as fallback for kana and remaining glyphs.

3. Renderer & Module Consistency

  • Applied identical font loading and priority logic to both Program.cs and OffscreenImGuiRenderer.cs.
  • Added missing using BPSR_ZDPS.DataTypes; to OffscreenImGuiRenderer.cs.

Note: Font merge order is determined at application startup based on the saved language setting. Changing language in Settings requires a restart for the updated font priority to take effect.

…ority by language

Previously, Japanese UI text was rendered using SourceHanSansSC (a Simplified Chinese
font), causing Japanese characters to appear in Chinese glyph variants. Additionally,
the meter font (Cascadia Mono) used a terminal-style Japanese font (CascadiaNextJP)
that resulted in wide, thin kana and kanji that clashed with the English text style.

Changes:
- Add BIZUDPGothic-Regular.ttf as an embedded font resource
- Use BIZ UDP Gothic (SIL Open Font License) as the Japanese font, merged at 13.5f to
  match the cap-height of Segoe UI (18f) and Cascadia Mono (18f)
- Enable GlyphOffset support in FontFile.BindToImGui() for baseline alignment
- Make CJK font merge order language-sensitive in both LoadFonts() calls:
  - Language ja: BIZ UDP Gothic merged first (Japanese glyph variants take priority),
    Source Han Sans SC as fallback
  - All other languages (zh, en, etc.): Source Han Sans SC merged first (Simplified
    Chinese glyph variants take priority), BIZ UDP Gothic as fallback
- Apply the same priority logic to the Cascadia-Mono meter font merge
- Add missing using BPSR_ZDPS.DataTypes directive to OffscreenImGuiRenderer.cs

Note: font priority is evaluated once at startup; a restart is required after changing
the language setting for the new font order to take effect.
@ThiconZ

ThiconZ commented Aug 25, 2026

Copy link
Copy Markdown
Member

Can you please provide example text along with screenshots of before and after the change to demonstrate it?

@tosakax2

Copy link
Copy Markdown
Author

Here are the comparison screenshots demonstrating the visual fixes (Top: Before, Bottom: After):


スクリーンショット 2026-08-25 234731

When Language is set to ja, the Japanese font is prioritized for shared glyphs, while Simplified Chinese-only characters fall back to the Chinese font. Other language settings maintain Chinese priority as before.


スクリーンショット 2026-08-25 230249

Compared to the English text, the Japanese font rendered significantly too large, causing line-height congestion and visual imbalance across the UI. Merging at 13.5f resolves these spacing issues and restores proper UI balance.


スクリーンショット 2026-08-25 235504

Sample Text Used for Verification

国語の永田先生がミーティングに20分遅れてきた。あきらかに気まずそうな顔をしている。通勤前にBOOK CAFÉに立ち寄ったら、居心地が良くて時間を忘れてしまったそうだ。先生は本を読むことが好きで、特に夏目漱石を尊敬しているらしい。

I love youを「月が綺麗ですね」と訳した話をよくしてくれる。そして決まって最後に「もっと愛の表現を知りたい」と呟く。

いろはにほへとちりぬるをわかよたれそつねならむうみのおくやまけふこえてあさきゆめみしゑひもせず色はにほへど散りぬるを我が世たれぞ常ならむ有為の奥山今日越えて浅き夢見じ酔ひもせず

textは編集することができます。

ティナ、墓、巨塔M4 H1募集

@ThiconZ

ThiconZ commented Aug 27, 2026

Copy link
Copy Markdown
Member

Is it possible to use a monospace version of this font?

There are two types of fonts currently used throughout ZDPS, Monospace and Proportional. Monospace fonts are used in select areas to provide consistent UI spacing and allow calculation shortcuts to improve performance without risking inconsistent UI spacing. The Proportional fonts are used in the rest of ZDPS when we don't need to worry about the consistent spacing or performance optimizations as much and want to provide a smoother reading experience in large quantities of text such as the Settings menu.

Your changes are currently using this Proportional font in both Monospace and Proportional atlases.

BIZUDPGothic-Regular.ttf (proportional) was incorrectly being merged
into the Cascadia-Mono monospace atlas for Japanese glyphs. Other CJK
languages consistently use their monospace counterparts (CascadiaNextSC,
CascadiaNextTC, D2Coding) in this atlas.

Changes:
- Add BIZUDGothic-Regular.ttf as an embedded font resource
- Use BIZUDGothic-Regular.ttf (monospace) instead of BIZUDPGothic-Regular.ttf
  (proportional) when merging Japanese glyphs into the Cascadia-Mono atlas,
  in both Program.cs and OffscreenImGuiRenderer.cs
- BIZUDPGothic-Regular.ttf (proportional) remains in use for the Segoe
  proportional atlas, as intended
@tosakax2

Copy link
Copy Markdown
Author

Thanks for pointing that out! That makes complete sense.

I have updated the implementation to use BIZ UD Gothic (BIZUDGothic-Regular.ttf, the monospace version) for the Cascadia-Mono atlas, while keeping BIZ UDP Gothic (BIZUDPGothic-Regular.ttf, the proportional version) for the Segoe atlas.

スクリーンショット 2026-08-28 101309

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants