从网络源生成的代号一个字体图像

时间:2018-11-28 12:43:34

标签: image codenameone

我正在使用CN1 FontImage文档中的以下示例:

Font materialFont = FontImage.getMaterialDesignFont();
int w = Display.getInstance().getDisplayWidth();
FontImage fntImage = FontImage.createFixed("\uE161", materialFont, 0xff0000, w, w);

该示例使用unicode图像,但我想从fontello之类的网络源中导入图标。如何从下载的图标生成FontIamage?

我还尝试将示例中的unicode条目“ \ uE161”修改为“ \ u004D”,应该返回一个capital M,但它只返回一个正方形...

谢谢。

2 个答案:

答案 0 :(得分:1)

我碰巧有从Build Real World Full Stack Mobile Apps in Java课程获得Facebook徽标的确切说明。您需要使用正确的字体对象,最简单的方法是在设计器中定义一个“ IconFont” UIID,然后选择该字体的fontello.ttf文件。然后做类似的事情:

Label icon = new Label("\uf308", "IconFont");

有关定义fontello并获取所需值的步骤,请参见此内容。

enter image description here

答案 1 :(得分:0)

对于那些试图在CN1组件中使用来自外部来源的图标的人来说,从Fontello之类的网站导入一些其他信息(可能对您有所帮助),只需完成Shai Almog的上述完美解释即可:

两个站点都很有用:

  1. FontImage文档;

  2. 此代号One article

然后这段代码对我有用:

    Font materialFont = Font.createTrueTypeFont("fontello", "fontello.ttf");        
    int w = 100;
    FontImage fntImage;
    fntImage = FontImage.createFixed("\ue801", materialFont, 0x000000, w, w);
相关问题