-
Notifications
You must be signed in to change notification settings - Fork 150
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 text_size
#689
fix text_size
#689
Conversation
I think |
It's not that bad. I see that it discovered unnecessary lifetimes and stuff. We just have to fix it every couple of months. |
Maybe we can add more versions to clippy matrix matrix:
toolchain: [nightly] |
No, stable |
Thanks! it would be nice to extend the text regression test to include the issue this is fixing: Line 810 in 54573da
|
Ofc. I will write proptests to ensure that text is always rendered inside this rectangle. |
And now I have found a counterexample for the X position in let img = GrayImage::new(600, 150);
let x = 62;
let y = 21;
let scale = 78.0932;
let text = "jnenuoltqjylzcbvcc";
let (text_w, text_h) = text_size(scale, &font, text);
let rect = Rect::at(x, y).of_size(text_w, text_h); |
Maybe the origin of the first glyph? its |
I tried to fix it, but it requires replacing the |
|
The test image can be regenerated by running
|
Are you familiar with OpenType glyphs? |
I replaced |
I think that despite moving to the right, all relative distances between glyphs will remain the same as in the previous implementation. |
For example, in the previous implementation of |
We can go the other way. We can keep the starting point at 0, that is, no change in the |
We can also add the horizontal let first_h_bearing = font.h_side_bearing(first_glyph);
let mut w = if first_h_bearing < 0.0 {
first_h_bearing.abs()
} else {
0.0
}; |
I have no preferences here. |
I’m not familiar with OpenType. Any of these options seems fine - let’s go with relaxing the test to allow for negative side bearings if you have no preference. |
Sure, one moment |
I added |
Thanks a lot! |
First I tried
h = h.max(bb.min.y + bb.height());
. But then I think I found a better solution.Looks good when using English and Japanese text. And some useful distance at the bottom of the text. You can try on my branch.
Relates: #687