barmalei / zebkit

JavaScript library that follows easy OOP concept, provides HTML5 Canvas based Rich UI and includes Java to JavaScript converter tool
Apache License 2.0
931 stars 177 forks source link

Font with italic bold and underline #162

Closed vasu-vvp closed 6 years ago

vasu-vvp commented 6 years ago

How to define font having properties ? italic bold and underline it seems that either italic or bold can be defined, but what if bold and italic both are needed also if underline is needed also

barmalei commented 6 years ago

For example bold +italic font can be set as follow:

...
comp.setFont(new zebkit.Font("Arial", "bold italic", 16));
...

or you can specify font encoded as string:

...
comp.setFont("bold italic 14px Arial");
...

Underline (strike, etc) decoration is not supported by HTML5 canvas, but zebkit provides special text render for this case. For instance if you need a label or text field component with underlined text you can archive it as follow:

var dec = zebkit.draw.DecoratedTextRender("ABC").addDecorations("underline");
var tf  = new zebkit.ui.TextField(dec);
vasu-vvp commented 6 years ago

Thanks :smiley: