[remove] Removed classes and resources related to fonts.

sfFont was useless. :(
This commit is contained in:
falsycat 2019-10-13 00:00:00 +00:00
parent dbe7e8af8c
commit ef34d9c058
5 changed files with 0 additions and 104 deletions

1
.bin/.gitignore vendored
View File

@ -1,4 +1,3 @@
* *
!/.gitignore !/.gitignore
!/fonts
!/songs !/songs

Binary file not shown.

View File

@ -1,69 +0,0 @@
/// License: MIT
module sj.Font;
import std.array,
std.conv,
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_);
}
///
vec2i[] CreateTextureUvArray(dstring str, size_t px) {
auto glyphs = appender!(sfGlyph[]);
glyphs.reserve(str.length);
foreach (c; str) {
glyphs ~= sfFont_getGlyph(font_, c, px.to!uint, false, 0f);
}
auto uv = appender!(vec2i[]);
uv.reserve(str.length * 4);
foreach (const ref g; glyphs[]) {
const rc = &g.textureRect;
const left = rc.left;
const right = (rc.left + rc.width);
const top = rc.top;
const bottom = (rc.top + rc.height);
uv ~= [
vec2i(left, top),
vec2i(left, bottom),
vec2i(right, bottom),
vec2i(right, top),
];
}
return uv[];
}
///
vec2i GetTextureSize(size_t px) {
const sz = sfTexture_getSize(
sfFont_getTexture(font_, px.to!uint).enforce);
return vec2i(sz.x, sz.y);
}
///
void BindTextureToUnit(GLenum unit, size_t px) {
gl.ActiveTexture(unit);
sfTexture_bind(sfFont_getTexture(font_, px.to!uint).enforce);
}
private:
sfFont* font_;
}

View File

@ -1,29 +0,0 @@
/// 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");
}
~this() {
gothic_heavy_.destroy();
}
///
@property Font gothicHeavy() {
return gothic_heavy_;
}
private:
Font gothic_heavy_;
}

View File

@ -7,7 +7,6 @@ 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,
@ -26,7 +25,6 @@ class Game : AbstractGame {
songs_ = Song.CreateFromJson(songs_list.parseJSON, songs_dir); songs_ = Song.CreateFromJson(songs_list.parseJSON, songs_dir);
programs_ = new ProgramSet; programs_ = new ProgramSet;
fonts_ = new FontSet;
lobby_ = new LobbyWorld(programs_); lobby_ = new LobbyWorld(programs_);
@ -46,7 +44,6 @@ class Game : AbstractGame {
lobby_.destroy(); lobby_.destroy();
programs_.destroy(); programs_.destroy();
fonts_.destroy();
songs_.each!destroy(); songs_.each!destroy();
} }
@ -56,8 +53,6 @@ class Game : AbstractGame {
ProgramSet programs_; ProgramSet programs_;
FontSet fonts_;
LobbyWorld lobby_; LobbyWorld lobby_;
TitleScene title_; TitleScene title_;