Java 在Vaadin中加载自己的图标字体

Java 在Vaadin中加载自己的图标字体,java,css,fonts,vaadin,vaadin7,Java,Css,Fonts,Vaadin,Vaadin7,我创建了一个图标字体,使用并尝试按照从Vaadin到 我的文件结构如下: |VAADIN +---themes +---my-theme +---fonts +---my-font-icons.ttf |---... |---addons.scss |---my-theme.scss |---styles.scss 在我的styles.scss中,我写了以下内容: @impo

我创建了一个图标字体,使用并尝试按照从Vaadin到

我的文件结构如下:

|VAADIN
+---themes
    +---my-theme
        +---fonts
            +---my-font-icons.ttf
            |---...
        |---addons.scss
        |---my-theme.scss
        |---styles.scss
在我的
styles.scss
中,我写了以下内容:

@import "addons.scss";
@import "my-theme.scss";
@include v-font(MyFontIcons, './fonts/my-font-icons');

.monitoring-theme {
  @include addons;
  @include my-theme;
}
但是我无法让字体在Java中工作

public enum MyIconFont implements FontIcon {
    BASKET(0xe905), 
    BOOKMARK(0x6e);

    private static final String fontFamily = "MyFontIcons";
    private int codepoint;

    MyIconFont(int codepoint) {
        this.codepoint = codepoint;
    }

    @Override
    public String getMIMEType() {
        throw new UnsupportedOperationException(FontIcon.class.getSimpleName() + " should not be used where a MIME type is needed.");
    }

    @Override
    public String getFontFamily() {
        return fontFamily;
    }

    @Override
    public int getCodepoint() {
        return codepoint;
    }

    @Override
    public String getHtml() {
        return "<span class=\"v-icon MyFontIcons\">&#x" + Integer.toHexString(codepoint) + ";</span>";
    }
创建的.css文件位于
mytheme
文件夹中,但该主题不包含在我的vaadin应用程序中


是否有任何方法可以将字体加载为
类资源
并使用其中的图标?

我想您会发现v-font函数提供与valo主题字体目录相关的文件

它应该看起来像:

@include v-font(MyFontIcons, '../../../../../my-theme/fonts/my-font-icons');

我想您会发现v-font函数提供与valo主题的字体目录相关的文件

它应该看起来像:

@include v-font(MyFontIcons, '../../../../../my-theme/fonts/my-font-icons');

会发生什么?它是从URL加载ttf文件还是该步骤失败了?当查看生成的styles.css时,它是否链接到您的字体以及最终的类名是否正确?那么它就不可能加载任何内容。查看项目的sass编译阶段您使用的构建系统是什么?为什么您通过
v-font(…)
而不是通过
@include font(…)
包含字体,如您提到的wiki文档所示?会发生什么?它是从URL加载ttf文件还是该步骤失败了?当查看生成的styles.css时,它是否链接到您的字体以及最终的类名是否正确?那么它就不可能加载任何内容。查看项目的sass编译阶段您使用的构建系统是什么?为什么您通过
v-font(…)
而不是通过
@include font(…)
包含字体,如您提到的wiki文档所示?