diff --git a/.bin/fonts/SourceHanSansJP-Heavy.otf b/.bin/fonts/SourceHanSansJP-Heavy.otf new file mode 100644 index 0000000..4558d3c Binary files /dev/null and b/.bin/fonts/SourceHanSansJP-Heavy.otf differ diff --git a/.gitignore b/.gitignore index 29733bb..54356cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .dub .bin +!/.bin dub.selections.json *.swp diff --git a/src/main.d b/src/main.d index 2f8126f..4e17590 100644 --- a/src/main.d +++ b/src/main.d @@ -2,6 +2,7 @@ import std; import derelict.sfml2.audio, + derelict.sfml2.graphics, derelict.sfml2.system, derelict.sfml2.window; @@ -61,9 +62,10 @@ private KeyInput GetKeyInput() { } private auto CreateWindow(ref in Args args) { - DerelictSFML2System.load(); - DerelictSFML2Window.load(); - DerelictSFML2Audio .load(); + DerelictSFML2Audio .load(); + DerelictSFML2Graphics.load(); + DerelictSFML2System .load(); + DerelictSFML2Window .load(); sfContextSettings specs; specs.depthBits = 24; diff --git a/src/sj/Font.d b/src/sj/Font.d new file mode 100644 index 0000000..ac644f0 --- /dev/null +++ b/src/sj/Font.d @@ -0,0 +1,31 @@ +/// License: MIT +module sj.Font; + +import std.exception, + std.format, + std.string; + +import derelict.sfml2.graphics; + +import gl4d; + +/// +class Font { + public: + /// + this(string path) { + font_ = sfFont_createFromFile(path.toStringz). + enforce("failed creating font from %s".format(path)); + } + ~this() { + sfFont_destroy(font_); + } + + /// + Texture2DRef Render(string text, size_t px) { + assert(false); + } + + private: + sfFont* font_; +} diff --git a/src/sj/FontSet.d b/src/sj/FontSet.d new file mode 100644 index 0000000..db449f0 --- /dev/null +++ b/src/sj/FontSet.d @@ -0,0 +1,26 @@ +/// License: MIT +module sj.FontSet; + +import std.file, + std.path; + +import sj.Font; + +/// +class FontSet { + public: + /// + this() { + const dir = thisExePath.dirName; + + gothic_heavy_ = new Font(dir~"/fonts/SourceHanSansJP-Heavy.otf"); + } + + /// + @property Font gothicHeavy() { + return gothic_heavy_; + } + + private: + Font gothic_heavy_; +} diff --git a/src/sj/Game.d b/src/sj/Game.d index 89be4fd..dcaf3b8 100644 --- a/src/sj/Game.d +++ b/src/sj/Game.d @@ -2,6 +2,7 @@ module sj.Game; import sj.AbstractGame, + sj.FontSet, sj.LobbyWorld, sj.ProgramSet, sj.TitleScene; @@ -12,6 +13,7 @@ class Game : AbstractGame { /// this() { programs_ = new ProgramSet; + fonts_ = new FontSet; lobby_ = new LobbyWorld(programs_); @@ -32,6 +34,8 @@ class Game : AbstractGame { private: ProgramSet programs_; + FontSet fonts_; + LobbyWorld lobby_; TitleScene title_;