-
Notifications
You must be signed in to change notification settings - Fork 32
Lyrics
storybrew can help with making a lyrics storyboard by loading subtitle files and automatically generating text sprites. You can find an example of this in scripts/Lyrics.cs.
Subtitles can be loaded in your script with the following method:
var subtitles = LoadSubtitles(path);
Where path
points to a .sbv
, .srt
, .ass
or .ssa
file in your project's folder (not mapset!). This is a standard subtitle file that can be made with a tool like aegisub. These subtitles contain multiple lines that can be accessed this way:
foreach (var line in subtitles.Lines)
Each line has Text
, StartTime
and EndTime
properties.
First, you need to declare a font. spritesPath
is the place where generated sprites will be saved, for example you can use "sb/font"
:
var font = LoadFont(spritesPath, new FontDescription() {
FontPath = "Verdana",
FontSize = 26,
});
Then you can use it to build text sprites:
var texture = font.GetTexture("Some text");
var sprite = layer.CreateSprite(texture.Path, OsbOrigin.Centre, new Vector2(320, 400));
And by using the previously loaded subtitles, you can display your lyrics :
foreach (var line in subtitles.Lines)
{
var texture = font.GetTexture(line.Text);
var sprite = layer.CreateSprite(texture.Path, OsbOrigin.Centre, new Vector2(320, 400));
sprite.Fade(line.StartTime - 200, line.StartTime, 0, 1);
sprite.Fade(line.EndTime - 200, line.EndTime, 1, 0);
}
When you declare a new font, you can specify a FontDescription to help format your text sprite. Parameters with a default value are optional.
-
FontPath
The path to the font file, relative to your project's folder. You can also use the font name instead for fonts installed on the system, but the correct font name can be hard to guess. Required. -
FontSize
The font point size. Default value 76. -
Color
The font's color, which accepts aColor4
object. Default value is black. -
Padding
Blank pixel space surrounding the rendered text sprite, asVector2
. Helpful for aligning a text sprite against a boxed background. Default value is Zero.
Need help with something that isn't in the wiki? Try contacting Damnae in osu! or Discord.