Skip to content

Commit 1298356

Browse files
committed
Fix typo in CharacterBoundingBox and small optimisation in TrueTypeFont and seal both classes
1 parent 1660c73 commit 1298356

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/UglyToad.PdfPig.Fonts/TrueType/TrueTypeFont.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/// <summary>
1010
/// A TrueType font.
1111
/// </summary>
12-
public class TrueTypeFont
12+
public sealed class TrueTypeFont
1313
{
1414
/// <summary>
1515
/// The font version number.
@@ -107,8 +107,12 @@ public bool TryGetBoundingBox(int characterCode, Func<int, int?> characterCodeTo
107107
{
108108
boundingBox = default(PdfRectangle);
109109

110-
if (!TryGetGlyphIndex(characterCode, characterCodeToGlyphId, out var index)
111-
|| TableRegister.GlyphTable == null)
110+
if (TableRegister.GlyphTable == null)
111+
{
112+
return false;
113+
}
114+
115+
if (!TryGetGlyphIndex(characterCode, characterCodeToGlyphId, out var index))
112116
{
113117
return false;
114118
}
@@ -139,8 +143,12 @@ public bool TryGetPath(int characterCode, Func<int, int?> characterCodeToGlyphId
139143
{
140144
path = null;
141145

142-
if (!TryGetGlyphIndex(characterCode, characterCodeToGlyphId, out var index)
143-
|| TableRegister.GlyphTable == null)
146+
if (TableRegister.GlyphTable == null)
147+
{
148+
return false;
149+
}
150+
151+
if (!TryGetGlyphIndex(characterCode, characterCodeToGlyphId, out var index))
144152
{
145153
return false;
146154
}

src/UglyToad.PdfPig/PdfFonts/CharacterBoundingBox.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
/// <summary>
66
/// Character bounding box.
77
/// </summary>
8-
public class CharacterBoundingBox
8+
public sealed class CharacterBoundingBox
99
{
1010
/// <summary>
1111
/// The glyph bounds.
1212
/// </summary>
1313
public PdfRectangle GlyphBounds { get; }
1414

1515
/// <summary>
16-
/// THe width.
16+
/// The width.
1717
/// </summary>
1818
public double Width { get; }
1919

0 commit comments

Comments
 (0)