예제 #1
0
 public FontGenerator GetFont(LyricFont fontType)
 {
     return(LoadFont($"sb/f/{GetFontString(fontType)}", new FontDescription {
         FontPath = GetFontPath(fontType),
         FontSize = 30
     }));
 }
예제 #2
0
        protected virtual void ApplyFont(LyricFont font)
        {
            // From text sample
            KaraokeText.FrontTextTexture = new SolidTexture {
                SolidColor = Color4.Blue
            };                                                                            // font.FrontTextBrushInfo.TextBrush.ConvertToTextureSample();
            KaraokeText.FrontBorderTexture     = font.FrontTextBrushInfo.BorderBrush.ConvertToTextureSample();
            KaraokeText.FrontTextShadowTexture = font.FrontTextBrushInfo.ShadowBrush.ConvertToTextureSample();

            // Back text sample
            KaraokeText.BackTextTexture       = font.BackTextBrushInfo.TextBrush.ConvertToTextureSample();
            KaraokeText.BackBorderTexture     = font.BackTextBrushInfo.BorderBrush.ConvertToTextureSample();
            KaraokeText.BackTextShadowTexture = font.BackTextBrushInfo.ShadowBrush.ConvertToTextureSample();

            // Apply text font info
            var lyricFont = font.LyricTextFontInfo.LyricTextFontInfo;

            KaraokeText.Font         = new FontUsage(size: lyricFont.CharSize); // TODO : FontName and Bold
            KaraokeText.Border       = lyricFont.EdgeSize > 0;
            KaraokeText.BorderRadius = lyricFont.EdgeSize;

            var rubyFont = font.RubyTextFontInfo.LyricTextFontInfo;

            KaraokeText.RubyFont = new FontUsage(size: rubyFont.CharSize); // TODO : FontName and Bold

            var romajiFont = font.RomajiTextFontInfo.LyricTextFontInfo;

            KaraokeText.RomajiFont = new FontUsage(size: romajiFont.CharSize); // TODO : FontName and Bold

            // Apply shadow
            KaraokeText.Shadow       = font.UseShadow;
            KaraokeText.ShadowOffset = font.ShadowOffset;
        }
예제 #3
0
        protected virtual void ApplyFont(LyricFont font)
        {
            foreach (var lyricPiece in lyricPieces)
            {
                lyricPiece.ApplyFont(font);

                // Apply text font info
                var lyricFont = font.LyricTextFontInfo.LyricTextFontInfo;
                lyricPiece.Font = getFont(KaraokeRulesetSetting.MainFont, lyricFont.CharSize);

                var rubyFont = font.RubyTextFontInfo.LyricTextFontInfo;
                lyricPiece.RubyFont = getFont(KaraokeRulesetSetting.RubyFont, rubyFont.CharSize);

                var romajiFont = font.RomajiTextFontInfo.LyricTextFontInfo;
                lyricPiece.RomajiFont = getFont(KaraokeRulesetSetting.RomajiFont, romajiFont.CharSize);
            }

            // Apply translate font.
            translateText.Font = getFont(KaraokeRulesetSetting.TranslateFont);

            FontUsage getFont(KaraokeRulesetSetting setting, float?charSize = null)
            {
                // todo : should interfact with skin font
                var forceUseDefault = forceUseDefaultFont();
                var font            = config?.Get <FontUsage>(setting) ?? FontUsage.Default;

                if (forceUseDefault || charSize == null)
                {
                    return(font);
                }

                return(font.With(size: charSize.Value));

                bool forceUseDefaultFont()
                {
                    switch (setting)
                    {
                    case KaraokeRulesetSetting.MainFont:
                    case KaraokeRulesetSetting.RubyFont:
                    case KaraokeRulesetSetting.RomajiFont:
                        return(config?.Get <bool>(KaraokeRulesetSetting.ForceUseDefaultFont) ?? false);

                    case KaraokeRulesetSetting.TranslateFont:
                        return(config?.Get <bool>(KaraokeRulesetSetting.ForceUseDefaultTranslateFont) ?? false);

                    default:
                        throw new InvalidOperationException(nameof(setting));
                    }
                }
            }
        }
