Creating a form object from a font object in Java

I have a font object and a string. I want to return a Shape object, which is a String view. I have a whole group of other classes that will display a string and take care of this.

I find it difficult to understand how to do this when I do not have a graphics / graphics2d object. Any help? I searched the web but could not find useful links.

public class SpecializationOfTester extends ParentTester {

    private String      str;
    private Font        font;


    public SpecializationOfTester(String str, Font font) {
        this.font = font;
        this.str = str;
    }

    public Shape getShape()
    {
        Shape           s;
        //
        //
        return s;
    }

}

thank

+3
source share
1 answer

You can use GlyphVector#getOutline()as mentioned here . You can create a graphics context in BufferedImage, as described in Using Headless Mode in the Java SE Platform .

See also these attractive examples:

+7

Source: https://habr.com/ru/post/1787217/


All Articles