문제

I would like to be able to change the font size and possibly the font itself before the strokeText() method is called. I can change the color but I don't see anyway to change the font.

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

Anyone know how to do this?

도움이 되었습니까?

해결책

You can set the GraphicsContext's font and font size by calling the setFont method before your strokeText call.

gc.setFont(new Font(fontName, fontSize));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top