예제 #4
0
            protected override void ApplyFont(LyricFont font)
            {
                base.ApplyFont(font);

                if (defaultValueAssigned)
                {
                    return;
                }

                defaultValueAssigned = true;

                // Assign default value here
                testScene.colorAreaDropdown.Current.TriggerChange();
                testScene.fontAreaDropdown.Current.TriggerChange();
                testScene.displayShaderCheckbox.Current.Value = Font.UseShadow;
            }
    public String GetFontPath(LyricFont lyricType)
    {
        switch (lyricType)
        {
        case LyricFont.MontserratLight:
            return("fonts/Montserrat-Light.ttf");

        case LyricFont.NottoSerifLight:
            return("fonts/NotoSerifJP-Light.otf");

        case LyricFont.NottoSerifRegular:
            return("fonts/NotoSerifJP-Regular.otf");

        case LyricFont.SawarabiMincho:
            return("fonts/SawarabiMincho-Regular.ttf");

        default:
            return("");
        }
    }
    public String GetFontString(LyricFont lyricType)
    {
        switch (lyricType)
        {
        case LyricFont.MontserratLight:
            return("monl");

        case LyricFont.NottoSerifLight:
            return("nol");

        case LyricFont.NottoSerifRegular:
            return("nor");

        case LyricFont.SawarabiMincho:
            return("s");

        default:
            return("");
        }
    }
예제 #7
0
 protected override void ApplyFont(LyricFont font)
 {
     ApplyFontAction?.Invoke(font);
     base.ApplyFont(font);
 }
예제 #8
0
        public override void OnSelectedSong(Playable[] playable, ChartMetadata chartInfo, PlayLog[] playLogs)
        {
            // Use player1's Playable
            var p = playable[0];

            Lyric = null;
            Lyric = new LyRiCs[p.Sections.Length];

            // *.lrc parse phase
            for (var section = 0; section < Lyric.Length; section++)
            {
                // get path for file
                var audioPath = chartInfo.Audio[section];

                if (audioPath == null)
                {
                    continue;
                }

                var folder  = Path.GetDirectoryName(audioPath);
                var lrcFile = $"{Path.GetFileNameWithoutExtension(audioPath)}.lrc";

                var lrcPath = Path.Combine(folder, lrcFile);

                // read and parse
                if (!File.Exists(lrcPath))
                {
                    continue;
                }

                var file = File.ReadAllText(lrcPath);

                var result = LRCDotNet.Parse(file);

                Lyric[section] = result;
            }
            // phase end

            // Generation texture phase
            LyricAndTimings = new LyricAndTiming[Lyric.Length][];
            for (var section = 0; section < Lyric.Length; section++)
            {
                if (Lyric[section] == null)
                {
                    continue;
                }

                var lyric = Lyric[section].Lyrics;
                LyricAndTimings[section] = new LyricAndTiming[lyric.Count()];

                for (var l = 0; l < lyric.Count(); l++)
                {
                    // convert ms to us
                    var timing = (long)(lyric[l].Time.TotalMilliseconds * 1000.0);
                    // apply offset
                    if (Theme.Offset != 0)
                    {
                        timing += Theme.Offset;
                    }
                    var tex = LyricFont.GetTexture(lyric[l].Text);
                    LyricAndTimings[section][l] = new LyricAndTiming(tex, timing);
                }
            }
            // phase end

            Showing = null;
        }
예제 #9
0
 protected override void ApplySkin(ISkinSource skin, bool allowFallback)
 {
     // Get layout
     Font = skin?.GetConfig <KaraokeSkinLookup, LyricFont>(new KaraokeSkinLookup(KaraokeSkinConfiguration.LyricStyle, HitObject.Singers))?.Value;
     base.ApplySkin(skin, allowFallback);
 }