2017-11-26 22:19:42 +00:00
|
|
|
|
// ReSharper disable RedundantDefaultMemberInitializer
|
2018-01-10 19:49:32 +00:00
|
|
|
|
namespace UglyToad.PdfPig.Graphics
|
2017-11-26 22:19:42 +00:00
|
|
|
|
{
|
|
|
|
|
|
using Core;
|
2019-07-06 14:03:23 +01:00
|
|
|
|
using Operations.SpecialGraphicsState;
|
2018-01-10 19:49:32 +00:00
|
|
|
|
using PdfPig.Core;
|
2018-11-16 20:00:12 +00:00
|
|
|
|
using Tokens;
|
2017-11-26 22:19:42 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The current state of text related parameters for a content stream.
|
|
|
|
|
|
/// </summary>
|
2019-01-03 22:20:53 +00:00
|
|
|
|
public class CurrentFontState : IDeepCloneable<CurrentFontState>
|
2017-11-26 22:19:42 +00:00
|
|
|
|
{
|
2019-07-06 14:03:23 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Whether the font comes from the extended graphics state via the <see cref="SetGraphicsStateParametersFromDictionary"/> operator.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool FromExtendedGraphicsState { get; set; } = false;
|
|
|
|
|
|
|
2017-11-26 22:19:42 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A value in unscaled text space units which is added to the horizontal (or vertical if in vertical writing mode)
|
|
|
|
|
|
/// glyph displacement.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// In horizontal writing mode a positive value will expand the distance between letters/glyphs.
|
|
|
|
|
|
/// Default value 0.
|
|
|
|
|
|
/// </remarks>
|
|
|
|
|
|
public decimal CharacterSpacing { get; set; } = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// As for <see cref="CharacterSpacing"/> but applies only for the space character (32).
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// Default value 0.
|
|
|
|
|
|
/// </remarks>
|
|
|
|
|
|
public decimal WordSpacing { get; set; } = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Adjusts the width of glyphs/letters by stretching (or compressing) them horizontally.
|
|
|
|
|
|
/// Value is a percentage of the normal width.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public decimal HorizontalScaling { get; set; } = 100;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The vertical distance in unscaled text space units between the baselines of lines of text.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public decimal Leading { get; set; }
|
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The name of the currently active font.
|
|
|
|
|
|
/// </summary>
|
2018-01-19 00:35:04 +00:00
|
|
|
|
public NameToken FontName { get; set; }
|
2017-11-26 22:19:42 +00:00
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The current font size.
|
|
|
|
|
|
/// </summary>
|
2017-11-26 22:19:42 +00:00
|
|
|
|
public decimal FontSize { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// The <see cref="TextRenderingMode"/> for glyph outlines.
|
2017-11-26 22:19:42 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// When the rendering mode requires filling the current non-stroking color in the state is used.<br/>
|
|
|
|
|
|
/// When the rendering mode requires stroking the current stroking color in the state is used.<br/>
|
|
|
|
|
|
/// The rendering mode has no impact on Type 3 fonts.
|
|
|
|
|
|
/// </remarks>
|
2019-01-03 22:20:53 +00:00
|
|
|
|
public TextRenderingMode TextRenderingMode { get; set; } = TextRenderingMode.Fill;
|
2017-11-26 22:19:42 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The distance in unscaled text space units to move the default baseline either up or down.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// Always applies to the vertical coordinate irrespective or writing mode.
|
|
|
|
|
|
/// </remarks>
|
|
|
|
|
|
public decimal Rise { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// Are all glyphs in a text object treated as a single elementary object for the purpose of the transparent imaging model?
|
2017-11-26 22:19:42 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool Knockout { get; set; }
|
|
|
|
|
|
|
2019-01-03 22:20:53 +00:00
|
|
|
|
/// <inheritdoc />
|
2017-11-26 22:19:42 +00:00
|
|
|
|
public CurrentFontState DeepClone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new CurrentFontState
|
|
|
|
|
|
{
|
|
|
|
|
|
CharacterSpacing = CharacterSpacing,
|
2019-01-03 22:20:53 +00:00
|
|
|
|
TextRenderingMode = TextRenderingMode,
|
2017-11-26 22:19:42 +00:00
|
|
|
|
Rise = Rise,
|
|
|
|
|
|
Leading = Leading,
|
|
|
|
|
|
WordSpacing = WordSpacing,
|
|
|
|
|
|
FontName = FontName,
|
|
|
|
|
|
FontSize = FontSize,
|
|
|
|
|
|
HorizontalScaling = HorizontalScaling,
|
|
|
|
|
|
Knockout = Knockout
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|