use transform x for widths to improve performance

when transforming the advance width inside a font, we transform only the x coordinate rather than making a new point to transform.
This commit is contained in:
Eliot Jones
2020-02-28 15:15:16 +00:00
parent 5ae38f1bad
commit 4d911fb9d1
3 changed files with 5 additions and 5 deletions

View File

@@ -94,7 +94,7 @@
var width = CidFont.GetWidthFromFont(characterIdentifier);
var advanceWidth = matrix.Transform(new PdfPoint(width, 0)).X;
var advanceWidth = matrix.TransformX(width);
return new CharacterBoundingBox(boundingBox, advanceWidth);
}

View File

@@ -159,11 +159,11 @@
if (fromFont)
{
width = fontMatrix.Transform(new PdfPoint(width, 0)).X;
width = fontMatrix.TransformX(width);
}
else
{
width = DefaultTransformation.Transform(new PdfPoint(width, 0)).X;
width = DefaultTransformation.TransformX(width);
}
var result = new CharacterBoundingBox(boundingBox, width);

View File

@@ -67,7 +67,7 @@
characterBoundingBox = fontMatrix.Transform(characterBoundingBox);
var width = fontMatrix.Transform(new PdfPoint(widths[characterCode - firstChar], 0)).X;
var width = fontMatrix.TransformX(widths[characterCode - firstChar]);
return new CharacterBoundingBox(characterBoundingBox, width);
}
@@ -79,7 +79,7 @@
throw new InvalidFontFormatException($"The character code was not contained in the widths array: {characterCode}.");
}
return new PdfRectangle(0, 0, widths[characterCode - firstChar], 0); ;
return new PdfRectangle(0, 0, widths[characterCode - firstChar], 0);
}
public TransformationMatrix GetFontMatrix()