Resize text in JavaFX GraphicsContext

I would like to be able to change the font size and possibly the font itself before calling the strokeText () method. I can change the color, but I do not see to change the font.

Pane canvas = new Pane(); GraphicsContext gc = canvas.getGraphicsContext2D(); gc.setStroke(Color.WHITE); gc.strokeText("Hello", 1, 1); 

Does anyone know how to do this?

+4
source share
1 answer

You can set the font and font size of the GraphicsContext by calling the setFont method before calling strokeText.

 gc.setFont(new Font(fontName, fontSize)); 
+4
source

All Articles