Exemple #1
0
 public Label()
 {
     Font    = new FontUsage(size: 18);
     Padding = new MarginPadding {
         Horizontal = 2
     };
 }
Exemple #2
0
        private void load(ISkinSource skin)
        {
            Font    = new FontUsage(skin.GetFontPrefix(font), 1, fixedWidth: true);
            Spacing = new Vector2(-skin.GetFontOverlap(font), 0);

            glyphStore = new LegacyGlyphStore(skin);
        }
Exemple #3
0
        /// <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));
        }
Exemple #4
0
        public LegacySpriteText(ISkin skin, string font = "score")
        {
            Shadow             = false;
            UseFullGlyphHeight = false;

            Font       = new FontUsage(font, 1);
            glyphStore = new LegacyGlyphStore(skin);
        }
Exemple #5
0
 public BarInfoText(BindablePage page)
 {
     _page.BindTo(page);
     Margin = new MarginPadding {
         Top = 40
     };
     Font = new FontUsage().With(size: 150);
 }
Exemple #6
0
            public LegacySpriteText(ISkin skin, string font)
            {
                Shadow             = false;
                UseFullGlyphHeight = false;

                Font       = new FontUsage(font, OsuFont.DEFAULT_FONT_SIZE);
                glyphStore = new LegacyGlyphStore(skin);
            }
Exemple #7
0
 public InfoText()
 {
     Padding      = new MarginPadding(10);
     Font         = new FontUsage().With(size: 55);
     Colour       = Config.Colors["Foreground"];
     Shadow       = true;
     ShadowColour = Color4.Black;
     ShadowOffset = new Vector2(0.04f, 0.04f);
     Depth        = -1;
 }
        public LegacySpriteText(ISkin skin, LegacyFont font)
        {
            Shadow = false;
            UseFullGlyphHeight = false;

            Font = new FontUsage(skin.GetFontPrefix(font), 1, fixedWidth: true);
            Spacing = new Vector2(-skin.GetFontOverlap(font), 0);

            glyphStore = new LegacyGlyphStore(skin);
        }
Exemple #9
0
        private void load()
        {
            fontLarge  = OsuFont.GetFont(size: 16);
            fontMedium = OsuFont.GetFont(size: 12);

            Children = new[]
            {
                createTitle(),
                createMessage()
            };
        }
Exemple #10
0
 public TruncatingTextBuilder(ITexturedGlyphLookupStore store, FontUsage font, float maxWidth, string ellipsisString = null, bool useFontSizeAsHeight = true, Vector2 startOffset = default,
                              Vector2 spacing = default, List <TextBuilderGlyph> characterList = null, char[] neverFixedWidthCharacters = null, char fallbackCharacter = '?', char fixedWidthReferenceCharacter = 'm')
     : base(store, font, maxWidth, useFontSizeAsHeight, startOffset, spacing, characterList, neverFixedWidthCharacters, fallbackCharacter, fixedWidthReferenceCharacter)
 {
     this.store                     = store;
     this.font                      = font;
     this.ellipsisString            = ellipsisString;
     this.useFontSizeAsHeight       = useFontSizeAsHeight;
     this.spacing                   = spacing;
     this.neverFixedWidthCharacters = neverFixedWidthCharacters;
     this.fallbackCharacter         = fallbackCharacter;
 }
