/// <summary> /// Creates a new <see cref="FontUsage"/> by applying adjustments to this <see cref="FontUsage"/>. /// </summary> /// <param name="typeface">The font typeface. If null, the value is copied from this <see cref="FontUsage"/>.</param> /// <param name="size">The text size. If null, the value is copied from this <see cref="FontUsage"/>.</param> /// <param name="weight">The font weight. If null, the value is copied from this <see cref="FontUsage"/>.</param> /// <param name="italics">Whether the font is italic. If null, the value is copied from this <see cref="FontUsage"/>.</param> /// <param name="fixedWidth">Whether all characters should be spaced apart the same distance. If null, the value is copied from this <see cref="FontUsage"/>.</param> /// <returns>The resulting <see cref="FontUsage"/>.</returns> public static FontUsage With(this FontUsage usage, Typeface?typeface = null, float?size = null, FontWeight?weight = null, bool?italics = null, bool?fixedWidth = null) { string familyString = typeface != null?OsuFont.GetFamilyString(typeface.Value) : usage.Family; string weightString = weight != null?OsuFont.GetWeightString(familyString, weight.Value) : usage.Weight; return(usage.With(familyString, size, weightString, italics, fixedWidth)); }
public GlowingSpriteText(string text, FontUsage font, Color4 textColour, Color4 glowColour) { AutoSizeAxes = Axes.Both; Children = new Drawable[] { new BufferedContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, BlurSigma = new Vector2(4), CacheDrawnFrameBuffer = true, RelativeSizeAxes = Axes.Both, Blending = BlendingMode.Additive, Size = new Vector2(3f), Children = new[] { new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, Font = font.With(fixedWidth: true), Text = text, Colour = glowColour, Shadow = false, }, }, }, new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, Font = font.With(fixedWidth: true), Text = text, Colour = textColour, Shadow = false, }, }; }
public static FontUsage With(this FontUsage usage, FontWeight?weight = null, float?size = null, bool?italics = null, bool?fixedWidth = null) => usage.With("SegoeUI", size, weight?.ToString(), italics, fixedWidth);
public void AddText(FontUsage font) => flow.Add(new SpriteText { Margin = new MarginPadding(20), Font = font.With(size: 32), Text = @"The quick fox jumps over the lazy dog.", });
private void updateFont() { FontUsage usage = useAlternates.Value ? OsuFont.TorusAlternate : OsuFont.Torus; spriteText.Font = usage.With(size: 40, weight: weight.Value); }