Skip to content
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

Matrix should align its items with the baseline, not the total box #484

Open
ForNeVeR opened this issue Mar 9, 2024 · 0 comments
Open

Comments

@ForNeVeR
Copy link
Owner

ForNeVeR commented Mar 9, 2024

Consider this formula:

\text{f(x)} = \cases{\text{1/3} & \text{if 0 ≤ x ≤ 1;} \\
\text{2/3} & \text{if 3 ≤ x ≤ 4;} \\
0..... & \colorbox{red}{\text{.elsewherge.}} \\
0..... & \colorbox{red}{\text{..}}}

Check how it looks currently:
image

As you can see, on line elsewherge the red box is high and the item itself is shifted up because of this.

On the line .., on contrary, the box is quite low and thus the item is also placed incorrectly.

Now, consider this patch that temporarily disables the character depth calculation for the system fonts:

Index: src/WpfMath/Fonts/WpfSystemFont.cs
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/WpfMath/Fonts/WpfSystemFont.cs b/src/WpfMath/Fonts/WpfSystemFont.cs
--- a/src/WpfMath/Fonts/WpfSystemFont.cs	(revision Staged)
+++ b/src/WpfMath/Fonts/WpfSystemFont.cs	(date 1710012618138)
@@ -155,6 +155,6 @@
         var scalingFactor = typeface.FontFamily.LineSpacing / typeface.FontFamily.Baseline;
         height /= scalingFactor;
 
-        return new TeXFontMetrics(formattedText.Width, height, depth, 0, 1.0);
+        return new TeXFontMetrics(formattedText.Width, height, 0, 0, 1.0);
     }
 }

After it, the elsewherge placement is nearly perfect:
image

So, the problem is that the characters properly report its baseline to the box model, but it cannot take it into account when placing the matrix items (I believe that we should just take Height instead of TotalHeight somewhere in the matrix calculation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant