Skip to content
New issue

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

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

Already on GitHub? # to your account

Ikonli material design 2 font not rendered on Javafx native Android application #171

Open
hallvard opened this issue Feb 16, 2025 · 5 comments

Comments

@hallvard
Copy link

My Javafx app at https://github.com/hallvard/halban uses Ikonli and its ikonli-materialdesign2-pack maven artifact for button icons, e.g. arrow triangles, undo/redo and play/pause. These icons show nicely when run normally on Macos (using mvn exec:java) or as a native app built with Gluon's maven plugin (using Graal).

However, in the "same" native Android app (also built with Gluon's plugin and github actions) the icons are rendered as rectangles with diagonal lines inside. The font loading seems OK, at least the icon's -fx-font-family style is correctly set, and there's no exception, so I assume the ttf is located (using a loaded service) and loaded. But for some reason the rendering uses this "placeholder" rectangle (rotation and color is correct), so something is clearly wrong.

BTW, I'm installing and running the app by downloading the apk, not by using the nativerun maven goal (since I don't run Linux I cannot build and run locally).

@aalmiray
Copy link
Collaborator

Have you tried loading the font directly via regular JavaFX APIs in a test app?

@hallvard
Copy link
Author

You mean use Font.loadFont(URL urlStr, double size), set this as the font on a Text and fill it with some characters? I can try and report back.

@aalmiray
Copy link
Collaborator

I suggest using both Text and Label classes.

@hallvard
Copy link
Author

private Tab createFontTestTab() {
    VBox pane = new VBox();
    String fontResource = "/META-INF/resources/materialdesignicons2/5.8.55/fonts/materialdesignicons-webfont.ttf";
    String fastForward = new String(Character.toChars(Integer.parseInt("F0211", 16)));
    try {
      Text textIcons = new Text();
      Label labelIcons = new Label();
      String ttfUrl = getClass().getResource(fontResource).toExternalForm();
      Font font = Font.loadFont(ttfUrl, 16);
      textIcons.setFont(font);
      labelIcons.setFont(font);
      textIcons.setText(fastForward);
      labelIcons.setText(fastForward);
      pane.getChildren().addAll(
        new Text(ttfUrl.substring(ttfUrl.lastIndexOf("/"))),
        new HBox(new Text("Text: "), textIcons),
        new HBox(new Text("Label: "), labelIcons)
      );
    } catch (Exception e) {
      pane.getChildren().add(new Text(e.getMessage()));
    }
    Tab iconTab = new Tab("Font icon test");
    iconTab.setContent(pane);
    return iconTab;
  }

@hallvard
Copy link
Author

hallvard commented Feb 17, 2025

Suddenly get Error downloading zips: java.io.IOException: Error downloading link from https://github.com/gluonhq/vmone/releases/download/gvm-24-2.1/vmone-android-linux-aarch64.zip. Unexpected status code: 404 during build, so not able to try on Android at the moment.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants