【问题标题】:Codename One Font Image Generate from Web Source代号从 Web 源生成的一种字体图像
【发布时间】:2019-04-30 09:07:35
【问题描述】:

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

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

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

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

提前致谢。

【问题讨论】:

    标签: image codenameone


    【解决方案1】:

    我碰巧有从Build Real World Full Stack Mobile Apps in Java 课程中获取 facebook 徽标的确切说明。您需要使用正确的字体对象,最简单的方法是在设计器中定义一个“IconFont”UIID 并为该字体选择 fontello.ttf 文件。然后只需执行以下操作:

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

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

    【讨论】:

      【解决方案2】:

      对于那些尝试在 CN1 组件中使用来自外部源的图标的人,一些额外的(希望有帮助的)信息可以从 Fontello 等网站导入,只需完成 Shai Almog 的上述完美解释:

      两个网站很有帮助:

      1. FontImage 文档;

      2. 这个代号一article

      然后这段代码对我有用:

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

      【讨论】:

        猜你喜欢
        • 2011-05-13
        • 1970-01-01
        • 1970-01-01
        • 2015-11-21
        • 1970-01-01
        • 2011-01-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多