Exemple #11
0
        /// <summary>
        /// Creates a new <see cref="TextBuilder"/>.
        /// </summary>
        /// <param name="store">The store from which glyphs are to be retrieved from.</param>
        /// <param name="mainTextFont">The main text's font.<paramref name="store"/>.</param>
        /// <param name="font">The font to use for glyph lookups from <paramref name="store"/>.</param>
        /// <param name="useFontSizeAsHeight">True to use the provided <see cref="font"/> size as the height for each line. False if the height of each individual glyph should be used.</param>
        /// <param name="startOffset">The offset at which characters should begin being added at.</param>
        /// <param name="spacing">The spacing between characters.</param>
        /// <param name="maxWidth">The maximum width of the resulting text bounds.</param>
        /// <param name="characterList">That list to contain all resulting <see cref="TextBuilderGlyph"/>s.</param>
        /// <param name="neverFixedWidthCharacters">The characters for which fixed width should never be applied.</param>
        /// <param name="fallbackCharacter">The character to use if a glyph lookup fails.</param>
        /// <param name="fixedWidthReferenceCharacter">The character to use to calculate the fixed width width. Defaults to 'm'.</param>
        /// <param name="relativePosition">Should be added into top or bottom.</param>
        /// <param name="alignment">Lyric text alignment.</param>
        public PositionTextBuilder(ITexturedGlyphLookupStore store, FontUsage mainTextFont, FontUsage font, float maxWidth, bool useFontSizeAsHeight = true, Vector2 startOffset = default,
                                   Vector2 spacing        = default, List <TextBuilderGlyph> characterList = null, char[] neverFixedWidthCharacters = null,
                                   char fallbackCharacter = '?', char fixedWidthReferenceCharacter         = 'm', RelativePosition relativePosition = RelativePosition.Top, LyricTextAlignment alignment = LyricTextAlignment.Auto)
            : base(store, font, maxWidth, useFontSizeAsHeight, startOffset, spacing, characterList, neverFixedWidthCharacters, fallbackCharacter, fixedWidthReferenceCharacter)
        {
            this.store             = store;
            this.mainTextFont      = mainTextFont;
            this.font              = font;
            this.startOffset       = startOffset;
            this.spacing           = spacing;
            this.fallbackCharacter = fallbackCharacter;

            this.relativePosition = relativePosition;
            this.alignment        = alignment;
        }
Exemple #12
0
        /// <summary>
        /// Creates a new <see cref="TextBuilder"/>.
        /// </summary>
        /// <param name="store">The store from which glyphs are to be retrieved from.</param>
        /// <param name="font">The font to use for glyph lookups from <paramref name="store"/>.</param>
        /// <param name="useFontSizeAsHeight">True to use the provided <see cref="font"/> size as the height for each line. False if the height of each individual glyph should be used.</param>
        /// <param name="startOffset">The offset at which characters should begin being added at.</param>
        /// <param name="spacing">The spacing between characters.</param>
        /// <param name="maxWidth">The maximum width of the resulting text bounds.</param>
        /// <param name="characterList">That list to contain all resulting <see cref="TextBuilderGlyph"/>s.</param>
        /// <param name="neverFixedWidthCharacters">The characters for which fixed width should never be applied.</param>
        /// <param name="fallbackCharacter">The character to use if a glyph lookup fails.</param>
        public TextBuilder(ITexturedGlyphLookupStore store, FontUsage font, float maxWidth = float.MaxValue, bool useFontSizeAsHeight = true, Vector2 startOffset = default, Vector2 spacing = default,
                           List <TextBuilderGlyph> characterList = null, char[] neverFixedWidthCharacters = null, char fallbackCharacter = '?')
        {
            this.store = store;
            this.font  = font;
            this.useFontSizeAsHeight = useFontSizeAsHeight;
            this.startOffset         = startOffset;
            this.spacing             = spacing;
            this.maxWidth            = maxWidth;

            Characters = characterList ?? new List <TextBuilderGlyph>();
            this.neverFixedWidthCharacters = neverFixedWidthCharacters ?? Array.Empty <char>();
            this.fallbackCharacter         = fallbackCharacter;

            currentPos = startOffset;
        }
Exemple #13
0
            public BasicDropdownHeader()
            {
                var font = new FontUsage("RobotoCondensed", weight: "Regular");

                Foreground.Padding    = new MarginPadding(5);
                BackgroundColour      = FrameworkColour.Green;
                BackgroundColourHover = FrameworkColour.YellowGreen;
                Children = new[]
                {
                    label = new SpriteText
                    {
                        AlwaysPresent = true,
                        Font          = font,
                        Height        = font.Size,
                    },
                };
            }
Exemple #14
0
            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,
                    },
                };
            }
        protected BindableFontUsage SetDefault(KaraokeRulesetSetting setting, FontUsage fontUsage, float?minFontSize = null, float?maxFontSize = null)
        {
            base.SetDefault(setting, fontUsage);

            // Should not use base.setDefault's value because it will return Bindable<FontUsage>, not BindableFontUsage
            var bindable = GetOriginalBindable <FontUsage>(setting);

            if (!(bindable is BindableFontUsage bindableFontUsage))
            {
                throw new InvalidCastException(nameof(bindable));
            }

            // Assign size restriction in here.
            if (minFontSize.HasValue)
            {
                bindableFontUsage.MinFontSize = minFontSize.Value;
            }
            if (maxFontSize.HasValue)
            {
                bindableFontUsage.MaxFontSize = maxFontSize.Value;
            }

            return(bindableFontUsage);
        }
 public TextColumn(string title, FontUsage font)
     : this(title, new OsuSpriteText {
     Font = font
 })
 {
 }
