Skip to content

The built-in font follows the metric scale too - #216

Merged
tannevaled merged 1 commit into
mainfrom
feat/text-follows-scale
Aug 16, 2026
Merged

The built-in font follows the metric scale too#216
tannevaled merged 1 commit into
mainfrom
feat/text-follows-scale

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

The metric audit measures chrome, not text — deliberately, since a centred baseline rounds and type carries its own scale. That left a gap it could not see: a host that turned the one documented HiDPI knob got padding, borders and controls at twice the size around type that stayed exactly as it was. Not a partial improvement — a worse interface than the one it had before it asked.

The rule, which the toolkit already had

activeFont is now nil until a host sets one, and nil means "the built-in bitmap at the current metric scale" rather than "the built-in bitmap at 1". A font the host chose is left alone, because a host that chose a font chose its size.

That is the same rule Menu and Browser follow for their own Scale fields (#209), and for the same reason: one scale, set in one place, never applied twice.

SetFont untouched SetFont(NewBitmapFont(3))
MetricScale() == 1 7px glyph 21px
MetricScale() == 2 14px 21px, not 42

The bitmap is a block rasteriser, so the scale rounds to a whole multiple: 1.4 draws the plain font and 1.6 the doubled one, because half a block is not a glyph. The scaled font is cached — text is measured per glyph per frame, and allocating one each time would be a new object sixty times a second.

🤖 Generated with Claude Code

The audit measures chrome and not text -- deliberately, since a centred baseline
rounds and type carries its own scale -- and that left a gap it could not see. A
host that turned the one documented HiDPI knob got padding, borders and controls
at twice the size around type that stayed exactly as it was. Not a partial
improvement: a worse interface than the one it had before it asked.

activeFont is now nil until a host sets one, and nil means "the built-in bitmap
at the current metric scale" rather than "the built-in bitmap at 1". A font the
host chose is left alone, because a host that chose a font chose its size -- the
same rule Menu and Browser already follow for their own Scale fields, and the
same reason: one scale, set in one place, never applied twice.

The bitmap is a block rasteriser, so the scale rounds to a whole multiple: 1.4
draws the plain font and 1.6 the doubled one, because half a block is not a
glyph. The scaled font is cached, since text is measured per glyph per frame and
allocating one each time would be a new object sixty times a second.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tannevaled
tannevaled merged commit dccf6be into main Aug 16, 2026
1 check passed
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.

1 participant