final Form hi = new Form("Fonts");
        hi.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
        hi.setScrollableX(false);
        hi.setScrollableY(true);

        int[] sizes = {2, 3, 4, 6, 8};

        String[] fonts = {"ArchitectsDaughter",
            "Cabin-Regular",
            "Cabin-Bold",
            "Kalam-Regular",
            "Kalam-Bold",
            "Merienda-Regular",
            "Merienda-Bold",
            "Montserrat-Regular",
            "Montserrat-Bold",
            "NotoSans-Regular",
            "NotoSans-Bold",
            "OpenSans-Regular",
            "PlayfairDisplay-Regular",
            "PlayfairDisplay-Bold",
            "Roboto-Regular",
            "Roboto-Bold",
            "Ubuntu-Regular",
            "Ubuntu-Bold"};

        for (String s : fonts) {
            Button b = new Button(s);
            b.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent evt) {

                    Form f = new Form(s);
                    f.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
                    f.setScrollableX(true);
                    f.setScrollableY(true);

                    for (int i : sizes) {
                        int fontSize = Display.getInstance().convertToPixels
(i);
                        Font ttfFont = Font.createTrueTypeFont(s, s + ".ttf"
).derive(fontSize, Font.STYLE_PLAIN);
                        f.add(createForFont(ttfFont, i + "mm: The quick 
brown fox"));
                        f.add(createForFont(ttfFont, i + "mm: 0123456789"));

                    }
                    setBackCommand(hi, f);
                    f.show();
                }

            });
            hi.add(b);
        }

        hi.show();
.....
    private Label createForFont(Font fnt, String s) {
        Label l = new Label(s);
        l.getUnselectedStyle().setFont(fnt);
        return l;
    }
 
Works fine on Android, all different fonts and sizes display. On WP10 the 
font size changes but only the system font is displayed.

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/fc9f001c-6123-4760-bac5-cef167c2c340%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to