[add] Added FontSet which uses freetype.
This commit is contained in:
@@ -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_);
|
||||
|
24
src/sj/FontSet.d
Normal file
24
src/sj/FontSet.d
Normal 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_;
|
||||
}
|
@@ -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_;
|
||||
}
|
||||
|
Reference in New Issue
Block a user