Renderer:
+ Font.BaselineAdjust Utils: + GameControllerState.AnyInteractions
This commit is contained in:
parent
89de4258e1
commit
dffa581596
18 changed files with 70 additions and 40 deletions
|
|
@ -39,9 +39,16 @@ namespace SM.Base.Drawing
|
|||
/// <summary>
|
||||
/// Returns the current model matrix.
|
||||
/// </summary>
|
||||
/// <param name="force">If set to true, it will always (re-)calculate the model matrix.</param>
|
||||
/// <returns></returns>
|
||||
public Matrix4 GetMatrix()
|
||||
public Matrix4 GetMatrix(bool force = false)
|
||||
{
|
||||
if (force)
|
||||
{
|
||||
_lastFrame = SMRenderer.CurrentFrame;
|
||||
return _modelMatrix = RequestMatrix();
|
||||
}
|
||||
|
||||
if (Ignore) return Matrix4.Identity;
|
||||
|
||||
if (_lastFrame != SMRenderer.CurrentFrame)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,12 @@ namespace SM.Base.Drawing.Text
|
|||
/// </summary>
|
||||
public float FontSize { get; set; } = 12;
|
||||
|
||||
/// <summary>
|
||||
/// Allows to adjust the baseline to fix clipping issues.
|
||||
/// <para>Due to some issues with the calculations, this is a temporary fix.</para>
|
||||
/// </summary>
|
||||
public float BaselineAdjust { get; set; } = 1f;
|
||||
|
||||
/// <summary>
|
||||
/// The character positions.
|
||||
/// </summary>
|
||||
|
|
@ -64,6 +70,8 @@ namespace SM.Base.Drawing.Text
|
|||
public void RegenerateTexture()
|
||||
{
|
||||
Width = Height = 0;
|
||||
|
||||
//Height = Math.Abs(_fontFace.BBox.Bottom) + _fontFace.BBox.Top;
|
||||
Positions = new Dictionary<char, CharParameter>();
|
||||
|
||||
_fontFace.SetCharSize(0, FontSize, 0, 96);
|
||||
|
|
@ -83,7 +91,7 @@ namespace SM.Base.Drawing.Text
|
|||
|
||||
float bBoxHeight = (Math.Abs(_fontFace.BBox.Bottom) + _fontFace.BBox.Top);
|
||||
float bBoxTopScale = _fontFace.BBox.Top / bBoxHeight;
|
||||
float baseline = Height * bBoxTopScale + 1;
|
||||
float baseline = (Height * bBoxTopScale) + BaselineAdjust;
|
||||
|
||||
Map = new Bitmap(Width, Height);
|
||||
using (Graphics g = Graphics.FromImage(Map))
|
||||
|
|
@ -95,8 +103,7 @@ namespace SM.Base.Drawing.Text
|
|||
{
|
||||
_fontFace.LoadChar(keyvalue.Key, LoadFlags.Render, LoadTarget.Normal);
|
||||
|
||||
int y = ((int)baseline - (int)_fontFace.Glyph.Metrics.HorizontalBearingY);
|
||||
|
||||
int y = ((int)baseline - (int) _fontFace.Glyph.Metrics.HorizontalBearingY);
|
||||
g.DrawImageUnscaled(_fontFace.Glyph.Bitmap.ToGdipBitmap(Color.White), (int)keyvalue.Value[1], y);
|
||||
|
||||
Vector2 offset = new Vector2(keyvalue.Value[1] / Width, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue