Moved to SFML 3.0 now.

This commit is contained in:
Zed A. Shaw 2025-01-29 12:55:33 -05:00
parent 7c56f350ab
commit e05b2c304c
12 changed files with 167 additions and 173 deletions

View file

@ -44,20 +44,19 @@ struct FontExtractor {
FontExtractor(fs::path font_path) :
$font_path(font_path)
{
bool good = $font.loadFromFile($font_path.string());
bool good = $font.openFromFile($font_path);
dbc::check(good, format("failed to load font {}", $font_path.string()));
$font.setSmooth(false);
for(int i = 100; i < 200; i++) {
auto glyph = $font.getGlyph(ui_base_char, i, false);
if(glyph.bounds.width > 0 && glyph.bounds.height > 0) {
if(glyph.bounds.size.x > 0 && glyph.bounds.size.y > 0) {
$grid_bounds = glyph.bounds;
$font_size = i;
break;
}
}
dbc::check($grid_bounds.width > 0 && $grid_bounds.height > 0, "couldn't find a valid font size");
dbc::check($grid_bounds.size.x > 0 && $grid_bounds.size.y > 0, "couldn't find a valid font size");
println("!!!!!!!!!!!!!!!!!!!!! FONT SIZE {}", $font_size);
}
@ -133,10 +132,10 @@ struct FontExtractor {
auto bounds = glyph.bounds;
// skip bad chars
if(bounds.width <= 0 || bounds.height <= 0) continue;
if(bounds.size.x <= 0 || bounds.size.y <= 0) continue;
if(bounds.width <= $grid_bounds.width &&
bounds.height <= $grid_bounds.height) {
if(bounds.size.x <= $grid_bounds.size.x &&
bounds.size.y <= $grid_bounds.size.y) {
return i;
}
}
@ -175,7 +174,7 @@ struct FontExtractor {
void clear_font_cache() {
if($clear_count % CLEAR_CACHE_POINT == 0) {
bool good = $font.loadFromFile($font_path.string());
bool good = $font.openFromFile($font_path);
dbc::check(good, format("failed to load font {}", $font_path.string()));
$font.setSmooth(false);