[add] Added FontSet which uses freetype.

This commit is contained in:
falsycat 2019-10-13 00:00:00 +00:00
parent d429856776
commit 983625d8d9
7 changed files with 39 additions and 3 deletions

3
.gitmodules vendored
View File

@ -4,3 +4,6 @@
[submodule "thirdparty/gl4d"] [submodule "thirdparty/gl4d"]
path = thirdparty/gl4d path = thirdparty/gl4d
url = https://gogs.enigmatical.work/kajironagi/gl4d.git url = https://gogs.enigmatical.work/kajironagi/gl4d.git
[submodule "thirdparty/ft4d"]
path = thirdparty/ft4d
url = https://gogs.enigmatical.work/KajiroNagi/ft4d.git

View File

@ -9,6 +9,7 @@
"sjplayer": {"path": "sjplayer"}, "sjplayer": {"path": "sjplayer"},
"gl4d": {"path": "thirdparty/gl4d"}, "gl4d": {"path": "thirdparty/gl4d"},
"ft4d": {"path": "thirdparty/ft4d"},
"derelict-sfml2": "~>4.0.0-beta.2" "derelict-sfml2": "~>4.0.0-beta.2"
} }
} }

Binary file not shown.

View File

@ -6,7 +6,7 @@ import derelict.sfml2.audio,
derelict.sfml2.system, derelict.sfml2.system,
derelict.sfml2.window; derelict.sfml2.window;
import gl4d; import gl4d, ft4d;
import sj.Args, import sj.Args,
sj.Game, sj.Game,
@ -62,6 +62,8 @@ private KeyInput GetKeyInput() {
} }
private auto CreateWindow(ref in Args args) { private auto CreateWindow(ref in Args args) {
ft.Initialize();
DerelictSFML2Audio .load(); DerelictSFML2Audio .load();
DerelictSFML2Graphics.load(); DerelictSFML2Graphics.load();
DerelictSFML2System .load(); DerelictSFML2System .load();
@ -93,6 +95,7 @@ private auto CreateWindow(ref in Args args) {
public: public:
~this() { ~this() {
sfWindow_destroy(window_); sfWindow_destroy(window_);
ft.Dispose();
} }
void Flush() { void Flush() {
sfWindow_display(window_); sfWindow_display(window_);

24
src/sj/FontSet.d Normal file
View File

@ -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_;
}

View File

@ -7,6 +7,7 @@ import std.algorithm,
std.path; std.path;
import sj.AbstractGame, import sj.AbstractGame,
sj.FontSet,
sj.LobbyWorld, sj.LobbyWorld,
sj.ProgramSet, sj.ProgramSet,
sj.SelectScene, sj.SelectScene,
@ -24,6 +25,7 @@ class Game : AbstractGame {
const songs_list = buildPath(songs_dir, "list.json").readText; const songs_list = buildPath(songs_dir, "list.json").readText;
songs_ = Song.CreateFromJson(songs_list.parseJSON, songs_dir); songs_ = Song.CreateFromJson(songs_list.parseJSON, songs_dir);
fonts_ = new FontSet;
programs_ = new ProgramSet; programs_ = new ProgramSet;
lobby_ = new LobbyWorld(programs_); lobby_ = new LobbyWorld(programs_);
@ -40,9 +42,11 @@ class Game : AbstractGame {
~this() { ~this() {
title_.destroy(); title_.destroy();
select_.destroy();
lobby_.destroy(); lobby_.destroy();
fonts_.destroy();
programs_.destroy(); programs_.destroy();
songs_.each!destroy(); songs_.each!destroy();
@ -51,11 +55,11 @@ class Game : AbstractGame {
private: private:
Song[] songs_; Song[] songs_;
FontSet fonts_;
ProgramSet programs_; ProgramSet programs_;
LobbyWorld lobby_; LobbyWorld lobby_;
TitleScene title_; TitleScene title_;
SelectScene select_; SelectScene select_;
} }

1
thirdparty/ft4d vendored Submodule

@ -0,0 +1 @@
Subproject commit 791af0dfe67ad25b41aae170568b89303ed853e9