graphics

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 66e98ecdebd263318efeeea101361a5aff4c8aba
parent d82922cacd5d8ae26f3f14115fc64170a2c96d25
Author: Brian Swetland <swetland@frotz.net>
Date:   Sun, 15 Sep 2013 20:05:14 -0700

texturefont: include overall ascent/descent/height data

Diffstat:
Mcommon/assets/orbitron-bold-34.font.dat | 0
Mcommon/assets/orbitron-bold-72.font.dat | 0
Mcommon/texturefont.h | 4++++
Mtools/mkfont.cc | 26+++++++++++++++++++++++++-
4 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/common/assets/orbitron-bold-34.font.dat b/common/assets/orbitron-bold-34.font.dat Binary files differ. diff --git a/common/assets/orbitron-bold-72.font.dat b/common/assets/orbitron-bold-72.font.dat Binary files differ. diff --git a/common/texturefont.h b/common/texturefont.h @@ -40,6 +40,10 @@ struct FontInfo { u32 first; u32 count; u32 unused; + u32 ascent_max; + u32 descent_max; + u32 height_max; + u32 unused2; CharInfo info[0]; }; diff --git a/tools/mkfont.cc b/tools/mkfont.cc @@ -119,6 +119,11 @@ retry: nx = ny = 1; rh = 0; + int ascent, descent; + int ascent_max = 0; + int descent_max = 0; + int height_max = 0; + printf("%dx%d texture...\n", max, max); for (i = 0; i < (LAST - FIRST); i++) { n = list[i].c; @@ -151,6 +156,22 @@ retry: info[n].dx = bb.xMin; info[n].dy = bb.yMin; info[n].advance = face->glyph->advance.x >> 6; + + if (bb.yMin < 0) { + descent = -bb.yMin; + } else { + descent = 0; + } + ascent = h + bb.yMin; + if (ascent < 0) + ascent = 0; + if (ascent > ascent_max) + ascent_max = ascent; + if (descent > descent_max) + descent_max = descent; + if ((ascent + descent) > height_max) + height_max = ascent + descent; + FT_Outline_Translate(&face->glyph->outline, nx * 64 + tx * 64, ny * 64 + ty * 64); FT_Outline_Get_Bitmap(ftl, &face->glyph->outline, &bm); nx += w; @@ -162,10 +183,13 @@ retry: sprintf(tmp, "%s.png", argv[3]); save_png_gray(tmp, bitmap->buffer, bitmap->width, bitmap->rows); FontInfo header; + memset(&header, 0, sizeof(header)); header.magic = TEXTUREFONT_MAGIC; header.first = FIRST; header.count = LAST - FIRST; - header.unused = 0; + header.ascent_max = ascent_max; + header.descent_max = descent_max; + header.height_max = height_max; sprintf(tmp, "%s.dat", argv[3]); FILE *fp = fopen(tmp, "wb");