Skip to content

GraphiteQuickDraw and GraphiteText: cursor state, palettes, file icons, font tables; ContiguousBytes input; swift-freetype - #23

Merged
colemancda merged 60 commits into
masterfrom
feature/cursor
Nov 26, 2026
Merged

colemancda merged 60 commits into
masterfrom
feature/cursor

Conversation

@colemancda

Copy link
Copy Markdown
Member

Summary

Fills in the QuickDraw, pictures, icons, fonts and cursors survey, and moves byte input to ContiguousBytes.

GraphiteQuickDraw

  • Cursor state: InitCursor, SetCursor, HideCursor and ShowCursor (nesting), and named pixel-map cursors; kept on QuickDraw.cursor.
  • Palette Manager: Palette and its entries, usage and tolerance, CopyPalette; and Index2Color, SetEntries, RestoreDeviceClut and CTabChanged on devices and color tables.
  • IconFamily(ofItemAt:): the icon an item has of its own: an .icns file, a custom icon (ID -16455) in its resource fork, a bundle's CFBundleIconFile, or a folder's Icon\r. GraphiteQuickDraw now depends on GraphiteFiles and GraphiteResources.

GraphiteResources

  • InfoPlist: top-level strings of an Info.plist, XML or binary, through Foundation's property list reader.
  • Fork.contents() returns Data, mapped into memory when a data fork is opened read-only.
  • ResourceFile holds its bytes as Data, so a mapped resource file is parsed in place and resources are copied out as asked for.

GraphiteText

  • FontFace gains table(_:) and horizontalMetrics (ATS's ATSFontGetTable and ATSFontGetHorizontalMetrics).
  • SfntTables reads an sfnt's directory (collections included) and the fields of head, hhea, OS/2 and post, in place.
  • FreeTypeFace is built on swift-freetype (master branch); the CFreeType target is removed. Tables, styles and the extra metrics are read from the font's bytes, since the wrapper doesn't expose them.

Byte input

  • Parsers take some ContiguousBytes (arrays, Data, slices, raw buffers): IconFamily, ColorTable, ResourceMap, ResourceFile, StringList, VersionResource, AppleDouble, Picture, PackBits, Region, Polygon, Cursor, ColorIcon, FreeTypeFace. Existing [UInt8] callers are source-compatible.
  • BigEndianReader stores Data and reads it where it is; readBytes now returns a Data slice.

Notes for review

  • One commit per file. Two commits don't build on their own, because the next commit completes the change: 996bcc1 (BigEndianReader on Data; fixed by 3c5eac5) and 06368d7 (the package change; fixed by 2dcd004).
  • swift-freetype is a branch dependency (branch: "master"), so a package that depends on Graphite by version can't use it until that is pinned or tagged.
  • A mapped read-only fork is a live view of the file, not a snapshot; truncating the file while it is held can crash a later read. Fork.contents() documents this.
  • Info.plist reading now uses Foundation, so binary plists work and malformed ones throw paramErr.

Testing

  • Built and ran all 362 tests in Xcode on macOS: all pass (including the FreeType and font-table tests, which need a font on the machine).
  • Linux and the build without the FreeType trait are left to CI.

@colemancda
colemancda merged commit 407a29e into master Nov 26, 2026
3 checks 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