-
Notifications
You must be signed in to change notification settings - Fork 113
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
Offsetting and scaling #143
Conversation
} | ||
|
||
impl LayoutGlyph { | ||
pub fn physical(&self, offset: (f32, f32), scale: f32) -> PhysicalGlyph { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
PhysicalGlyph
type that allows deferring the computation of aCacheKey
while offsetting and scaling a glyph after layout.This allows consumers to benefit from layout linearity and leverage subpixel glyph positioning.