We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I'm trying to shift the origin of the laid out text for which I need the total width and height.
let (xw, yw) = (0.5, 0.5); let offset_x = -total_width * xw; let offset_y = total_height * yw; let glyphs = layout.glyphs(); layout.lines().unwrap().for_each(|line| { for i in line.glyph_start..=line.glyph_end { let g = &glyphs[i]; // TODO: Shift glyph position by `offset_x` and `offset_y` } });
I found Layout::height which seems to be what I need for total_height for calculating offset_y up-front, but I've found no equivalent Layout::width?
Layout::height
total_height
offset_y
Layout::width
I found the private tracking_x which seems to have been useful here maybe since it's used for the horizontal alignment in the finalize stage..
tracking_x
finalize
Is there something I've missed in the API or do I have to calculate the total_width manually like I do currently which seems to work:
total_width
let total_height = layout.height(); let total_width = { let mut max_width: f32 = f32::MIN; lines.iter().for_each(|line| { let gs = &glyphs[line.glyph_start]; let ge = &glyphs[line.glyph_end]; let min = gs.x; let max = ge.x + ge.width as f32; max_width = max_width.max(max - min + line.padding); }); max_width };
If I'm totally wrong here, how would you calculate the bounding box of the laid out text?
Thanks btw for making this crate as dependency free and self-standing as possible. I really appreciate that kind of effort :)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I'm trying to shift the origin of the laid out text for which I need the total width and height.
I found
Layout::height
which seems to be what I need fortotal_height
for calculatingoffset_y
up-front, but I've found no equivalentLayout::width
?I found the private
tracking_x
which seems to have been useful here maybe since it's used for the horizontal alignment in thefinalize
stage..Is there something I've missed in the API or do I have to calculate the
total_width
manually like I do currently which seems to work:If I'm totally wrong here, how would you calculate the bounding box of the laid out text?
Thanks btw for making this crate as dependency free and self-standing as possible. I really appreciate that kind of effort :)
The text was updated successfully, but these errors were encountered: