如何通过编码设置字体粗体和下划线?

how to set font bold and underline by coding?

我正在使用编码更改标签的字体,我想在字体上同时设置粗体和下划线,怎么办? 我正在使用以下代码

Font fnt = Font.createTrueTypeFont("abc.ttf", "abc.ttf").
           derive(4, Font.STYLE_BOLD);

您可以为带样式的标签设置粗体字体和文字装饰class。例如:

Font fnt = Font.createTrueTypeFont("abc.ttf", "abc.ttf").
       derive(4, Font.STYLE_BOLD);
/* 
*  I set up all styles in this case (Unselected,Selected,Pressed,Disabled),     
*  but btw you can edit each style independantly (getUnslectedStyle(),etc...)
*/
myLabel.getAllStyles().setFont(fnt);       //Font Selected
myLabel.getAllStyles().setUnderline(true); //Text decoration enabled