mirror of https://github.com/ppy/osu
change heading font weight
h1 and h2 : Semi Bold (600) -376cac43a0/resources/assets/less/bem/osu-md.less (L111)
-376cac43a0/resources/assets/less/bem/osu-md.less (L135)
The rest of heading : Bold (700) -376cac43a0/resources/assets/less/bem/osu-md.less (L97)
This commit is contained in:
parent
bfc328c5ab
commit
63381ff4f2
|
@ -3,16 +3,25 @@
|
|||
|
||||
using Markdig.Syntax;
|
||||
using osu.Framework.Graphics.Containers.Markdown;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Graphics.Containers.Markdown
|
||||
{
|
||||
public class OsuMarkdownHeading : MarkdownHeading
|
||||
{
|
||||
private readonly int level;
|
||||
|
||||
public OsuMarkdownHeading(HeadingBlock headingBlock)
|
||||
: base(headingBlock)
|
||||
{
|
||||
level = headingBlock.Level;
|
||||
}
|
||||
|
||||
public override MarkdownTextFlowContainer CreateTextFlow() => new HeadingTextFlowContainer
|
||||
{
|
||||
Weight = GetFontWeightByLevel(level),
|
||||
};
|
||||
|
||||
protected override float GetFontSizeByLevel(int level)
|
||||
{
|
||||
const float base_font_size = 14;
|
||||
|
@ -38,5 +47,30 @@ protected override float GetFontSizeByLevel(int level)
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual FontWeight GetFontWeightByLevel(int level)
|
||||
{
|
||||
switch (level)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
return FontWeight.SemiBold;
|
||||
|
||||
default:
|
||||
return FontWeight.Bold;
|
||||
}
|
||||
}
|
||||
|
||||
private class HeadingTextFlowContainer : OsuMarkdownTextFlowContainer
|
||||
{
|
||||
public FontWeight Weight { get; set; }
|
||||
|
||||
protected override SpriteText CreateSpriteText()
|
||||
{
|
||||
var spriteText = base.CreateSpriteText();
|
||||
spriteText.Font = spriteText.Font.With(weight: Weight);
|
||||
return spriteText;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue