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

多个字符被渲染为单个glyph时无法正常计算宽度 #55

Open
kinginsun opened this issue Feb 12, 2020 · 4 comments
Open

多个字符被渲染为单个glyph时无法正常计算宽度 #55

kinginsun opened this issue Feb 12, 2020 · 4 comments
Assignees
Labels

Comments

@kinginsun
Copy link

kinginsun commented Feb 12, 2020

测试文本:
The procedure was successfully applied for the determination of carbamazepine in pharmaceutical samples, human plasma and breast milk.

然后标记procedure正常,标记“successfully” 开始位置正确,结束位置错了,“successfully”后面的词标记的开始和结束都错位了。

本地和https://synyi.github.io/poplar/#/annotate 在线测试都是同样结果。

polar_bug001

@longfangsong longfangsong self-assigned this Feb 13, 2020
@longfangsong
Copy link
Collaborator

longfangsong commented Feb 13, 2020

测试文本:
The procedure was successfully applied for the determination of carbamazepine in pharmaceutical samples, human plasma and breast milk.

然后标记procedure正常,标记“successfully” 开始位置正确,结束位置错了,“successfully”后面的词标记的开始和结束都错位了。

本地和https://synyi.github.io/poplar/#/annotate 在线测试都是同样结果。

已经在修复这一问题。
这一问题似乎只在Firefox上存在,如果急着使用,可以尝试使用Chrome。

@kinginsun
Copy link
Author

牛!非常感谢

@longfangsong
Copy link
Collaborator

longfangsong commented Feb 13, 2020

经查,该问题是由于部分浏览器+字体的组合下,会将多个字符(例如相邻的f和l)渲染为单个glyph,而getExtentOfChar()方法此时返回的width并非这个字符的宽度。

在解决这一问题之前,较为保险的方案是使用等宽字体作为英文字体。

Stackoverflow 上的相关问题

@longfangsong longfangsong changed the title 标注的内容出现“successfully”这个词,打的标签就会错位 多个字符被渲染为单个glyph时无法正常计算宽度 Feb 13, 2020
@kinginsun
Copy link
Author

把font-family改成”Courier New“后就正常了,谢谢。

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

No branches or pull requests

2 participants