mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-07-17 04:15:03 +08:00
default height from font matrix for type 0 fonts when height missing #287
This commit is contained in:
parent
13247a5218
commit
6a1fa544d2
@ -10,7 +10,7 @@
|
|||||||
{
|
{
|
||||||
var names = Standard14.GetNames().Count;
|
var names = Standard14.GetNames().Count;
|
||||||
|
|
||||||
Assert.Equal(38, names);
|
Assert.Equal(39, names);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
private readonly ICidFontProgram fontProgram;
|
private readonly ICidFontProgram fontProgram;
|
||||||
private readonly VerticalWritingMetrics verticalWritingMetrics;
|
private readonly VerticalWritingMetrics verticalWritingMetrics;
|
||||||
private readonly double? defaultWidth;
|
private readonly double? defaultWidth;
|
||||||
|
private readonly double scale;
|
||||||
|
|
||||||
public NameToken Type { get; }
|
public NameToken Type { get; }
|
||||||
|
|
||||||
@ -46,11 +47,13 @@
|
|||||||
this.fontProgram = fontProgram;
|
this.fontProgram = fontProgram;
|
||||||
this.verticalWritingMetrics = verticalWritingMetrics;
|
this.verticalWritingMetrics = verticalWritingMetrics;
|
||||||
this.defaultWidth = defaultWidth;
|
this.defaultWidth = defaultWidth;
|
||||||
|
|
||||||
|
scale = 1 / (double)(fontProgram?.GetFontMatrixMultiplier() ?? 1000);
|
||||||
|
|
||||||
Type = type;
|
Type = type;
|
||||||
SubType = subType;
|
SubType = subType;
|
||||||
BaseFont = baseFont;
|
BaseFont = baseFont;
|
||||||
SystemInfo = systemInfo;
|
SystemInfo = systemInfo;
|
||||||
var scale = 1 / (double)(fontProgram?.GetFontMatrixMultiplier() ?? 1000);
|
|
||||||
FontMatrix = TransformationMatrix.FromValues(scale, 0, 0, scale, 0, 0);
|
FontMatrix = TransformationMatrix.FromValues(scale, 0, 0, scale, 0, 0);
|
||||||
Descriptor = descriptor;
|
Descriptor = descriptor;
|
||||||
Widths = widths;
|
Widths = widths;
|
||||||
@ -96,7 +99,7 @@
|
|||||||
|
|
||||||
if (fontProgram == null)
|
if (fontProgram == null)
|
||||||
{
|
{
|
||||||
return Descriptor?.BoundingBox ?? new PdfRectangle(0, 0, 1000, 0);
|
return Descriptor?.BoundingBox ?? new PdfRectangle(0, 0, 1000, 1.0 / scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fontProgram.TryGetBoundingBox(characterIdentifier, out var boundingBox))
|
if (fontProgram.TryGetBoundingBox(characterIdentifier, out var boundingBox))
|
||||||
@ -106,15 +109,15 @@
|
|||||||
|
|
||||||
if (Widths.TryGetValue(characterIdentifier, out var width))
|
if (Widths.TryGetValue(characterIdentifier, out var width))
|
||||||
{
|
{
|
||||||
return new PdfRectangle(0, 0, width, 0);
|
return new PdfRectangle(0, 0, width, 1.0 / scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defaultWidth.HasValue)
|
if (defaultWidth.HasValue)
|
||||||
{
|
{
|
||||||
return new PdfRectangle(0, 0, defaultWidth.Value, 0);
|
return new PdfRectangle(0, 0, defaultWidth.Value, 1.0 / scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PdfRectangle(0, 0, 1000, 0);
|
return new PdfRectangle(0, 0, 1000, 1.0 / scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PdfVector GetPositionVector(int characterIdentifier)
|
public PdfVector GetPositionVector(int characterIdentifier)
|
||||||
|
Loading…
Reference in New Issue
Block a user