-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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) Co-authored-by: Luigi Rosso <[email protected]>
- Loading branch information
1 parent
9f0db02
commit d42be0a
Showing
9 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1a5f273bb6534a395d1c3cdcc11a1ba3cd80a96c | ||
da1bb77455deeafd48012a8eea5ea946a718fb77 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "rive/text_engine.hpp" | ||
|
||
#ifdef WITH_RIVE_TEXT | ||
#include "rive/text/font_hb.hpp" | ||
#import <CoreText/CoreText.h> | ||
|
||
#include "hb-coretext.h" | ||
|
||
rive::rcp<rive::Font> HBFont::FromSystem(void* systemFont) | ||
{ | ||
auto font = hb_coretext_font_create((CTFontRef)systemFont); | ||
if (font) | ||
{ | ||
return rive::rcp<rive::Font>(new HBFont(font)); | ||
} | ||
return nullptr; | ||
} | ||
#endif |