[remove] Removed classes and resources related to fonts.
sfFont was useless. :(
This commit is contained in:
parent
dbe7e8af8c
commit
ef34d9c058
1
.bin/.gitignore
vendored
1
.bin/.gitignore
vendored
@ -1,4 +1,3 @@
|
||||
*
|
||||
!/.gitignore
|
||||
!/fonts
|
||||
!/songs
|
||||
|
Binary file not shown.
@ -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_;
|
||||
}
|
@ -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_;
|
||||
}
|
@ -7,7 +7,6 @@ import std.algorithm,
|
||||
std.path;
|
||||
|
||||
import sj.AbstractGame,
|
||||
sj.FontSet,
|
||||
sj.LobbyWorld,
|
||||
sj.ProgramSet,
|
||||
sj.SelectScene,
|
||||
@ -26,7 +25,6 @@ class Game : AbstractGame {
|
||||
songs_ = Song.CreateFromJson(songs_list.parseJSON, songs_dir);
|
||||
|
||||
programs_ = new ProgramSet;
|
||||
fonts_ = new FontSet;
|
||||
|
||||
lobby_ = new LobbyWorld(programs_);
|
||||
|
||||
@ -46,7 +44,6 @@ class Game : AbstractGame {
|
||||
lobby_.destroy();
|
||||
|
||||
programs_.destroy();
|
||||
fonts_.destroy();
|
||||
|
||||
songs_.each!destroy();
|
||||
}
|
||||
@ -56,8 +53,6 @@ class Game : AbstractGame {
|
||||
|
||||
ProgramSet programs_;
|
||||
|
||||
FontSet fonts_;
|
||||
|
||||
LobbyWorld lobby_;
|
||||
|
||||
TitleScene title_;
|
||||
|
Reference in New Issue
Block a user