JSFL - How to change the font of a text field?

泄露秘密 提交于 2019-12-13 02:54:43

问题


Im trying to set the font (face) of a textfield.

Ive tried both :

textElement.setTextAttr("face", replacementFont);
textElement.setTextAttr.face = replacementFont;

Where replacementFont is the text name of the desired font.

This doesnt work - am I missing something?


回答1:


'textElement.setTextAttr("face", replacementFont);' works for me. Probably the font you are trying to replace with, is not installed. You could try this:

textElement.setTextAttr('face', replacementFont);
if (textElement.getTextAttr('face') != replacementFont)
{
    fl.trace("Font '" + replacementFont + "' is not available!\nTry a different font!");
}



回答2:


This ended up an issue with the way I was loading in my replacement fonts.

I had made a csv file containing the font mapping. And the font names were containing a new line character.

I parsed out the new line character. Interestingly enough the new line character was required to compare and match the font map.



来源:https://stackoverflow.com/questions/19328448/jsfl-how-to-change-the-font-of-a-text-field

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!