代码之家  ›  专栏  ›  技术社区  ›  rainer

代码名从Web源生成一个字体图像

  •  1
  • rainer  · 技术社区  · 6 年前

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

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

    该示例使用unicode图像,但我想从web源导入一个图标,如 fontello . 如何从下载的图标生成字体图像?

    capital M ,但它只返回一个正方形。。。

    提前谢谢。

    2 回复  |  直到 6 年前
        1
  •  1
  •   Shai Almog    6 年前

    Build Real World Full Stack Mobile Apps in Java 课程您需要使用正确的字体对象,最简单的方法是在设计器中定义一个“ICont”UIID,并为该字体选择fontello.ttf文件。然后做一些类似的事情:

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

    有关定义fontello和获取所需值的步骤,请参见:

    enter image description here

        2
  •  1
  •   rainer    6 年前

    对于那些试图在CN1组件中使用来自外部源的图标的人,一些额外的信息——希望是有用的——可以从以下站点导入 Fontello ,刚刚完成Shai Almog的上述完美解释:

    有两个网站很有用:

    1. FontImage

    2. 这个代号是1 article ;

    这段代码对我很有用:

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