Skip to content

Add missing sk_fontmgr_legacy_create_typeface C API - #198

Merged
mattleibow merged 1 commit into
skiasharpfrom
dev/fix-missing-legacy-api
Apr 25, 2026
Merged

Add missing sk_fontmgr_legacy_create_typeface C API#198
mattleibow merged 1 commit into
skiasharpfrom
dev/fix-missing-legacy-api

Conversation

@mattleibow

@mattleibow mattleibow commented Apr 25, 2026

Copy link
Copy Markdown
Collaborator

Context

What happened

During the review of PR #195, the sk_fontmgr_legacy_create_typeface function was added
in a separate commit (e6736d19f) pushed to a local branch (dev/issue-3693-legacy-typeface)
on mono/skia — but this commit was not pushed to the PR author's fork branch. When PR #195
was squash-merged, only the commits on the fork's branch were included. The separately pushed
commit was left behind, so the function that the PR was named after was never actually merged.

This was a process error: the fix should have been pushed to the PR branch (on the author's
fork) before merging, not to a separate branch on the upstream repo.

Fix

This PR cherry-picks commit e6736d19f23da0746c4291ed7223e69ffbce3ac1 onto skiasharp to
add the missing function.

What the function does

sk_fontmgr_legacy_create_typeface exposes SkFontMgr::legacyMakeTypeface() to the C API.
It is needed by SkiaSharp's SKTypeface.Default to reliably resolve the platform default
typeface on Android, where matchFamilyStyle(null) returns null because onMatchFamily(null)
rejects null family names. legacyMakeTypeface(null) bypasses this by using fDefaultStyleSet
(which searches "sans-serif", "Roboto", then falls back to style set 0).

Without this function, SKTypeface.Default falls back to the empty typeface on Android API 36,
causing all text measurement and drawing to produce zero/nothing.

Exposes SkFontMgr::legacyMakeTypeface() to the C API for reliable
default typeface resolution on Android, where matchFamilyStyle(null)
returns null but legacyMakeTypeface(null) uses fDefaultStyleSet.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mattleibow
mattleibow merged commit f534546 into skiasharp Apr 25, 2026
1 check passed
@mattleibow
mattleibow deleted the dev/fix-missing-legacy-api branch April 25, 2026 21:38
mattleibow added a commit to mono/SkiaSharp that referenced this pull request Apr 25, 2026
Includes sk_fontmgr_legacy_create_typeface C API from mono/skia#198.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
mattleibow added a commit to mono/SkiaSharp that referenced this pull request Apr 25, 2026
Updates submodule from fb76f3dd84 to f5345469d1 (mono/skia#198).
Adds the sk_fontmgr_legacy_create_typeface C API that was missing
from the squash merge of mono/skia#195.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ramezgerges added a commit to ramezgerges/skia that referenced this pull request Apr 26, 2026
Brings in the latest mono/skia 'skiasharp' branch updates on top of the
m147 work-in-progress:

  * Add variable font C API for typeface variation queries and cloning (mono#185)
  * Add sk_fontmgr_legacy_create_typeface C API (mono#198, mono#195) — replaces
    the old sk_default_fontmgr.{cpp,h} with a single C entry point that
    forwards to SkFontMgr::legacyMakeTypeface(). Fixes the Android
    default-typeface SIGSEGV.
  * Use int32_t instead of long for SkManagedStream move offset
    (mono#186) — fail-loud on overflow instead of silent truncation
    of platform-dependent C long.
  * Update libpng to 1.6.58
  * Update libexpat to 2.7.5

Conflict resolutions:
  - DEPS: keep m147's freetype roll, take origin/skiasharp's libexpat 2.7.5
    (and libpng 1.6.58 auto-merged the same way).
  - src/c/sk_default_fontmgr.cpp: accept origin/skiasharp's deletion;
    their legacyMakeTypeface refactor obviates our m147 carry of that file.
  - src/c/sk_typeface.cpp: re-apply our m139 SkFontScanner fix to the
    Android and FontConfig SkFontMgr_New_* call sites, which moved into
    this file as part of their refactor.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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