Exemple #17
0
 public SmallText()
 {
     Font = new FontUsage(size: 20);
 }
Exemple #18
0
 public GlyphEntry(FontUsage font, ITexturedCharacterGlyph glyph)
 {
     Font  = font;
     Glyph = glyph;
 }
Exemple #19
0
 public CounterText()
 {
     Font = new FontUsage(fixedWidth: true);
 }
Exemple #20
0
        public DetailsDisplay()
        {
            this.RelativeSizeAxes = Axes.X;
            this.Height           = 100;
            this.Width            = 0.5f;
            FontUsage defaultFont   = FontUsage.Default.With(size: 30);
            Anchor    defaultAnchor = Anchor.TopCentre;

            this.Children = new Drawable[]
            {
                new Box
                {
                    RelativeSizeAxes = Axes.Both,
                    Colour           = new Colour4(40, 40, 40, 255),
                },
                new FillFlowContainer
                {
                    RelativeSizeAxes = Axes.Both,
                    Spacing          = new Vector2(35, 0),
                    Position         = new Vector2(0, 20),
                    Children         = new Drawable[]
                    {
                        new SpriteText
                        {
                            Anchor = defaultAnchor,
                            Origin = defaultAnchor,
                            Text   = "Song Length",
                            Font   = defaultFont,
                        },
                        new SpriteText
                        {
                            Anchor = defaultAnchor,
                            Origin = defaultAnchor,
                            Text   = "Bpm",
                            Font   = defaultFont,
                        },
                        new SpriteText
                        {
                            Anchor = defaultAnchor,
                            Origin = defaultAnchor,
                            Text   = "Average Nps",
                            Font   = defaultFont,
                        },
                        new SpriteText
                        {
                            Anchor = defaultAnchor,
                            Origin = defaultAnchor,
                            Text   = "Object Count",
                            Font   = defaultFont,
                        },
                        new SpriteText
                        {
                            Anchor = defaultAnchor,
                            Origin = defaultAnchor,
                            Text   = "Key Count",
                            Font   = defaultFont,
                        },
                        new SpriteText
                        {
                            Anchor = defaultAnchor,
                            Origin = defaultAnchor,
                            Text   = "Drain rate",
                            Font   = defaultFont,
                        },
                        new SpriteText
                        {
                            Anchor = defaultAnchor,
                            Origin = defaultAnchor,
                            Text   = "Difficulty",
                            Font   = defaultFont,
                        },
                    },
                },
            };
        }
Exemple #21
0
 public Provider(FontUsage font)
 {
     _font = font;
 }
 public MultilineTextBuilder(ITexturedGlyphLookupStore store, FontUsage font, float maxWidth, bool useFontSizeAsHeight = true, Vector2 startOffset = default, Vector2 spacing = default,
                             List <TextBuilderGlyph> characterList = null, char[] neverFixedWidthCharacters = null, char fallbackCharacter = '?', char fixedWidthReferenceCharacter = 'm')
     : base(store, font, maxWidth, useFontSizeAsHeight, startOffset, spacing, characterList, neverFixedWidthCharacters, fallbackCharacter, fixedWidthReferenceCharacter)
 {
 }
 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.",
 });
Exemple #24
0
        private void updateFont()
        {
            FontUsage usage = useAlternates.Value ? OsuFont.TorusAlternate : OsuFont.Torus;

            spriteText.Font = usage.With(size: 40, weight: weight.Value);
        }
Exemple #25
0
 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 TextColumn(string title, FontUsage font, float?minWidth = null)
     : this(title, new OsuSpriteText {
     Font = font
 }, minWidth)
 {
 }
Exemple #27
0
 public NoFixedWidthSpaceText()
 {
     Font = new FontUsage(fixedWidth: true);
 }