Skip to content

Draw and measure text in libQuickDraw - #71

Merged
colemancda merged 20 commits into
masterfrom
feature/quickdraw-text
Dec 3, 2026
Merged

colemancda merged 20 commits into
masterfrom
feature/quickdraw-text

Conversation

@colemancda

Copy link
Copy Markdown
Member

libQuickDraw now draws and measures text. DrawChar, DrawString, DrawText, CharWidth, StringWidth, TextWidth, MeasureText, GetFontInfo and CharExtra replace their stubs (121 of 305 functions implemented).

Behaviour from the Mac

ReferenceTests/Retro68/TextCapture.c ran on Mac OS 9.2.2. It draws in a small NFNT font of its own (TextCapture.r), so the comparison is pixel for pixel without any of Apple's fonts. The test replays it through the C API: 242 of 245 lines match. The three that don't are one pixel at the right edge of bold condensed text, and a few pixels in two pictures shrunk to 9 points. The rules found are listed in ReferenceTests/Retro68/README.md.

Changes beyond the C API

  • GraphiteText's drawing is rewritten to those rules: characters are drawn into a strip, styled, stretched if the face has only another size, then put on the port. The earlier styling had not been measured and was wrong in italic slant, underline, outline with shadow, and scaling. This also changes TextLayout drawing and text in pictures.
  • BitmapFont is new: a face from an NFNT or FONT resource.
  • FontFace gains strikeSize and kerning, both with defaults.
  • libQuickDraw now links GraphiteText, and so FreeType when GRAPHITE_FREETYPE is on, though it doesn't use it yet.

Limits

  • A C program has no way to add a font, so every TextFont draws in the built-in system font: printable ASCII only, with widths unlike Chicago's or Geneva's.
  • Not captured, so chosen without a reference: outline and shadow in the bic and not modes, srcCopy and SpaceExtra at scaled sizes, and where the pen ends after a half-pixel width.

Verification

  • 800 Swift tests pass on macOS.
  • CMake build on macOS: 305 exports as the headers declare; pure.c (26 checks) and drawing.c (47 checks) pass.
  • On Linux the changed targets and their tests compile; the tests were not run there.

@colemancda
colemancda merged commit fea181a into master Dec 3, 2026
3 checks passed
@colemancda
colemancda deleted the feature/quickdraw-text branch December 3, 2026 05:35
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