What is the difference between embedded font and third-party font for Java?

Trying to figure out what might be a bug in the MultiLineLabel code found here: http://samuelsjoberg.com/archive/2009/10/multiline-labels-in-swing

Essentially, this sample will work just fine, say, Arial. But if I install my own font on my Mac, for example ITCKorinna-Bold, it still displays MultiLineLabel, but it does not add any lines, so "This is a long line." Becomes "This is ..."

+3
source share
1 answer

On Linux, with OpenJDK 7 update 19, it works fine. You did not provide your code, so it was difficult for us to understand if something could be wrong.

Roboto, , .

, Java , , Apple, , FontMetrics ( Apple Java , , , OpenJDK Linux). OpenJDK , , .

    Font robotoFont = null;
    try {
        robotoFont = Font.createFont(Font.TRUETYPE_FONT, new File("/usr/share/fonts/roboto/Roboto-Black.ttf"));
        robotoFont = robotoFont.deriveFont(14f);
    } catch (Exception e) {
        e.printStackTrace();
    }

    // Using the MultiLineLabel class.
    final MultiLineLabel mLabel = new MultiLineLabel(
            "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
                    + "Phasellus non sapien quam. Fusce posuere, nisl "
                    + "vitae tristique volutpat, augue erat faucibus nisl, "
                    + "nec venenatis metus sem vel enim. Cras in libero "
                    + "sapien, vitae euismod neque. Proin hendrerit, odio "
                    + "et faucibus suscipit, eros tellus blandit justo, "
                    + "ac cursus risus elit ut risus.");
    mLabel.setForeground(Color.WHITE);
    mLabel.setFont(robotoFont);

enter image description here

0

All Articles