nativescript-community / ui-canvas

Implement Canvas into your NativeScript apps.
https://nativescript-community.github.io/ui-canvas/
Apache License 2.0
31 stars 9 forks source link

Can not set font size #21

Closed MartinPenev closed 3 years ago

MartinPenev commented 3 years ago

Hello! Thanks for the great plugin!

I have checked the example folder but I wasn't able to find an example with setting the font size. I can see in the API that a Font can be provided on Paint, but it seems the size I set there is not taken into account.

const paint = new Paint();
paint.color = "black";
paint.font = new Font("Roboto", 10, FontStyle.ITALIC, FontWeight.BOLD);
paint.setStyle(Style.FILL_AND_STROKE);
fields.forEach(cardField => {
  canvas.drawText(cardField.textValue, cardField.position.x, cardField.position.y, paint);
});`

It doesn't matter what value I place instead of "10" in the example above, the size is always the same. Is that field supported?

farfromrefug commented 3 years ago

@MartinPenev can you try by using fontSize property on the paint object? It should work. However it not working with the Font object is a bug !

MartinPenev commented 3 years ago

using textSize property does the trick, thanks!