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

fix: provide a mock function to measure text width #311

Merged
merged 1 commit into from
Nov 10, 2023
Merged

Conversation

xiaoiver
Copy link
Contributor

使用 document 创建 <canvas> 进行文本连弟度量,会导致服务端渲染强依赖 node-canvas。
此时可以参考 plot 使用一个字符宽度查找表进行估算,因此需要提供一个可传入的 mock 方法实现:

import { setMockMeasureTextWidth } from '@antv/component';
setMockMeasureTextWidth(measureText);

目前 G2 在截图测试中使用。

@xiaoiver xiaoiver merged commit 9a10cdf into master Nov 10, 2023
2 checks passed
@xiaoiver xiaoiver deleted the fix-mock branch November 10, 2023 03:09
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

Successfully merging this pull request may close these issues.

1 participant