Skip to content

Commit

Permalink
Make an HBFont from a CTFontRef.
Browse files Browse the repository at this point in the history
By including ```rive/text/font_hb.hpp``` in iOS you'll get access to ```HBFont::FromSystem``` along with the ```HBFont::Decode``` (which we've been using so far to generate Font objects to put into the fallback list).

You can get a UIFont with [this API](https://developer.apple.com/documentation/uikit/uifont/1619027-systemfontofsize?language=objc).

You should be able to cast that to a CTFontRef:
```
CTFontRef ctFont = (__bridge CTFontRef)uiFont;
auto fallbackFont = HBFont::FromSystem((void*)ctFont);
```

You can then use that in a fallback font procedure (like the example from the editor below) to load on demand/cache/provide from a list etc:
https://github.com/rive-app/rive/blob/b5b930f88f18280afa44683c5756066abaa9b1dc/packages/rive_common/macos/rive_text/rive_text.cpp#L153-L175

Diffs=
da1bb7745 Make an HBFont from a CTFontRef. (#7661)
  • Loading branch information
luigi-rosso committed Jul 25, 2024
1 parent c1f4034 commit 2e3e21e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1a5f273bb6534a395d1c3cdcc11a1ba3cd80a96c
da1bb77455deeafd48012a8eea5ea946a718fb77
2 changes: 1 addition & 1 deletion .rive_renderer
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5877f25dc1e16f4f779c410dbb3449e356130e4e
3c057fe4e09442e99a1468e48da297d84aaaca6e
2 changes: 1 addition & 1 deletion submodules/rive-cpp

0 comments on commit 2e3e21e

Please sign in to comment.