Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

给rect添加文本,修改字体类型无效 #4032

Open
shengaiyishi opened this issue Nov 13, 2023 · 2 comments
Open

给rect添加文本,修改字体类型无效 #4032

shengaiyishi opened this issue Nov 13, 2023 · 2 comments

Comments

@shengaiyishi
Copy link

问题描述

给rect添加文本,修改字体类型特别无效
我在 https://x6.antv.antgroup.com/examples/node/native-node#rect 上测试发现
事例:
const a = graph.addNode({
x: 40,
y: 40,
width: 120,
height: 60,
// label: 'rect',
attrs: {
text: {
text:'你好',
// fontFamily: 'Times New Roman',
fontFamily: '宋体',
}
}
})
当label为rect时,修改字体还是有效果的,当改成中文时,基本看不出效果了

重现链接

重现步骤

const a = graph.addNode({
x: 40,
y: 40,
width: 120,
height: 60,
// label: 'rect',
attrs: {
text: {
text:'你好么',
// fontFamily: '微软雅黑',
// fontFamily: '黑体',
}
}
})
当文本是 rect时确实能看到效果,当文本为中文时,就看不到效果了

预期行为

期望修改字体类型有效果

平台

  • 操作系统: [macOS, Windows, Linux, React Native ...]
  • 网页浏览器: [Google Chrome, Safari, Firefox ...]
  • X6 版本: [2.11.1 ...]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response

@XueMeijing
Copy link
Contributor

某些字体可能没有中文字形文件,导致切换无效,另外 微软雅黑 应该叫 Microsoft YaHei 吧 (https://www.jianshu.com/p/053e588c9470)

如果你期望修改字体类型有效果,左边选中某个html的汉字,再修改css里这个汉字对应的font-family,看哪个font-family对汉字生效,然后再把配置的 fontFamily 改成有效的font-family。比如mac上 fontFamily: 'cursive' 就是有效的

image

@shengaiyishi
Copy link
Author

是的,目前我采用的就是直接去遍历tspan,然后给它们添加font-family;
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants