2018-01-10 19:49:32 +00:00
|
|
|
|
namespace UglyToad.PdfPig.Graphics.Operations.TextState
|
2017-11-22 18:41:34 +00:00
|
|
|
|
{
|
2018-12-02 16:14:55 +00:00
|
|
|
|
using System.IO;
|
2017-11-29 22:55:53 +00:00
|
|
|
|
|
2019-01-01 18:00:04 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Sets the word spacing.
|
|
|
|
|
|
/// </summary>
|
2019-01-03 22:20:53 +00:00
|
|
|
|
public class SetWordSpacing : IGraphicsStateOperation
|
2017-11-22 18:41:34 +00:00
|
|
|
|
{
|
2019-01-01 18:00:04 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The symbol for this operation in a stream.
|
|
|
|
|
|
/// </summary>
|
2017-11-22 18:41:34 +00:00
|
|
|
|
public const string Symbol = "Tw";
|
|
|
|
|
|
|
2019-01-01 18:00:04 +00:00
|
|
|
|
/// <inheritdoc />
|
2017-11-22 18:41:34 +00:00
|
|
|
|
public string Operator => Symbol;
|
|
|
|
|
|
|
2019-01-01 18:00:04 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Sets the width of the space ' ' character. For horizontal
|
|
|
|
|
|
/// writing positive values increase the gap between words separated by space, for vertical writing
|
|
|
|
|
|
/// positive values decrease the gap.
|
|
|
|
|
|
/// </summary>
|
2017-11-22 18:41:34 +00:00
|
|
|
|
public decimal Spacing { get; }
|
|
|
|
|
|
|
2019-01-01 18:00:04 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a new <see cref="SetWordSpacing"/>.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="spacing">The word spacing.</param>
|
2017-11-22 18:41:34 +00:00
|
|
|
|
public SetWordSpacing(decimal spacing)
|
|
|
|
|
|
{
|
|
|
|
|
|
Spacing = spacing;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-01 18:00:04 +00:00
|
|
|
|
/// <inheritdoc />
|
2019-01-03 22:20:53 +00:00
|
|
|
|
public void Run(IOperationContext operationContext)
|
2017-11-29 22:55:53 +00:00
|
|
|
|
{
|
|
|
|
|
|
var currentState = operationContext.GetCurrentState();
|
|
|
|
|
|
|
|
|
|
|
|
currentState.FontState.WordSpacing = Spacing;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-01 18:00:04 +00:00
|
|
|
|
/// <inheritdoc />
|
2018-12-02 16:14:55 +00:00
|
|
|
|
public void Write(Stream stream)
|
|
|
|
|
|
{
|
2019-01-01 18:00:04 +00:00
|
|
|
|
stream.WriteNumberText(Spacing, Symbol);
|
2018-12-02 16:14:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-01 18:00:04 +00:00
|
|
|
|
/// <inheritdoc />
|
2017-11-22 18:41:34 +00:00
|
|
|
|
public override string ToString()
|
|
|
|
|
|
{
|
|
|
|
|
|
return $"{Spacing} {Symbol}";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|