2 Deep Runner - 6dof shooter game for the SGI O2.
3 Copyright (C) 2023 John Tsiombikas <nuclear@mutantstargoat.com>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
20 int load_font(struct font *font, const char *fname)
22 if(!(font->dtxfont = dtx_open_font_glyphmap(fname))) {
23 fprintf(stderr, "failed to load font: %s\n", fname);
26 font->size = dtx_get_glyphmap_ptsize(dtx_get_glyphmap(font->dtxfont, 0));
27 dtx_use_font(font->dtxfont, font->size);
28 font->height = dtx_line_height();
29 font->baseline = font->height * 0.2;
33 void destroy_font(struct font *font)
37 dtx_close_font(font->dtxfont);
40 void use_font(struct font *font)
42 dtx_use_font(font->dtxfont, font->size);
45 float font_strwidth(struct font *font, const char *str)
47 dtx_use_font(font->dtxfont, font->size);
48 return dtx_string_width(str);