Skip to content

Commit

Permalink
Merge pull request #1 from Thor181/fix_484
Browse files Browse the repository at this point in the history
fix: alignment in matrix by baseline
  • Loading branch information
Thor181 authored Mar 12, 2024
2 parents 7674caa + cd34b6d commit 9240a61
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
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);
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

0 comments on commit 9240a61

Please sign in to comment.