Skip to content

Latest commit

 

History

History
348 lines (337 loc) · 49.1 KB

CoreText.md

File metadata and controls

348 lines (337 loc) · 49.1 KB

CoreText

Symbols: 24.1% of Apple's iOS API (534 of 2213, exact) · Rows: 20: 13 ✅ 6 🟡 1 ❌ · iOS: 3.2+

Area: Graphics & text · Apple: CoreText · Issues: area:graphics

How isim implements it

  • Adapted: isim's own implementation (isim/frameworks/CoreText) over fontconfig, HarfBuzz and Pango.

API

API / feature Status iOS Notes
CTFont by name, size, names, metrics, character set ✅ ≤17 adapted: fontconfig picks the face; metrics (ascent, descent, leading, cap / x height, underline, bounding box, units per em, glyph count, slant angle) are read from that font file with HarfBuzz; CTFontCopyName; a UIFont works as a CTFont. Unknown names fall back to the system font; iOS font names missing on the host keep their weight/slant on the substitute (and their name). Tested (HelloCoreText, HelloQuartz)
CTFontManager: RegisterFontsForURL / UnregisterFontsForURL, RegisterFontURLs / UnregisterFontURLs, RegisterGraphicsFont / UnregisterGraphicsFont, CreateFontDescriptorsFromData / FromURL, CreateFontDescriptorFromData, CTFontManagerError, kCTFontManagerErrorDomain, kCTFontManagerErrorFontURLsKey ✅ ≤17 adapted: fonts are added to fontconfig for this process (any scope); errors for a missing file (101), a file that is not a font (103), a second registration (105) and an unregistered font (201); the URL handler is called once, done; descriptors from data (every face of a collection) make the data usable by name without listing it among the app's fonts; unregistering only forgets a font (fontconfig cannot remove one); tested (HelloCoreText, test_coretext)
CTFontCopyTable, CTFontCopyAvailableTables, CTFontTableTag (kCTFontTable…), CTFontTableOptions ✅ ≤17 passthrough: the tables of the face's file through HarfBuzz; tested (HelloCoreText)
CTFontCopyVariationAxes, CTFontCopyVariation, kCTFontVariationAxis…Key 🟡 ≤17 adapted: the axes of the face's fvar table (tag, minimum, maximum, default, name, hidden); tested (HelloCoreText, Adwaita Sans). Missing: isim draws a variable font's default instance (kCTFontVariationAttribute is not in isim yet), so CTFontCopyVariation reports the defaults
CTFontCreateForString, CTFontCreateForStringWithLanguage ✅ ≤17 adapted: the font itself when it covers the start of the range, else the font the host's Pango falls back to for it; tested (HelloCoreText, emoji)
String attributes (CTStringAttributes.h): kCTTrackingAttributeName, kCTLigatureAttributeName, kCTSuperscriptAttributeName, kCTUnderlineColorAttributeName, kCTLanguageAttributeName, CTUnderlineStyle, CTUnderlineStyleModifiers 🟡 ≤17 adapted through Pango markup: tracking is letter spacing between characters; ligatures 0 turns off the standard ligatures, 2 adds discretionary ones; superscript / subscript use Pango's baseline shift and scale; the language drives shaping and fallback; tested (HelloCoreText). Missing: thick underlines and the dot / dash patterns are drawn as single solid underlines (Pango has neither)
kCTStrokeWidthAttributeName, kCTStrokeColorAttributeName ✅ ≤17 adapted: the outlines of the run's glyphs stroked over the line at width percent of the font size, in the stroke color (else the foreground color); a positive width hides the fill, a negative one keeps it; tested (HelloCoreText pixels)
CTFontDescriptor, symbolic traits, font features ✅ ≤17 adapted: descriptors are attribute dictionaries (name, family, style name, size, traits with weight / width / slant, feature settings, file URL) resolved through fontconfig; matching descriptors list the family's installed faces (closest first; mandatory attributes filter). Traits: bold, italic, condensed / expanded set the face asked for (fontconfig synthesizes a missing bold or oblique); monospace and colour glyphs are read from the face. Glyphs, advances, bounding rects and outlines (CTFontCreatePathForGlyph) come from the font file (HarfBuzz), CTFontDrawGlyphs draws through Pango. Features: OpenType tags go to the shaper; AAT type/selector pairs map to their OpenType features (ligatures, number spacing and case, fractions, vertical position, slashed zero, case-sensitive forms, small / petite caps, contextual and swash alternates, stylistic sets); exclusive types replace earlier settings; CTFontCopyFeatures lists the types whose features the font has. Tested (HelloCoreText)
CTLine (create, typographic bounds, offsets/indices, truncation, draw) 🟡 ≤17 laid out by Pango (HarfBuzz) at fractional positions; leading and ink bounds from the fonts; truncation by Pango's ellipsis (the truncation token is ignored); CTLineCreateJustifiedLine returns the line unchanged. Tested (HelloCoreText, HelloQuartz)
CTRun (glyphs, positions, advances, string indices, attributes) ✅ ≤17 adapted: runs are Pango's glyph items (one per font, direction and attribute change) in string order; glyph ids are those of the face Pango used, and the run's kCTFontAttributeName is that font (a fallback font for characters the requested one lacks, the 12 pt system font when none was set); right-to-left / non-monotonic status; UTF-16 string indices; base advances and origins; metrics of the run's font; ink bounds; CTRunDraw of a glyph range. A line redrawn from its runs with CTFontDrawGlyphs matches CTLineDraw. kCTRunDelegateAttributeName (run delegates) is not supported. Tested (HelloCoreText)
CTFramesetter / CTFrame (frames in a path's bounding box, line origins, suggest size) ✅ ≤17 adapted: each paragraph (ended by \n, \r, \r\n or U+2029) is laid out on its own with its paragraph style and isim places the lines (see CTParagraphStyle); rectangular paths only (bounding box). Tested (HelloCoreText, HelloQuartz)
CTParagraphStyle ✅ ≤17 adapted: every specifier is kept and read back (CTParagraphStyleCreateCopy, CTTextTab). Frames apply alignment (natural follows the paragraph's direction), base writing direction, first-line / head / tail indents, tab stops (left, right, center, decimal: the separator centred on the stop) and the default tab interval, line break modes (word, character, clipping, truncation to one line), line height multiple / minimum / maximum, line spacing (adjustment, minimum / maximum, the deprecated fixed spacing) and paragraph spacing before / after (before applies to the first paragraph too). Lines (CTLine) use the tab stops and writing direction. UIKit's NSParagraphStyle is read the same way. Line bounds options are stored only. Tested (HelloCoreText)
CTTypesetter: CreateWithAttributedString (with options), SuggestLineBreak / SuggestClusterBreak (with offset), CreateLine (with offset); CTFramesetterCreateWithTypesetter, CTFramesetterGetTypesetter ✅ ≤17 adapted: the paragraph from the start index laid out by Pango at the width, broken at words (characters when a word does not fit) or at grapheme clusters; a line's length includes its trailing whitespace and the paragraph separator; the offset and kCTTypesetterOption… are accepted and ignored; tested (HelloCoreText)
CTRunDelegate, CTRunDelegateCallbacks, kCTRunDelegateAttributeName ✅ ≤17 adapted: each character the attribute covers takes the delegate's width, ascent and descent (a Pango shape), so lines, runs and frames make room for it, and draws nothing; the dealloc callback runs when the delegate is released; tested (HelloCoreText)
CTRubyAnnotation (Create, CreateWithAttributes, CreateCopy, getters), CTRubyAlignment / Overhang / Position, kCTRubyAnnotationAttributeName, kCTRubyAnnotationSizeFactorAttributeName 🟡 ≤17 adapted: CTLineDraw / CTFrameDraw draw the before (over) and after (under) ruby of each annotated range at its size factor of the base font (default 0.5), aligned start, end or centered; tested (HelloCoreText). Missing: the line's metrics leave no room for the ruby, overhang and ScaleToFit are ignored, inter-character and inline ruby are not drawn
CTGlyphInfo (by glyph name, glyph, character identifier; getters), CTCharacterCollection, kCTGlyphInfoAttributeName; CTFontGetGlyphWithName, CTFontCopyNameForGlyph 🟡 ≤17 adapted: glyph names from the font's post table / CFF charset through HarfBuzz; tested (HelloCoreText). Missing: laying out text does not substitute the glyph info's glyph
CTFontCollection: CreateFromAvailableFonts, CreateWithFontDescriptors, CreateCopyWithFontDescriptors, CreateMatchingFontDescriptors (sorted with a callback, with options), CopyFontAttribute(s), CTFontCollectionCopyOptions, kCTFontCollectionRemoveDuplicatesOption ✅ ≤17 adapted: every face fontconfig lists (by family, then PostScript name), or the faces each query descriptor matches with its name, style and traits mandatory; tested (HelloCoreText)
CTLineCreateJustifiedLine, CTLineEnumerateCaretOffsets ✅ ≤17 adapted: the line laid out again by Pango, justified (the last line too) to its natural width plus the factor (at most 1) of what is missing; caret offsets are each character's leading and trailing edges in string order (a cluster's characters share them); tested (HelloCoreText)
CTFrameGetFrameAttributes, CTFrameProgression, CTFramePathFillRule, kCTFrame…AttributeName 🟡 ≤17 adapted: the frame's attributes are kept and returned; isim lays out top to bottom in the path's bounding box whatever the progression, fill rule or clipping paths
Types not yet in isim (iOS 17 and earlier) ❌ ≤17 not implemented, found by the 2026-10 sweep: AnchorPoint, AnchorPointTable, AnkrTable, BslnFormat0Part, BslnFormat1Part, BslnFormat2Part, BslnFormat3Part, BslnFormatUnion, BslnTable, CTAdaptiveImageProviding, CTFontCollection, CTFontDescriptorMatchingState, CTFontManagerAutoActivationSetting, CTGlyphInfo, CTRubyAnnotation, CTRunDelegate, CTTypesetter, FontVariation, JustDirectionTable, JustPCAction, JustPCActionSubrecord, JustPCConditionalAddAction, JustPCDecompositionAction, JustPCDuctilityAction, JustPCGlyphRepeatAddAction, JustPostcompTable, JustTable, JustWidthDeltaEntry, JustWidthDeltaGroup, KernFormatSpecificHeader, KernIndexArrayHeader, KernKerningPair, KernOffsetTable, KernOrderedListEntry, KernOrderedListHeader, KernSimpleArrayHeader, KernStateEntry, KernStateHeader, KernSubtableHeader, KernTableHeader, KernVersion0Header, KernVersion0SubtableHeader, KerxAnchorPointAction, KerxControlPointAction, KerxControlPointEntry, KerxControlPointHeader, KerxCoordinateAction, KerxFormatSpecificHeader, KerxIndexArrayHeader, KerxKerningPair, KerxOrderedListEntry, KerxOrderedListHeader, KerxSimpleArrayHeader, KerxStateEntry and 69 more (126 types; with their members under "Not yet in isim")

Not yet in isim

1679 symbols Apple documents for iOS that isim does not have (exact; Apple snapshot 2026-10-14). Each links to Apple's documentation.

List