diff options
author | matt335672 <30179339+matt335672@users.noreply.github.com> | 2022-08-11 16:10:07 +0300 |
---|---|---|
committer | matt335672 <30179339+matt335672@users.noreply.github.com> | 2022-09-06 11:31:47 +0300 |
commit | 36959e593acab22ce6f33eee312d7412097e6270 (patch) | |
tree | 6a7c09c8868fbf8968ba25e38c9e61c023d34f59 | |
parent | 90561f7bad25d6274b41d2a7a4ba71252d51ef6f (diff) |
Add support for new fields in fv1 fonts
The previous commit added utilities which work with fv1 files
with additional fields in the fv1 header (i.e. body_height and
min_descender). This commit makes minor changes to the font loading code
in xrdp so xrdp can read the new font format.
-rw-r--r-- | xrdp/xrdp_font.c | 68 |
1 files changed, 32 insertions, 36 deletions
diff --git a/xrdp/xrdp_font.c b/xrdp/xrdp_font.c index cc6670d0..5813b361 100644 --- a/xrdp/xrdp_font.c +++ b/xrdp/xrdp_font.c @@ -18,23 +18,7 @@ * fonts */ -/* - The fv1 files contain - Font File Header (just one) - FNT1 4 bytes - Font Name 32 bytes - Font Size 2 bytes - Font Style 2 bytes - Pad 8 bytes - Font Data (repeats) - Width 2 bytes - Height 2 bytes - Baseline 2 bytes - Offset 2 bytes - Incby 2 bytes - Pad 6 bytes - Glyph Data var, see FONT_DATASIZE macro -*/ +/* fv1 files are described in fontutils/README_fv1.txt */ #if defined(HAVE_CONFIG_H) #include <config_ac.h> @@ -46,22 +30,22 @@ #if 0 /* not used */ static char w_char[] = { - 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, - 0x08, 0x20, 0x80, - 0x08, 0x50, 0x80, - 0x04, 0x51, 0x00, - 0x04, 0x51, 0x00, - 0x04, 0x51, 0x00, - 0x02, 0x8a, 0x00, - 0x02, 0x8a, 0x00, - 0x02, 0x8a, 0x00, - 0x01, 0x04, 0x00, - 0x01, 0x04, 0x00, - 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, // ........................ + 0x00, 0x00, 0x00, // ........................ + 0x00, 0x00, 0x00, // ........................ + 0x08, 0x20, 0x80, // ....X.....X.....X....... + 0x08, 0x50, 0x80, // ....X....X.X....X....... + 0x04, 0x51, 0x00, // .....X...X.X...X........ + 0x04, 0x51, 0x00, // .....X...X.X...X........ + 0x04, 0x51, 0x00, // .....X...X.X...X........ + 0x02, 0x8a, 0x00, // ......X.X...X.X......... + 0x02, 0x8a, 0x00, // ......X.X...X.X......... + 0x02, 0x8a, 0x00, // ......X.X...X.X......... + 0x01, 0x04, 0x00, // .......X.....X.......... + 0x01, 0x04, 0x00, // .......X.....X.......... + 0x00, 0x00, 0x00, // ........................ + 0x00, 0x00, 0x00, // ........................ + 0x00, 0x00, 0x00, // ........................ }; #endif @@ -78,6 +62,7 @@ xrdp_font_create(struct xrdp_wm *wm) int datasize; int file_size; struct xrdp_font_char *f; + int min_descender; char file_path[256]; LOG_DEVEL(LOG_LEVEL_TRACE, "in xrdp_font_create"); @@ -117,7 +102,9 @@ xrdp_font_create(struct xrdp_wm *wm) in_uint8a(s, self->name, 32); in_uint16_le(s, self->size); in_uint16_le(s, self->style); - in_uint8s(s, 8); + in_uint16_le(s, self->body_height); + in_sint16_le(s, min_descender); + in_uint8s(s, 4); index = 32; while (s_check_rem(s, 16)) @@ -128,7 +115,8 @@ xrdp_font_create(struct xrdp_wm *wm) in_sint16_le(s, i); f->height = i; in_sint16_le(s, i); - f->baseline = i; + /* Move the glyph up so there are no descenders */ + f->baseline = i + min_descender; in_sint16_le(s, i); f->offset = i; in_sint16_le(s, i); @@ -145,7 +133,15 @@ xrdp_font_create(struct xrdp_wm *wm) break; } - if (s_check_rem(s, datasize)) + if (datasize == 0) + { + /* Allocate a single blank pixel for the glyph, so + * that it can be added to the glyph cache if required */ + f->width = 1; + f->height = 1; + f->data = (char *)g_malloc(1, 1); + } + else if (s_check_rem(s, datasize)) { f->data = (char *)g_malloc(datasize, 0); in_uint8a(s, f->data, datasize); |