简体   繁体   English

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

[英]Joints: How to include icomoon icon into rappid's custom shape

I'm using the Rappid framework for HTML diagramming tooling.我将Rappid框架用于 HTML 图表工具。 I've made custom shapes using dia.Element from rappid's namespace using the below example.我使用以下示例使用dia.Element命名空间中的dia.Element制作了自定义形状。 Anyhow, images are working fine using SVG, but I want to use icomoon/font-awesome icon instead.无论如何,图像使用 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,
    }
);

Here I've used the attr on custom element on appLogo:在这里,我在 appLogo 上的自定义元素上使用了attr

appLogo: {
  width: 48,
  height: 48,
  refX: 21,
  refY: 14,
  // here I've used the font-family or content/text
  // to fiddle with it, but no luck
  fontFamily: "icomoon",
  content: `\eb65`,
  text: `\eb65`,
}

And the markup is like this:标记是这样的:

{
  tagName: "text",
  selector: "appLogo",
},

Any help would be greatly appreciated.任何帮助将不胜感激。 Thanks.谢谢。

I finally solved it by using the correct font code.我终于通过使用正确的字体代码解决了它。 Needed to append \\u\u003c/code> to the text string.需要将\\u\u003c/code>附加到text字符串。 And the content prop is no longer required.不再需要content道具。

{
  text: '\ueb65'
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM