mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-19 19:07:56 +08:00
merge pull request #103 from uglytoad/version-10-bugfixes
version 10 bugfixes
This commit is contained in:
@@ -68,6 +68,7 @@
|
||||
{
|
||||
AdvancedStrokingColorSpace = namedColorSpace.Name;
|
||||
CurrentStrokingColorSpace = colorspaceActual;
|
||||
DefaultColorSpace(colorspaceActual);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -120,10 +121,11 @@
|
||||
if (namedColorSpace.Name == NameToken.Separation && namedColorSpace.Data is ArrayToken separationArray
|
||||
&& separationArray.Length == 4
|
||||
&& separationArray[2] is NameToken alternativeColorSpaceName
|
||||
&& alternativeColorSpaceName.TryMapToColorSpace(out var colorSpaceActual))
|
||||
&& alternativeColorSpaceName.TryMapToColorSpace(out colorspaceActual))
|
||||
{
|
||||
AdvancedNonStrokingColorSpace = namedColorSpace.Name;
|
||||
CurrentNonStrokingColorSpace = colorSpaceActual;
|
||||
CurrentNonStrokingColorSpace = colorspaceActual;
|
||||
DefaultColorSpace(colorspaceActual);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -50,6 +50,7 @@
|
||||
private Stack<CurrentGraphicsState> graphicsStack = new Stack<CurrentGraphicsState>();
|
||||
private IFont activeExtendedGraphicsStateFont;
|
||||
private InlineImageBuilder inlineImageBuilder;
|
||||
private bool currentPathAdded;
|
||||
|
||||
/// <summary>
|
||||
/// A counter to track individual calls to <see cref="ShowText"/> operations used to determine if letters are likely to be
|
||||
@@ -215,16 +216,18 @@
|
||||
? currentState.CurrentNonStrokingColor
|
||||
: currentState.CurrentStrokingColor;
|
||||
|
||||
ShowGlyph(font, transformedGlyphBounds,
|
||||
var letter = new Letter(unicode, transformedGlyphBounds,
|
||||
transformedPdfBounds.BottomLeft,
|
||||
transformedPdfBounds.BottomRight,
|
||||
transformedPdfBounds.Width,
|
||||
unicode,
|
||||
fontSize,
|
||||
font.Name.Data,
|
||||
color,
|
||||
pointSize,
|
||||
textSequence);
|
||||
|
||||
letters.Add(letter);
|
||||
|
||||
decimal tx, ty;
|
||||
if (font.IsVertical)
|
||||
{
|
||||
@@ -378,12 +381,13 @@
|
||||
|
||||
public void BeginSubpath()
|
||||
{
|
||||
if (CurrentPath != null && CurrentPath.Commands.Count > 0 && !paths.Contains(CurrentPath))
|
||||
if (CurrentPath != null && CurrentPath.Commands.Count > 0 && !currentPathAdded)
|
||||
{
|
||||
paths.Add(CurrentPath);
|
||||
}
|
||||
|
||||
CurrentPath = new PdfPath();
|
||||
currentPathAdded = false;
|
||||
}
|
||||
|
||||
public void StrokePath(bool close)
|
||||
@@ -395,6 +399,7 @@
|
||||
else
|
||||
{
|
||||
paths.Add(CurrentPath);
|
||||
currentPathAdded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,6 +412,7 @@
|
||||
else
|
||||
{
|
||||
paths.Add(CurrentPath);
|
||||
currentPathAdded = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,6 +421,7 @@
|
||||
CurrentPath.ClosePath();
|
||||
paths.Add(CurrentPath);
|
||||
CurrentPath = null;
|
||||
currentPathAdded = false;
|
||||
}
|
||||
|
||||
public void SetNamedGraphicsState(NameToken stateName)
|
||||
@@ -501,28 +508,5 @@
|
||||
|
||||
TextMatrices.TextMatrix = newMatrix;
|
||||
}
|
||||
|
||||
private void ShowGlyph(IFont font, PdfRectangle glyphRectangle,
|
||||
PdfPoint startBaseLine,
|
||||
PdfPoint endBaseLine,
|
||||
decimal width,
|
||||
string unicode,
|
||||
decimal fontSize,
|
||||
IColor color,
|
||||
decimal pointSize,
|
||||
int textSequence)
|
||||
{
|
||||
var letter = new Letter(unicode, glyphRectangle,
|
||||
startBaseLine,
|
||||
endBaseLine,
|
||||
width,
|
||||
fontSize,
|
||||
font.Name.Data,
|
||||
color,
|
||||
pointSize,
|
||||
textSequence);
|
||||
|
||||
letters.Add(letter);
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,6 +4,7 @@
|
||||
|
||||
internal class OperatorToken : IDataToken<string>
|
||||
{
|
||||
private static readonly object Lock = new object();
|
||||
private static readonly Dictionary<string, string> PooledNames = new Dictionary<string, string>();
|
||||
|
||||
public static readonly OperatorToken R = new OperatorToken("R");
|
||||
@@ -24,11 +25,16 @@
|
||||
|
||||
private OperatorToken(string data)
|
||||
{
|
||||
if (!PooledNames.TryGetValue(data, out var stored))
|
||||
string stored;
|
||||
|
||||
lock (Lock)
|
||||
{
|
||||
if (!PooledNames.TryGetValue(data, out stored))
|
||||
{
|
||||
stored = data;
|
||||
PooledNames[data] = stored;
|
||||
}
|
||||
}
|
||||
|
||||
Data = stored;
|
||||
}
|
||||
|
Reference in New Issue
Block a user