Skip to content
Merged
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
12 changes: 6 additions & 6 deletions src/UglyToad.PdfPig/PdfFonts/Simple/TrueTypeSimpleFont.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ public CharacterBoundingBox GetBoundingBox(int characterCode)
return cached;
}

var fontMatrix = GetFontMatrix();
var fontMatrixL = GetFontMatrix();

var boundingBox = GetBoundingBoxInGlyphSpace(characterCode, out var fromFont);

var boundingBoxPreTransform = boundingBox.Width;

if (fromFont)
{
boundingBox = fontMatrix.Transform(boundingBox);
boundingBox = fontMatrixL.Transform(boundingBox);
}
else
{
Expand All @@ -191,12 +191,12 @@ public CharacterBoundingBox GetBoundingBox(int characterCode)
double width;

var index = characterCode - firstCharacter;
if (widths != null && index >= 0 && index < widths.Length)
if (widths is not null && index >= 0 && index < widths.Length)
{
fromFont = false;
width = widths[index];
}
else if (font != null)
else if (font is not null)
{
if (!font.TryGetAdvanceWidth(characterCode, out width))
{
Expand All @@ -209,12 +209,12 @@ public CharacterBoundingBox GetBoundingBox(int characterCode)
}
else
{
throw new InvalidOperationException($"Could not retrieve width for character code: {characterCode} in font {Name}.");
width = boundingBoxPreTransform;
}

if (fromFont)
{
width = fontMatrix.TransformX(width);
width = fontMatrixL.TransformX(width);
}
else
{
Expand Down
Loading