-
-
Notifications
You must be signed in to change notification settings - Fork 69
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 Woff2 bounds decompression and size measurement calculations. #380
Conversation
@@ -552,7 +556,9 @@ private static IReadOnlyList<GlyphLayout> LayoutText(TextBox textBox, TextOption | |||
advanceX, | |||
data.ScaledAdvance, | |||
GlyphLayoutMode.Vertical, | |||
i == 0)); | |||
i == 0 && j == 0)); |
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.
Prevents individual metrics within a composite glyph adding to the advance.
for (int i = removalIndices.Length - 1; i >= 0; i--) | ||
{ | ||
int match = removalIndices[i]; | ||
codePointCount += this.glyphs[match].Data.CodePointCount; | ||
CodePoint currentCodePoint = this.glyphs[match].Data.CodePoint; |
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.
If we do not update the code point, then we can end up with a codepoint that is then skipped during rendering.
for (int i = count; i > 0; i--) | ||
{ | ||
int match = index + i; | ||
codePointCount += this.glyphs[match].Data.CodePointCount; | ||
CodePoint currentCodePoint = this.glyphs[match].Data.CodePoint; | ||
if (!UnicodeUtility.IsDefaultIgnorableCodePoint((uint)codePoint.Value) || UnicodeUtility.ShouldRenderWhiteSpaceOnly(codePoint)) |
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.
When substituting a ligation, we need to ensure that the remaining codepoint is renderable.
FontRectangle bounds = GetBounds(glyphLayouts, dpi); | ||
return new FontRectangle(0, 0, MathF.Ceiling(bounds.Right - topLeft.X), MathF.Ceiling(bounds.Bottom - topLeft.Y)); | ||
return new FontRectangle(0, 0, MathF.Ceiling(bounds.Width), MathF.Ceiling(bounds.Height)); |
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.
We know the bounds width/height here so should use it directly.
@@ -1166,35 +1184,6 @@ private static void SubstituteBidiMirrors(FontMetrics fontMetrics, GlyphSubstitu | |||
: metric.FontMetrics.VerticalMetrics; | |||
float ascender = metricsHeader.Ascender * scaleY; | |||
|
|||
// Adjust ascender for glyphs with a negative tsb. e.g. emoji to prevent cutoff. | |||
if (!CodePoint.IsWhiteSpace(codePoint)) |
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.
This was a hack based upon incorrect assumptions. The proper fix is to use a larger line spacing to meet the font design.
Prerequisites
Description
Fixes #375 #373 #367
We were calculating the bounds bitmap length calculation incorrectly which led to the wrong bounds being read.
Further investigation into determining the correct bounds led to the discovery that the bounds calculation could be simplified and that the size was being incorrectly calculated.
I've added some additional visual tooling in the samples project that helps to verify measurement results. This helped me to discover that we were not rendering the results of some ligature substitutions if the remaining glyph code point was non-rendering. The output is pretty cool.
I also fixed the line breaking algorithm to include a missed breaking opportunity and exactly match browser output.