diff --git a/.gitmodules b/.gitmodules index e4de406..09d0611 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "thirdparty/gl4d"] path = thirdparty/gl4d url = https://gogs.enigmatical.work/kajironagi/gl4d.git +[submodule "thirdparty/ft4d"] + path = thirdparty/ft4d + url = https://gogs.enigmatical.work/KajiroNagi/ft4d.git diff --git a/dub.json b/dub.json index 6cf5d5b..c3e20fb 100644 --- a/dub.json +++ b/dub.json @@ -9,6 +9,7 @@ "sjplayer": {"path": "sjplayer"}, "gl4d": {"path": "thirdparty/gl4d"}, + "ft4d": {"path": "thirdparty/ft4d"}, "derelict-sfml2": "~>4.0.0-beta.2" } } diff --git a/res/fonts/SourceHanSansJP-Regular.otf b/res/fonts/SourceHanSansJP-Regular.otf new file mode 100644 index 0000000..a4b4f86 Binary files /dev/null and b/res/fonts/SourceHanSansJP-Regular.otf differ diff --git a/src/main.d b/src/main.d index 4e17590..1642094 100644 --- a/src/main.d +++ b/src/main.d @@ -6,7 +6,7 @@ import derelict.sfml2.audio, derelict.sfml2.system, derelict.sfml2.window; -import gl4d; +import gl4d, ft4d; import sj.Args, sj.Game, @@ -62,6 +62,8 @@ private KeyInput GetKeyInput() { } private auto CreateWindow(ref in Args args) { + ft.Initialize(); + DerelictSFML2Audio .load(); DerelictSFML2Graphics.load(); DerelictSFML2System .load(); @@ -93,6 +95,7 @@ private auto CreateWindow(ref in Args args) { public: ~this() { sfWindow_destroy(window_); + ft.Dispose(); } void Flush() { sfWindow_display(window_); diff --git a/src/sj/FontSet.d b/src/sj/FontSet.d new file mode 100644 index 0000000..2423aa3 --- /dev/null +++ b/src/sj/FontSet.d @@ -0,0 +1,24 @@ +/// License: MIT +module sj.FontSet; + +import ft4d; + +/// +class FontSet { + public: + /// + enum Gothic = cast(ubyte[]) import("fonts/SourceHanSansJP-Regular.otf"); + + /// + this() { + gothic_ = Face.CreateFromBuffer(Gothic); + } + + /// + @property FaceRef gothic() { + return gothic_; + } + + private: + FaceRef gothic_; +} diff --git a/src/sj/Game.d b/src/sj/Game.d index d6a0551..903c212 100644 --- a/src/sj/Game.d +++ b/src/sj/Game.d @@ -7,6 +7,7 @@ import std.algorithm, std.path; import sj.AbstractGame, + sj.FontSet, sj.LobbyWorld, sj.ProgramSet, sj.SelectScene, @@ -24,6 +25,7 @@ class Game : AbstractGame { const songs_list = buildPath(songs_dir, "list.json").readText; songs_ = Song.CreateFromJson(songs_list.parseJSON, songs_dir); + fonts_ = new FontSet; programs_ = new ProgramSet; lobby_ = new LobbyWorld(programs_); @@ -40,9 +42,11 @@ class Game : AbstractGame { ~this() { title_.destroy(); + select_.destroy(); lobby_.destroy(); + fonts_.destroy(); programs_.destroy(); songs_.each!destroy(); @@ -51,11 +55,11 @@ class Game : AbstractGame { private: Song[] songs_; + FontSet fonts_; ProgramSet programs_; LobbyWorld lobby_; - TitleScene title_; - + TitleScene title_; SelectScene select_; } diff --git a/thirdparty/ft4d b/thirdparty/ft4d new file mode 160000 index 0000000..791af0d --- /dev/null +++ b/thirdparty/ft4d @@ -0,0 +1 @@ +Subproject commit 791af0dfe67ad25b41aae170568b89303ed853e9