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

Measuring HtmlContext text with spaces is broken #71

Open
hellochar opened this issue Sep 6, 2017 · 1 comment
Open

Measuring HtmlContext text with spaces is broken #71

hellochar opened this issue Sep 6, 2017 · 1 comment
Labels

Comments

@hellochar
Copy link
Contributor

var context = new HtmlContext(...);
var measurer = new CacheMeasurer(context);

measurer.measure("t"); // returns { width: 10, height: 17 }
measurer.measure(" "); // returns { width: -37, height: 35 }

This negative value then feeds up the chain for generic line/text measuring

The space measuring breaks because of the "useGuards" logic

@hellochar hellochar added the bug label Sep 6, 2017
@hellochar
Copy link
Contributor Author

hellochar commented Sep 6, 2017

I found the issue - in

const textElement = HtmlUtils.append(this.element, "span", "text-tmp", this.className);
we append a <span> with the text and measure the span. To measure the width of a single space character we append "bdpql" on either side. In my case the span was line-wrapping to put the bdpql's on separate new lines, and using the space as a line break. This never happened in svg since svg text never linewraps

In general, this strategy for measuring doesn't feel right, we're working against browser's html layout engine

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

1 participant