关节:如何将 icomoon 图标包含到 rappid 的自定义形状中

问题描述

我使用 rappid 框架来制作 HTML 图表工具。我使用以下示例使用 rappid 命名空间中的 dia.Element 制作了自定义形状。无论如何,图像使用 SVG 工作正常,但我想改用 icomoon/font-awesome 图标。

export const Element = dia.Element.define(
    "custom.Element",{
        size: {height: 165,width: 140},attrs: {
            body: {
                refWidth: "100%",refheight: "100%",fill: "transparent",},logoWrapper: {
                refX2: 25,refY2: 40,logoContainer: {
                height: 75,width: 90,fill: "#fff",stroke: "#9C9C9C",rx: 6,ry: 6,applogo: {
                width: 48,height: 48,refX: 21,refY: 14,fontFamily: "icomoon",content: `\eb65`,text: `\eb65`,...otherProps,} as Record<string,SVGAttributes>,{
        markup: [
            {
                tagName: "rect",selector: "body",{
                tagName: "g",selector: "logoWrapper",children: [
                    {
                        tagName: "rect",selector: "logoContainer",{
                        tagName: "text",selector: "applogo",...otherMarkup,],] as dia.MarkupJSON,}
);

这里我在 applogo自定义元素上使用了 attr

applogo: {
  width: 48,// here I've used the font-family or content/text
  // to fiddle with it,but no luck
  fontFamily: "icomoon",}

标记是这样的:

{
  tagName: "text",

任何帮助将不胜感激。谢谢。

解决方法

我终于通过使用正确的字体代码解决了它。需要将 \u 附加到 text 字符串。并且不再需要 content 道具。

{
  text: '\ueb65'
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...