Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font.loadFont() two or more times with the same font family fails on iOS #149

Closed
gailasgteach opened this issue Mar 7, 2022 · 0 comments
Assignees
Milestone

Comments

@gailasgteach
Copy link

gailasgteach commented Mar 7, 2022

Example project created with https://start.gluon.io/, adding only FXML, no glisten, just add a button with a single FontIcon. Example project can be accessed here: https://asgteach.com/wp-content/uploads/2022/03/myapp.zip
Works with regular JVM (gluonfx:run), as well as native Graal build on Mac OS X desktop. On iOS, the icons don't render.

Gluon has suggested the following to avoid loading the font multiple times:
[from]
https://github.com/kordamp/ikonli/blob/master/core/ikonli-javafx/src/main/java/org/kordamp/ikonli/javafx/IkonResolver.java#L42
[to]

[+]() private static final Map<String, Font> fontMap = new HashMap<>();
    static {
        INSTANCE = new IkonResolver();
        ServiceLoader<IkonHandler> loader = resolveServiceLoader();
        for (IkonHandler handler : loader) {
            HANDLERS.add(handler);
-            handler.setFont(Font.loadFont(handler.getFontResource().toExternalForm(), 16));
+           String fontStr = handler.getFontResource().toExternalForm();
+           handler.setFont(fontMap.computeIfAbsent(fontStr, key -> Font.loadFont(key, 16)));
        }
    }
@aalmiray aalmiray self-assigned this Mar 7, 2022
@aalmiray aalmiray added this to the 12.3.1 milestone Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants