Reputation: 468
I am trying to write String at given position in drawing and it works fine. I have implemented Slider in my app. And as the user changes the slider value I want the font and thickness of String to increase and decrease. Here is the code I tried
Slider slider= new new Slider();
slider.addDataChangedListener(new DataChangedListener() {
@Override
public void dataChanged(int type, int index) {
this.setBrushGirth(index * 2);
}
});
int offset = girth * 2;
Font f= Font.createSystemFont(Font.FACE_PROPORTIONAL, offset , offset);
g.setFont(f);
g.drawString("Hello World" , currentLine.startX + imageDrawnFromX, currentLine.startY + imageDrawnFromY);
Here girth is nothing but the value I get from slider movement. So, How do I set the stroke width for the text so that it increases or decreases according to value obtained from Slider. I can set the Font color of text but not this.
Any suggestions would be helpful. Thanks
Upvotes: 1
Views: 95
Reputation: 52770
We don't support that, stroke is only used to draw shapes and currently there is no API to convert text to a shape. I doubt if there ever will be.
The reason for this is simple, in order to do this we'd need to take over the drawing/kerning of text completely. This is something done by Swing/JavaFX which makes their text look different from the way the OS renders the same text. That's not something we want as it makes the app look less native.
Upvotes: 0