From e3e219f00cbd151e06119c0f964b12aed69bbe36 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 21 May 2022 16:04:39 +0800 Subject: [PATCH] Should give it al better full-size calculation. --- .../Utils/TextBuilderGlyphUtils.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/osu.Framework.Font/Utils/TextBuilderGlyphUtils.cs b/osu.Framework.Font/Utils/TextBuilderGlyphUtils.cs index 0e8fe9f..b07a342 100644 --- a/osu.Framework.Font/Utils/TextBuilderGlyphUtils.cs +++ b/osu.Framework.Font/Utils/TextBuilderGlyphUtils.cs @@ -7,20 +7,23 @@ namespace osu.Framework.Utils { - public class TextBuilderGlyphUtils + public static class TextBuilderGlyphUtils { + private static float getCharacterTopOffset(ICharacterGlyph character) + => character.Baseline * 0.3f; + + private static float getCharacterBottomOffset(ICharacterGlyph character) + => character.Baseline * 0.03f; + public static RectangleF GetCharacterRectangle(TextBuilderGlyph character, bool drawSizeOnly) { if (drawSizeOnly) return character.DrawRectangle; - // todo: should get the real value. - var topReduce = character.Baseline * 0.3f; - var bottomIncrease = character.Baseline * 0.2f; return character.DrawRectangle.Inflate(new MarginPadding { - Top = character.YOffset - topReduce, - Bottom = character.Baseline - character.Height - character.YOffset + bottomIncrease, + Top = character.YOffset - getCharacterTopOffset(character), + Bottom = character.Baseline - character.Height - character.YOffset + getCharacterBottomOffset(character), }); } @@ -29,13 +32,10 @@ public static RectangleF GetCharacterRectangle(PositionTextBuilderGlyph characte if (drawSizeOnly) return character.DrawRectangle; - // todo: should get the real value. - var topReduce = character.Baseline * 0.3f; - var bottomIncrease = character.Baseline * 0.2f; return character.DrawRectangle.Inflate(new MarginPadding { - Top = character.YOffset - topReduce, - Bottom = character.Baseline - character.Height - character.YOffset + bottomIncrease, + Top = character.YOffset - getCharacterTopOffset(character), + Bottom = character.Baseline - character.Height - character.YOffset + getCharacterBottomOffset(character), }); } }