//
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
namespace ImageSharp.Drawing
{
///
/// Options for influencing the drawing functions.
///
public struct TextGraphicsOptions
{
///
/// Represents the default .
///
public static readonly TextGraphicsOptions Default = new TextGraphicsOptions(true);
///
/// Whether antialiasing should be applied.
///
public bool Antialias;
///
/// The number of subpixels to use while rendering with antialiasing enabled.
///
public int AntialiasSubpixelDepth;
///
/// Whether the text should be drawing with kerning enabled.
///
public bool ApplyKerning;
///
/// The number of space widths a tab should lock to.
///
public float TabWidth;
///
/// Flag weather to use the current image resultion to for point size scaling.
/// If this is [false] the text renders at 72dpi otherwise it renders at Image resolution
///
public bool UseImageResolution;
///
/// Initializes a new instance of the struct.
///
/// If set to true [enable antialiasing].
public TextGraphicsOptions(bool enableAntialiasing)
{
this.Antialias = enableAntialiasing;
this.ApplyKerning = true;
this.TabWidth = 4;
this.AntialiasSubpixelDepth = 16;
this.UseImageResolution = false;
}
///
/// Performs an implicit conversion from to .
///
/// The options.
///
/// The result of the conversion.
///
public static implicit operator TextGraphicsOptions(GraphicsOptions options)
{
return new TextGraphicsOptions(options.Antialias)
{
AntialiasSubpixelDepth = options.AntialiasSubpixelDepth
};
}
///
/// Performs an explicit conversion from to .
///
/// The options.
///
/// The result of the conversion.
///
public static explicit operator GraphicsOptions(TextGraphicsOptions options)
{
return new GraphicsOptions(options.Antialias)
{
AntialiasSubpixelDepth = options.AntialiasSubpixelDepth
};
}
}
}