Offsetting and scaling#143
Conversation
| } | ||
|
|
||
| impl LayoutGlyph { | ||
| pub fn physical(&self, offset: (f32, f32), scale: f32) -> PhysicalGlyph { |
There was a problem hiding this comment.
I don't really like the name. Ideally, it should be a verb; but I can't quite come up with anything. I'll keep thinking about it.
| self.font_size * scale, | ||
| ( | ||
| (self.x + x_offset) * scale + offset.0, | ||
| ((self.y - y_offset) * scale + offset.1).trunc(), // Hinting in Y axis |
There was a problem hiding this comment.
Maybe hinting could be an argument flag to this method and could be passed and stored in the CacheKey. This way we could tie it all together with the swash::swash_image function in a type safe way.
There was a problem hiding this comment.
From a Discord discussion, the author of swash shared:
My general recommendation would be to never apply fractional offsets in the y direction. We do so in the x direction because scaled advance widths are almost never integral and we’re generally rasterizing to a fixed grid so if the fractional component of the advance is not taken into account, you end up with very noticeable inconsistent spacing between glyphs and the error accumulates quickly over a line.
For most body text, the line height is consistent so rounding is fine (and imho, preferable).
So I guess we can just keep hinting hardcoded like this.
|
@StaffEngineer No. |
|
I fixed the test failures in 85ac473 |
The latest `cosmic-text` release performs bucketing calculations after layouting. This allows us to provide proper subpixel offsets, as well as scale any buffer thanks to its linear layout properties. See pop-os/cosmic-text#143.
The latest `cosmic-text` release performs bucketing calculations after layouting. This allows us to provide proper subpixel offsets, as well as scale any buffer thanks to its linear layout properties. See pop-os/cosmic-text#143.
The latest `cosmic-text` release performs bucketing calculations after layouting. This allows us to provide proper subpixel offsets, as well as scale any buffer thanks to its linear layout properties. See pop-os/cosmic-text#143.
The latest `cosmic-text` release performs bucketing calculations after layouting. This allows us to provide proper subpixel offsets, as well as scale any buffer thanks to its linear layout properties. See pop-os/cosmic-text#143.
This PR introduces a new
PhysicalGlyphtype that allows deferring the computation of aCacheKeywhile offsetting and scaling a glyph after layout.This allows consumers to benefit from layout linearity and leverage subpixel glyph positioning.