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

Suggested solution #484 #485

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/WpfMath/Fonts/WpfSystemFont.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,6 @@ private static TeXFontMetrics GetFontMetrics(char c, Typeface typeface)
var scalingFactor = typeface.FontFamily.LineSpacing / typeface.FontFamily.Baseline;
height /= scalingFactor;

return new TeXFontMetrics(formattedText.Width, height, depth, 0, 1.0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have you reverted this? It seems wrong: it will stop preserving the "depth" of the system font characters. Example:
image
(see how the selection box is wrong now)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your solution doesn't solve the problem. In addition, it breaks other types of matrices.
image
image

Why have you reverted this? It seems wrong: it will stop preserving the "depth" of the system font characters.

Because the letters overhang is under the baseline. If an alignment by the baseline, then the overhang must be below the baseline (seems logic). Otherwise a characters will be above the required line (in this case will be need substract depth at boxes placing - it is also seems logic 🤔).

return new TeXFontMetrics(formattedText.Width, height, 0, 0, 1.0);
}
}
19 changes: 15 additions & 4 deletions src/XamlMath.Shared/Atoms/MatrixAtom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,25 @@ protected override Box CreateBoxCore(TexEnvironment environment)

var vFreeSpace = rowHeight - cell.TotalHeight;
var tbGap = (VerticalPadding + vFreeSpace) / 2;

var cellContainer = new VerticalBox();
cellContainer.Add(new StrutBox(0.0, tbGap, 0.0, 0.0));
cellContainer.Add(cell);
cellContainer.Add(new StrutBox(0.0, tbGap, 0.0, 0.0));

if (cell.TotalHeight <= 0.54)
{
cellContainer.Add(new StrutBox(0.0, vFreeSpace, 0.0, 0.0));
cellContainer.Add(cell);
cellContainer.Add(new StrutBox(0.0, VerticalPadding / 2, 0.0, 0.0));
}
else
{
cellContainer.Add(new StrutBox(0.0, tbGap, 0.0, 0.0));
cellContainer.Add(cell);
cellContainer.Add(new StrutBox(0.0, tbGap, 0.0, 0.0));
}

cellContainer.Height = cellContainer.TotalHeight;
cellContainer.Depth = 0;


var hFreeSpace = columnWidth - cell.TotalWidth;
var (lGap, rGap) = GetLeftRightGap(hFreeSpace, j);
rowContainer.Add(new StrutBox(lGap, 0.0, 0.0, 0.0));
Expand Down
Loading