Skip to content

Commit

Permalink
Should give it al better full-size calculation.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed May 21, 2022
1 parent 95d1e97 commit e3e219f
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions osu.Framework.Font/Utils/TextBuilderGlyphUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
});
}

Expand All @@ -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),
});
}
}
Expand Down

0 comments on commit e3e219f

Please sign in to comment.