-
Notifications
You must be signed in to change notification settings - Fork 36
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
Broken results when setting variations #91
Comments
Interesting. Will take a look. |
Seems like there are two issues at play here:
fn glyph_advance(&self, glyph: GlyphId, is_vertical: bool) -> u32 {
let face = &self.ttfp_face;
if face.is_variable()
&& face.has_non_default_variation_coordinates()
&& face.tables().hvar.is_none()
&& face.tables().vvar.is_none()
{
return match face.glyph_bounding_box(glyph) {
Some(bbox) => {
(if is_vertical {
bbox.y_max + bbox.y_min
} else {
bbox.x_max + bbox.x_min
}) as u32
}
None => 0,
};
} In the case of this font, Seems the reason that this is done is that in pub fn glyph_hor_advance(&self, glyph_id: GlyphId) -> Option<u16> {
#[cfg(feature = "variable-fonts")]
{
let mut advance = self.tables.hmtx?.advance(glyph_id)? as f32;
if self.is_variable() {
// Ignore variation offset when `hvar` is not set.
if let Some(hvar) = self.tables.hvar {
if let Some(offset) = hvar.advance_offset(glyph_id, self.coords()) {
// We can't use `round()` in `no_std`, so this is the next best thing.
advance += offset + 0.5;
}
}
}
u16::try_num_from(advance)
}
#[cfg(not(feature = "variable-fonts"))]
{
self.tables.hmtx?.advance(glyph_id)
}
} So I presume using other tables has just not been implemented yet? @RazrFalcon since you seem to have written the code in ttf-parser, do you know what's up with that? |
|
Correct. |
As for phantom points, yep, not implemented. RazrFalcon/ttf-parser#27 Overall, the problem here is that in TrueType there are a billion ways to do exactly the same thing. And this is one of those edge cases. |
No worries, at least we know the "problem" now. |
Hello. Came here to create an issue and found this one already. I have the same rust program implemented twice, once with This with And this is with There is a There is a lot of other weird behaviors. Compare the images with the same names in both branches to see what I mean. |
Do you know which one HarfBuzz produces? You probably can recreate using |
I am using my fork/PR of |
Yes, there is still a lot of work to do. rustybuzz tries to produce the same output as harfbuzz, but we're not there yet. |
@RazrFalcon I'm afraid it's still not working correctly, at least for this test case :(
|
Yes, this is expected. My fix mostly affects spaces advance calculation. So they are no longer 0. |
Stupid mistake... How about now? |
Will try again later. |
Over Eid vacation I have been working on a tiny toy project to compare HarfBuzz and Rustybuzz output for variable fonts (specifically Raqq). I came here to post it on this issue only to find it closed :) (I am using my fork of Here it is anyway: https://github.com/asibahi/hb_vs_rb . I haven't (yet?) tried it with the input from my previous comment but for every small phrase I tried they matched perfectly. I even ran a loop over every permutation of the two axis to find discrepancies. |
@RazrFalcon Yep, seems to work prefectly now! Thanks a lot! |
@asibahi I suspect that your issue is not directly related to this, so if it is still reproducible with the newest main, I will try to look into it. |
@RazrFalcon small update: I refactored the code so I can switch between the two shapers with a trait, assuring I am calling both shapers exactly the same way. I found no differences whatsoever. The earlier difference. must've been a bug in my code when I moved it to rusty buzz the first time. |
Great to hear! :) |
Hello. I wasn't sure if I should report this considering the deprecation status of this crate. But anyway, here it goes..
Running the example with this monospace variable font:
First, test with
wght=<default>
andwdth=<default>
:All good.
Now, let's variate:
Not so mono anymore, and that
space=0+0
is even more problematic.harfbuzz
reports correct results.The text was updated successfully, but these errors were encountered: