Godot's built-in font has no Japanese, so kanji in song names showed as boxes. The theme now sets Godot's own Open Sans SemiBold as its default font, with Noto Sans JP Medium as fallback. The Noto file's line metrics are set to Open Sans's, so line heights stay the same and every other screen is pixel-identical; fonts/README.md explains how to redo it. Search and Sync move right to where the Statistics button was.
32 lines
1.4 KiB
Markdown
32 lines
1.4 KiB
Markdown
# Fonts
|
|
|
|
The theme's default font (`themes/main_theme.tres`) is `OpenSans-SemiBold.woff2`, the
|
|
font Godot uses when a project sets none, saved from Godot so the game looks the same.
|
|
Text it has no letters for, such as Japanese, falls back to `NotoSansJP-Medium.otf`.
|
|
|
|
Both are under the SIL Open Font License, see `OpenSans-LICENSE.txt` and
|
|
`NotoSansJP-LICENSE.txt`.
|
|
|
|
`NotoSansJP-Medium.otf` is the Medium weight from
|
|
[noto-cjk](https://github.com/notofonts/noto-cjk/tree/main/Sans/SubsetOTF/JP), changed in
|
|
one way: its line metrics (`hhea` ascent and descent) are set to Open Sans's. Godot makes
|
|
every line as tall as the tallest font in the fallback chain, so with Noto's own, taller
|
|
metrics all text in the game would move down and rows would grow, even without any
|
|
Japanese on screen. The glyphs are unchanged. To update the font, download it again and
|
|
set the metrics with [fontTools](https://github.com/fonttools/fonttools):
|
|
|
|
```python
|
|
from fontTools.ttLib import TTFont
|
|
|
|
reference = TTFont("OpenSans-SemiBold.woff2") # needs the brotli package
|
|
noto = TTFont("NotoSansJP-Medium.otf")
|
|
scale = noto["head"].unitsPerEm / reference["head"].unitsPerEm
|
|
noto["hhea"].ascent = round(reference["hhea"].ascent * scale)
|
|
noto["hhea"].descent = round(reference["hhea"].descent * scale)
|
|
noto["hhea"].lineGap = 0
|
|
noto.save("NotoSansJP-Medium.otf")
|
|
```
|
|
|
|
`tests/integration/test_theme.gd` checks that Japanese has a font and that the line
|
|
height is still Godot's.
|