1.0.12 & 1.0.12.1

+ Utility Methods for texture transformations

~ Fixed an issue, where the horizontal & vertical flip was wrongly applied
~ Added missing summaries
This commit is contained in:
Michel Fedde 2021-05-05 17:36:12 +02:00
parent a29a2cab53
commit f11a954b5a
10 changed files with 116 additions and 21 deletions

View file

@ -18,6 +18,9 @@ namespace SM.Base.Drawing.Text
/// </summary>
public int Advance;
/// <summary>
/// The bearing for this char.
/// </summary>
public float BearingX;
/// <summary>
@ -26,6 +29,9 @@ namespace SM.Base.Drawing.Text
public float Width;
/// <summary>
/// Matrix for the texture.
/// </summary>
public Matrix3 TextureMatrix;
}
}

View file

@ -11,21 +11,45 @@ using SM.Base.Textures;
namespace SM.Base.Drawing.Text
{
/// <summary>
/// Represents a font to be used in DrawText-classes.
/// </summary>
public class Font : Texture
{
private static Library _lib;
private Face _fontFace;
/// <summary>
/// The amount the cursor should move forward when a space was found.
/// </summary>
public float SpaceWidth { get; private set; } = 0;
/// <summary>
/// The char set the font should contain.
/// <para>See <see cref="FontCharStorage"/> for some default values.</para>
/// <para>Default: <see cref="FontCharStorage.SimpleUTF8"/></para>
/// </summary>
public ICollection<char> CharSet { get; set; } = FontCharStorage.SimpleUTF8;
/// <summary>
/// The font-size defines how large the result texture should be.
/// <para>Lower equals less quality, but also less memory usage.</para>
/// <para>Higher equals high quality, but also high memory usage.</para>
/// <para>Default: 12</para>
/// </summary>
public float FontSize { get; set; } = 12;
/// <summary>
/// The character positions.
/// </summary>
public Dictionary<char, CharParameter> Positions = new Dictionary<char, CharParameter>();
/// <summary>
/// Creates a font, by using a path
/// </summary>
/// <param name="path">Path to the font-file.</param>
public Font(string path)
{
_lib ??= new Library();
@ -34,6 +58,9 @@ namespace SM.Base.Drawing.Text
UnpackAlignment = 1;
}
/// <summary>
/// (Re-)Generates the texture.
/// </summary>
public void RegenerateTexture()
{
Width = Height = 0;
@ -88,6 +115,7 @@ namespace SM.Base.Drawing.Text
}
}
/// <inheritdoc />
public override void Compile()
{
RegenerateTexture();

View file

@ -10,10 +10,22 @@ using SM.Base.Window;
namespace SM.Base.Drawing.Text
{
/// <summary>
/// Represents the options for <see cref="TextDrawingBasis{TTransform}.Origin"/>
/// </summary>
public enum TextOrigin
{
/// <summary>
/// The position equals (0,0) in the left side of the text.
/// </summary>
Left,
/// <summary>
/// The position equals (0,0) in the center of the text.
/// </summary>
Center,
/// <summary>
/// The position equals (0,0) in the right side of the text.
/// </summary>
Right
}