From 0fee19a8c0342a1976399b0272cdecdff8701e35 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Mon, 6 Aug 2012 14:48:22 +0200 Subject: [PATCH] text: font: Simplify font-system and add freetype2 renderer The freetype2 renderer uses ft2 and fontconfig to provide a very simplistic renderer. We also simplify the logic of the whole subsystem a lot and guarantee that each glyph will have the same size now. Signed-off-by: David Herrmann --- Makefile.am | 19 +- configure.ac | 93 ++++- src/main.c | 3 + src/text.h | 64 +++- src/text_bblit.c | 23 +- src/text_font.c | 51 ++- src/text_font_8x16.c | 528 +--------------------------- src/text_font_freetype2.c | 705 ++++++++++++++++++++++++++++++++++++++ src/text_font_pango.c | 124 +++---- 9 files changed, 996 insertions(+), 614 deletions(-) create mode 100644 src/text_font_freetype2.c diff --git a/Makefile.am b/Makefile.am index 4926535..6ac9e63 100644 --- a/Makefile.am +++ b/Makefile.am @@ -121,15 +121,28 @@ libkmscon_core_la_SOURCES = \ src/text.h \ src/text.c \ src/text_bblit.c \ - src/text_font.c \ - src/text_font_8x16.c \ - src/text_font_pango.c + src/text_font.c if KMSCON_HAVE_GLES2 libkmscon_core_la_SOURCES += \ src/gl_shader.c endif +if KMSCON_HAVE_8X16 +libkmscon_core_la_SOURCES += \ + src/text_font_8x16.c +endif + +if KMSCON_HAVE_FREETYPE2 +libkmscon_core_la_SOURCES += \ + src/text_font_freetype2.c +endif + +if KMSCON_HAVE_PANGO +libkmscon_core_la_SOURCES += \ + src/text_font_pango.c +endif + libkmscon_core_la_CPPFLAGS = \ $(AM_CPPFLAGS) \ $(GLES2_CFLAGS) \ diff --git a/configure.ac b/configure.ac index c6c2aca..3e0990b 100644 --- a/configure.ac +++ b/configure.ac @@ -76,12 +76,12 @@ PKG_CHECK_MODULES([GLES2], [glesv2], PKG_CHECK_MODULES([XKBCOMMON], [xkbcommon], [have_xkbcommon=yes], [have_xkbcommon=no]) +PKG_CHECK_MODULES([FREETYPE2], [freetype2 fontconfig], + [have_freetype2=yes], [have_freetype2=no]) + PKG_CHECK_MODULES([PANGO], [pango pangoft2], [have_pango=yes], [have_pango=no]) -PKG_CHECK_MODULES([FREETYPE2], [freetype2], - [have_freetype2=yes], [have_freetype2=no]) - # # Parse arguments # Parse all command line arguments and save the values so we can check them @@ -100,6 +100,12 @@ AC_ARG_ENABLE([udev], [enable device hotplug support with udev])]) AC_MSG_RESULT([ok]) +AC_MSG_CHECKING([whether to use dbus for IPC]) +AC_ARG_ENABLE([dbus], + [AS_HELP_STRING([--enable-dbus], + [enable dbus IPC])]) +AC_MSG_RESULT([ok]) + AC_MSG_CHECKING([whether to use uterm fbdev video backend]) AC_ARG_ENABLE([fbdev], [AS_HELP_STRING([--enable-fbdev], @@ -124,6 +130,24 @@ AC_ARG_ENABLE([xkbcommon], [disable xkbcommon keyboard backend])]) AC_MSG_RESULT([ok]) +AC_MSG_CHECKING([whether to use static 8x16 font backend]) +AC_ARG_ENABLE([f8x16], + [AS_HELP_STRING([--disable-f8x16], + [disable static 8x16 font backend])]) +AC_MSG_RESULT([ok]) + +AC_MSG_CHECKING([whether to use freetype2 font backend]) +AC_ARG_ENABLE([freetype2], + [AS_HELP_STRING([--disable-freetype2], + [disable freetype2 font backend])]) +AC_MSG_RESULT([ok]) + +AC_MSG_CHECKING([whether to use pango font backend]) +AC_ARG_ENABLE([pango], + [AS_HELP_STRING([--disable-pango], + [disable pango font backend])]) +AC_MSG_RESULT([ok]) + AC_MSG_CHECKING([whether to build with debugging on]) AC_ARG_ENABLE([debug], [AS_HELP_STRING([--enable-debug], @@ -345,6 +369,62 @@ fi AM_CONDITIONAL([UTERM_HAVE_XKBCOMMON], [test x$xkbcommon_enabled = xyes]) +# +# Font backends +# This checks for the 8x16, freetype2 and pango font backends and enables them +# if requested and available. +# + +f8x16_enabled=no +if test ! x$enable_f8x16 = xno ; then + f8x16_enabled=yes +fi + +if test x$f8x16_enabled = xyes ; then + AC_DEFINE([KMSCON_HAVE_8X16], [1], + [Use static 8x16 font backend]) +fi + +AM_CONDITIONAL([KMSCON_HAVE_8X16], [test x$f8x16_enabled = xyes]) + +freetype2_enabled=no +if test ! x$enable_freetype2 = xno ; then + if test x$have_freetype2 = xyes ; then + freetype2_enabled=yes + elif test x$enable_freetype2 = xyes ; then + AC_ERROR([freetype2/fontconfig not found for freetype2 backend]) + fi +fi + +if test x$freetype2_enabled = xyes ; then + AC_DEFINE([KMSCON_HAVE_FREETYPE2], [1], + [Use freetype2 as font backend]) +else + FREETYPE2_CFLAGS="" + FREETYPE2_LIBS="" +fi + +AM_CONDITIONAL([KMSCON_HAVE_FREETYPE2], [test x$freetype2_enabled = xyes]) + +pango_enabled=no +if test ! x$enable_pango = xno ; then + if test x$have_pango = xyes ; then + pango_enabled=yes + elif test x$enable_pango = xyes ; then + AC_ERROR([pango not found for pango font backend]) + fi +fi + +if test x$pango_enabled = xyes ; then + AC_DEFINE([KMSCON_HAVE_PANGO], [1], + [Use pango as font backend]) +else + PANGO_CFLAGS="" + PANGO_LIBS="" +fi + +AM_CONDITIONAL([KMSCON_HAVE_PANGO], [test x$pango_enabled = xyes]) + # # Makefile vars # After everything is configured, we correctly substitute the values for the @@ -390,10 +470,15 @@ AC_MSG_NOTICE([Build configuration: dbus: $dbus_enabled xkbcommon: $xkbcommon_enabled - libuterm video backends: + libuterm video backends: fbdev: $fbdev_enabled dumb drm: $dumb_enabled drm: $drm_enabled OpenGLES2: $gles2_enabled + font backends: + 8x16: $f8x16_enabled + freetype2: $freetype2_enabled + pango: $pango_enabled + Run "make" to start compilation process]) diff --git a/src/main.c b/src/main.c index 9ac6691..6a1dbc2 100644 --- a/src/main.c +++ b/src/main.c @@ -336,6 +336,7 @@ int main(int argc, char **argv) kmscon_font_8x16_load(); kmscon_font_pango_load(); + kmscon_font_freetype2_load(); kmscon_text_bblit_load(); memset(&app, 0, sizeof(app)); @@ -367,6 +368,7 @@ int main(int argc, char **argv) destroy_app(&app); kmscon_text_bblit_unload(); + kmscon_font_freetype2_unload(); kmscon_font_pango_unload(); kmscon_font_8x16_unload(); conf_free(); @@ -376,6 +378,7 @@ int main(int argc, char **argv) err_unload: kmscon_text_bblit_unload(); + kmscon_font_freetype2_unload(); kmscon_font_pango_unload(); kmscon_font_8x16_unload(); err_out: diff --git a/src/text.h b/src/text.h index 6bdd5dd..fccb877 100644 --- a/src/text.h +++ b/src/text.h @@ -69,9 +69,8 @@ bool kmscon_font_attr_match(const struct kmscon_font_attr *a1, const struct kmscon_font_attr *a2); struct kmscon_glyph { - unsigned int ascent; - unsigned int descent; struct uterm_video_buffer buf; + void *data; }; struct kmscon_font { @@ -89,8 +88,10 @@ struct kmscon_font_ops { void (*destroy) (struct kmscon_font *font); int (*render) (struct kmscon_font *font, kmscon_symbol_t sym, const struct kmscon_glyph **out); - void (*drop) (struct kmscon_font *font, - const struct kmscon_glyph *glyph); + int (*render_empty) (struct kmscon_font *font, + const struct kmscon_glyph **out); + int (*render_inval) (struct kmscon_font *font, + const struct kmscon_glyph **out); }; int kmscon_font_register(const struct kmscon_font_ops *ops); @@ -104,8 +105,10 @@ void kmscon_font_unref(struct kmscon_font *font); int kmscon_font_render(struct kmscon_font *font, kmscon_symbol_t sym, const struct kmscon_glyph **out); -void kmscon_font_drop(struct kmscon_font *font, - const struct kmscon_glyph *glyph); +int kmscon_font_render_empty(struct kmscon_font *font, + const struct kmscon_glyph **out); +int kmscon_font_render_inval(struct kmscon_font *font, + const struct kmscon_glyph **out); /* text renderer */ @@ -164,11 +167,60 @@ void kmscon_text_render(struct kmscon_text *txt); /* modularized backends */ +#ifdef KMSCON_HAVE_8X16 + int kmscon_font_8x16_load(void); void kmscon_font_8x16_unload(void); + +#else + +static inline int kmscon_font_8x16_load(void) +{ + return -EOPNOTSUPP; +} + +static inline void kmscon_font_8x16_unload(void) +{ +} + +#endif + +#ifdef KMSCON_HAVE_FREETYPE2 + +int kmscon_font_freetype2_load(void); +void kmscon_font_freetype2_unload(void); + +#else + +static inline int kmscon_font_freetype2_load(void) +{ + return -EOPNOTSUPP; +} + +static inline void kmscon_font_freetype2_unload(void) +{ +} + +#endif + +#ifdef KMSCON_HAVE_PANGO + int kmscon_font_pango_load(void); void kmscon_font_pango_unload(void); +#else + +static inline int kmscon_font_pango_load(void) +{ + return -EOPNOTSUPP; +} + +static inline void kmscon_font_pango_unload(void) +{ +} + +#endif + int kmscon_text_bblit_load(void); void kmscon_text_bblit_unload(void); diff --git a/src/text_bblit.c b/src/text_bblit.c index d982934..6db729b 100644 --- a/src/text_bblit.c +++ b/src/text_bblit.c @@ -128,35 +128,30 @@ static void bblit_draw(struct kmscon_text *txt, kmscon_symbol_t ch, const struct kmscon_glyph *glyph; int ret; struct bblit *bblit = txt->data; - int off, pos; - ret = kmscon_font_render(txt->font, ch, &glyph); + if (ch == 0 || ch == ' ') { + ret = kmscon_font_render_empty(txt->font, &glyph); + } else { + ret = kmscon_font_render(txt->font, ch, &glyph); + } + if (ret) { - /* TODO: document 0 as fallback glyph */ - ret = kmscon_font_render(txt->font, 0, &glyph); + ret = kmscon_font_render_inval(txt->font, &glyph); if (ret) return; } - /* position glyph correctly */ - off = bblit->base - glyph->ascent; - pos = posy * bblit->advance_y; - if (pos + off < 0) - pos = 0; - else - pos += off; - /* draw glyph */ if (attr->inverse) { uterm_screen_blend(txt->screen, &glyph->buf, posx * bblit->advance_x, - pos, + posy * bblit->advance_y, attr->br, attr->bg, attr->bb, attr->fr, attr->fg, attr->fb); } else { uterm_screen_blend(txt->screen, &glyph->buf, posx * bblit->advance_x, - pos, + posy * bblit->advance_y, attr->fr, attr->fg, attr->fb, attr->br, attr->bg, attr->bb); } diff --git a/src/text_font.c b/src/text_font.c index 561be62..316b2d3 100644 --- a/src/text_font.c +++ b/src/text_font.c @@ -341,7 +341,7 @@ int kmscon_font_find(struct kmscon_font **out, ret = -EFAULT; } else { ret = 0; - def = kmscon_dlist_entry(font__list.next, + def = kmscon_dlist_entry(font__list.prev, struct font_backend, list); if (!backend) { @@ -453,8 +453,10 @@ void kmscon_font_unref(struct kmscon_font *font) * @out: Output buffer for glyph * * Renders the glyph for symbol @sym and places a pointer to the glyph in @out. - * If the glyph cannot be found or is invalid, an error is returned. You must - * release the glyph with kmscon_font_drop() if you don't need it anymore. + * If the glyph cannot be found or is invalid, an error is returned. The glyph + * is cached internally and removed when the last reference to this font is + * dropped. + * If the glyph is no available in this font-set, then -ERANGE is returned. * * Returns: 0 on success, negative error code on failure */ @@ -468,19 +470,42 @@ int kmscon_font_render(struct kmscon_font *font, kmscon_symbol_t sym, } /** - * kmscon_font_drop: + * kmscon_font_render_empty: * @font: Valid font object - * @glyph: Glyph object from font @font + * @out: Output buffer for glyph * - * This releases a glyph that was previously retrieved via kmscon_font_render(). - * Please note that the glyphs are shared and this does not necessarily free the - * memory if there are still other users. + * Same as kmscon_font_render() but this renders a glyph that has no content and + * can be used to blit solid backgrounds. That is, the resulting buffer will be + * all 0 but the dimensions are the same as for all other glyphs. + * + * Returns: 0 on success, negative error code on failure */ -void kmscon_font_drop(struct kmscon_font *font, - const struct kmscon_glyph *glyph) +int kmscon_font_render_empty(struct kmscon_font *font, + const struct kmscon_glyph **out) { - if (!font || !glyph) - return; + if (!font || !out) + return -EINVAL; - font->ops->drop(font, glyph); + return font->ops->render_empty(font, out); +} + +/** + * kmscon_font_render_inval: + * @font: Valid font object + * @out: Output buffer for glyph + * + * Same sa kmscon_font_render_empty() but renders a glyph that can be used as + * replacement for any other non-drawable glyph. That is, if + * kmscon_font_render() returns -ERANGE, then this glyph can be used as + * replacement. + * + * Returns: 0 on success ,engative error code on failure + */ +int kmscon_font_render_inval(struct kmscon_font *font, + const struct kmscon_glyph **out) +{ + if (!font || !out) + return -EINVAL; + + return font->ops->render_inval(font, out); } diff --git a/src/text_font_8x16.c b/src/text_font_8x16.c index 2bc37e1..ac13e18 100644 --- a/src/text_font_8x16.c +++ b/src/text_font_8x16.c @@ -97,9 +97,18 @@ static int kmscon_font_8x16_render(struct kmscon_font *font, return 0; } -static void kmscon_font_8x16_drop(struct kmscon_font *font, - const struct kmscon_glyph *glyph) +static int kmscon_font_8x16_render_empty(struct kmscon_font *font, + const struct kmscon_glyph **out) { + *out = &kmscon_font_8x16_glyphs[0]; + return 0; +} + +static int kmscon_font_8x16_render_inval(struct kmscon_font *font, + const struct kmscon_glyph **out) +{ + *out = &kmscon_font_8x16_glyphs['?']; + return 0; } static const struct kmscon_font_ops kmscon_font_8x16_ops = { @@ -107,7 +116,8 @@ static const struct kmscon_font_ops kmscon_font_8x16_ops = { .init = kmscon_font_8x16_init, .destroy = kmscon_font_8x16_destroy, .render = kmscon_font_8x16_render, - .drop = kmscon_font_8x16_drop, + .render_empty = kmscon_font_8x16_render_empty, + .render_inval = kmscon_font_8x16_render_inval, }; int kmscon_font_8x16_load(void) @@ -130,8 +140,6 @@ void kmscon_font_8x16_unload(void) static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { { /* 0 0x00 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -174,8 +182,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 1 0x01 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -218,8 +224,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 2 0x02 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -262,8 +266,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 3 0x03 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -306,8 +308,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 4 0x04 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -350,8 +350,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 5 0x05 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -394,8 +392,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 6 0x06 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -438,8 +434,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 7 0x07 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -482,8 +476,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 8 0x08 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -526,8 +518,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 9 0x09 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -570,8 +560,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 10 0x0a */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -614,8 +602,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 11 0x0b */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -658,8 +644,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 12 0x0c */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -702,8 +686,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 13 0x0d */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -746,8 +728,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 14 0x0e */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -790,8 +770,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 15 0x0f */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -834,8 +812,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 16 0x10 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -878,8 +854,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 17 0x11 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -922,8 +896,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 18 0x12 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -966,8 +938,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 19 0x13 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1010,8 +980,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 20 0x14 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1054,8 +1022,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 21 0x15 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1098,8 +1064,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 22 0x16 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1142,8 +1106,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 23 0x17 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1186,8 +1148,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 24 0x18 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1230,8 +1190,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 25 0x19 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1274,8 +1232,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 26 0x1a */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1318,8 +1274,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 27 0x1b */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1362,8 +1316,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 28 0x1c */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1406,8 +1358,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 29 0x1d */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1450,8 +1400,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 30 0x1e */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1494,8 +1442,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 31 0x1f */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1538,8 +1484,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 32 0x20 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1582,8 +1526,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 33 0x21 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1626,8 +1568,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 34 0x22 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1670,8 +1610,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 35 0x23 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1714,8 +1652,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 36 0x24 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1758,8 +1694,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 37 0x25 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1802,8 +1736,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 38 0x26 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1846,8 +1778,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 39 0x27 '*/ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1890,8 +1820,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 40 0x28 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1934,8 +1862,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 41 0x29 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -1978,8 +1904,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 42 0x2a */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2022,8 +1946,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 43 0x2b */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2066,8 +1988,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 44 0x2c */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2110,8 +2030,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 45 0x2d */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2154,8 +2072,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 46 0x2e */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2198,8 +2114,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 47 0x2f */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2242,8 +2156,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 48 0x30 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2286,8 +2198,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 49 0x31 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2330,8 +2240,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 50 0x32 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2374,8 +2282,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 51 0x33 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2418,8 +2324,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 52 0x34 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2462,8 +2366,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 53 0x35 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2506,8 +2408,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 54 0x36 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2550,8 +2450,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 55 0x37 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2594,8 +2492,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 56 0x38 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2638,8 +2534,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 57 0x39 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2682,8 +2576,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 58 0x3a */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2726,8 +2618,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 59 0x3b */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2770,8 +2660,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 60 0x3c */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2814,8 +2702,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 61 0x3d */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2858,8 +2744,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 62 0x3e */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2902,8 +2786,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 63 0x3f */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2946,8 +2828,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 64 0x40 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -2990,8 +2870,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 65 0x41 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3034,8 +2912,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 66 0x42 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3078,8 +2954,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 67 0x43 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3122,8 +2996,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 68 0x44 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3166,8 +3038,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 69 0x45 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3210,8 +3080,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 70 0x46 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3254,8 +3122,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 71 0x47 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3298,8 +3164,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 72 0x48 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3342,8 +3206,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 73 0x49 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3386,8 +3248,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 74 0x4a */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3430,8 +3290,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 75 0x4b */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3474,8 +3332,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 76 0x4c */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3518,8 +3374,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 77 0x4d */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3562,8 +3416,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 78 0x4e */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3606,8 +3458,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 79 0x4f */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3650,8 +3500,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 80 0x50 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3694,8 +3542,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 81 0x51 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3738,8 +3584,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 82 0x52 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3782,8 +3626,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 83 0x53 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3826,8 +3668,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 84 0x54 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3870,8 +3710,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 85 0x55 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3914,8 +3752,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 86 0x56 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -3958,8 +3794,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 87 0x57 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4002,8 +3836,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 88 0x58 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4046,8 +3878,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 89 0x59 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4090,8 +3920,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 90 0x5a */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4134,8 +3962,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 91 0x5b */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4178,8 +4004,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 92 0x5c */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4222,8 +4046,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 93 0x5d */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4266,8 +4088,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 94 0x5e */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4310,8 +4130,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 95 0x5f */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4354,8 +4172,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 96 0x60 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4398,8 +4214,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 97 0x61 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4442,8 +4256,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 98 0x62 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4486,8 +4298,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 99 0x63 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4530,8 +4340,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 100 0x64 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4574,8 +4382,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 101 0x65 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4618,8 +4424,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 102 0x66 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4662,8 +4466,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 103 0x67 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4706,8 +4508,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 104 0x68 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4750,8 +4550,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 105 0x69 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4794,8 +4592,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 106 0x6a */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4838,8 +4634,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 107 0x6b */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4882,8 +4676,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 108 0x6c */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4926,8 +4718,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 109 0x6d */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -4970,8 +4760,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 110 0x6e */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5014,8 +4802,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 111 0x6f */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5058,8 +4844,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 112 0x70 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5102,8 +4886,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 113 0x71 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5146,8 +4928,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 114 0x72 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5190,8 +4970,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 115 0x73 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5234,8 +5012,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 116 0x74 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5278,8 +5054,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 117 0x75 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5322,8 +5096,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 118 0x76 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5366,8 +5138,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 119 0x77 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5410,8 +5180,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 120 0x78 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5454,8 +5222,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 121 0x79 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5498,8 +5264,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 122 0x7a */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5542,8 +5306,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 123 0x7b */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5586,8 +5348,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 124 0x7c */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5630,8 +5390,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 125 0x7d */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5674,8 +5432,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 126 0x7e */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5718,8 +5474,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 127 0x7f */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5762,8 +5516,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 128 0x80 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5806,8 +5558,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 129 0x81 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5850,8 +5600,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 130 0x82 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5894,8 +5642,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 131 0x83 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5938,8 +5684,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 132 0x84 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -5982,8 +5726,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 133 0x85 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6026,8 +5768,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 134 0x86 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6070,8 +5810,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 135 0x87 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6114,8 +5852,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 136 0x88 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6158,8 +5894,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 137 0x89 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6202,8 +5936,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 138 0x8a */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6246,8 +5978,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 139 0x8b */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6290,8 +6020,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 140 0x8c */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6334,8 +6062,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 141 0x8d */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6378,8 +6104,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 142 0x8e */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6422,8 +6146,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 143 0x8f */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6466,8 +6188,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 144 0x90 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6510,8 +6230,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 145 0x91 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6554,8 +6272,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 146 0x92 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6598,8 +6314,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 147 0x93 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6642,8 +6356,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 148 0x94 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6686,8 +6398,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 149 0x95 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6730,8 +6440,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 150 0x96 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6774,8 +6482,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 151 0x97 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6818,8 +6524,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 152 0x98 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6862,8 +6566,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 153 0x99 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6906,8 +6608,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 154 0x9a */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6950,8 +6650,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 155 0x9b */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -6994,8 +6692,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 156 0x9c */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7038,8 +6734,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 157 0x9d */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7082,8 +6776,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 158 0x9e */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7126,8 +6818,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 159 0x9f */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7170,8 +6860,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 160 0xa0 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7214,8 +6902,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 161 0xa1 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7258,8 +6944,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 162 0xa2 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7302,8 +6986,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 163 0xa3 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7346,8 +7028,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 164 0xa4 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7390,8 +7070,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 165 0xa5 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7434,8 +7112,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 166 0xa6 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7478,8 +7154,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 167 0xa7 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7522,8 +7196,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 168 0xa8 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7566,8 +7238,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 169 0xa9 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7610,8 +7280,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 170 0xaa */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7654,8 +7322,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 171 0xab */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7698,8 +7364,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 172 0xac */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7742,8 +7406,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 173 0xad */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7786,8 +7448,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 174 0xae */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7830,8 +7490,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 175 0xaf */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7874,8 +7532,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 176 0xb0 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7918,8 +7574,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 177 0xb1 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -7962,8 +7616,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 178 0xb2 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8006,8 +7658,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 179 0xb3 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8050,8 +7700,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 180 0xb4 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8094,8 +7742,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 181 0xb5 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8138,8 +7784,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 182 0xb6 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8182,8 +7826,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 183 0xb7 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8226,8 +7868,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 184 0xb8 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8270,8 +7910,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 185 0xb9 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8314,8 +7952,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 186 0xba */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8358,8 +7994,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 187 0xbb */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8402,8 +8036,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 188 0xbc */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8446,8 +8078,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 189 0xbd */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8490,8 +8120,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 190 0xbe */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8534,8 +8162,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 191 0xbf */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8578,8 +8204,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 192 0xc0 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8622,8 +8246,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 193 0xc1 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8666,8 +8288,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 194 0xc2 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8710,8 +8330,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 195 0xc3 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8754,8 +8372,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 196 0xc4 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8798,8 +8414,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 197 0xc5 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8842,8 +8456,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 198 0xc6 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8886,8 +8498,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 199 0xc7 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8930,8 +8540,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 200 0xc8 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -8974,8 +8582,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 201 0xc9 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9018,8 +8624,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 202 0xca */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9062,8 +8666,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 203 0xcb */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9106,8 +8708,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 204 0xcc */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9150,8 +8750,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 205 0xcd */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9194,8 +8792,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 206 0xce */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9238,8 +8834,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 207 0xcf */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9282,8 +8876,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 208 0xd0 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9326,8 +8918,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 209 0xd1 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9370,8 +8960,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 210 0xd2 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9414,8 +9002,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 211 0xd3 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9458,8 +9044,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 212 0xd4 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9502,8 +9086,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 213 0xd5 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9546,8 +9128,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 214 0xd6 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9590,8 +9170,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 215 0xd7 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9634,8 +9212,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 216 0xd8 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9678,8 +9254,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 217 0xd9 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9722,8 +9296,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 218 0xda */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9766,8 +9338,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 219 0xdb */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9810,8 +9380,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 220 0xdc */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9854,8 +9422,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 221 0xdd */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9898,8 +9464,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 222 0xde */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9942,8 +9506,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 223 0xdf */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -9986,8 +9548,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 224 0xe0 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10030,8 +9590,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 225 0xe1 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10074,8 +9632,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 226 0xe2 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10118,8 +9674,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 227 0xe3 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10162,8 +9716,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 228 0xe4 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10206,8 +9758,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 229 0xe5 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10250,8 +9800,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 230 0xe6 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10294,8 +9842,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 231 0xe7 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10338,8 +9884,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 232 0xe8 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10382,8 +9926,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 233 0xe9 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10426,8 +9968,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 234 0xea */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10470,8 +10010,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 235 0xeb */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10514,8 +10052,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 236 0xec */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10558,8 +10094,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 237 0xed */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10602,8 +10136,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 238 0xee */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10646,8 +10178,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 239 0xef */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10690,8 +10220,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 240 0xf0 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10734,8 +10262,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 241 0xf1 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10778,8 +10304,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 242 0xf2 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10822,8 +10346,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 243 0xf3 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10866,8 +10388,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 244 0xf4 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10910,8 +10430,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 245 0xf5 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10954,8 +10472,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 246 0xf6 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -10998,8 +10514,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 247 0xf7 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -11042,8 +10556,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 248 0xf8 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -11086,8 +10598,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 249 0xf9 */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -11130,8 +10640,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 250 0xfa */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -11174,8 +10682,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 251 0xfb */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -11218,8 +10724,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 252 0xfc */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -11262,8 +10766,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 253 0xfd */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -11306,8 +10808,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 254 0xfe */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, @@ -11350,8 +10850,6 @@ static const struct kmscon_glyph kmscon_font_8x16_glyphs[256] = { }, }, { /* 255 0xff */ - .ascent = 12, - .descent = 4, .buf = { .width = 8, .height = 16, diff --git a/src/text_font_freetype2.c b/src/text_font_freetype2.c new file mode 100644 index 0000000..a63a147 --- /dev/null +++ b/src/text_font_freetype2.c @@ -0,0 +1,705 @@ +/* + * kmscon - Freetype2 backend for font handling of text renderer + * + * Copyright (c) 2011-2012 David Herrmann + * Copyright (c) 2011 University of Tuebingen + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * SECTION:text_font_freetype2.c + * @short_description: Freetype2 backend for font handling of text renderer + * @include: text.h + * + * The freetype2 backend uses freetype2 to render glyphs into memory + * buffers. It uses a hashmap to cache all rendered glyphs of a single + * font-face. Therefore, rendering should be very fast. Also, when loading a + * glyph it pre-renders all common (mostly ASCII) characters, so it can measure + * the font and return a valid font width. + */ + +#include +#include +#include +#include FT_FREETYPE_H +#include +#include +#include +#include +#include "log.h" +#include "static_misc.h" +#include "text.h" +#include "unicode.h" +#include "uterm.h" + +#define LOG_SUBSYSTEM "text_font_freetype2" + +struct glyph { + bool shrinked; + unsigned int width; +}; + +struct face { + unsigned long ref; + struct kmscon_dlist list; + + bool shrink; + struct kmscon_font_attr attr; + struct kmscon_font_attr real_attr; + unsigned int baseline; + FT_Face face; + pthread_mutex_t glyph_lock; + struct kmscon_hashtable *glyphs; + + struct kmscon_glyph empty; + struct kmscon_glyph inval; +}; + +static pthread_mutex_t manager_mutex = PTHREAD_MUTEX_INITIALIZER; +static unsigned long manager__refcnt; +static FT_Library manager__lib; +static struct kmscon_dlist manager__list = KMSCON_DLIST_INIT(manager__list); + +static void manager_lock() +{ + pthread_mutex_lock(&manager_mutex); +} + +static void manager_unlock() +{ + pthread_mutex_unlock(&manager_mutex); +} + +/* TODO: We currently load the default font-config configuration on start-up but + * should probably provide a way to refresh it on SIGHUP or similar. Font-config + * provides the FcInitBringUptoDate() or FcInitReinitialize() functions. */ +static int manager__ref() +{ + FT_Error err; + + if (!manager__refcnt++) { + err = FT_Init_FreeType(&manager__lib); + if (err) { + log_warn("cannot initialize freetype2"); + --manager__refcnt; + return -EFAULT; + } + + if (!FcInit()) { + log_warn("cannot initialize fontconfig library"); + err = FT_Done_FreeType(manager__lib); + if (err) + log_warn("cannot deinitialize freetype2"); + --manager__refcnt; + return -EFAULT; + } + } + + return 0; +} + +static void manager__unref() +{ + FT_Error err; + + if (!--manager__refcnt) { + /* FcFini() uses assert() to check whether all resources were + * correctly freed before FcFini() is called. As an emergency + * console, we cannot risk being killed because we have a small + * memory leak. Therefore, we rather skip deinitializing + * fontconfig and blame their authors here. + * Never ever use assert()/abort()/etc. in critical code paths! + * Bullshit... + * TODO: Fix upstream fontconfig to drop all those ugly + * assertions. */ + // FcFini(); + err = FT_Done_FreeType(manager__lib); + if (err) + log_warn("cannot deinitialize freetype2"); + } +} + +static int get_glyph(struct face *face, struct kmscon_glyph **out, + kmscon_symbol_t ch) +{ + struct kmscon_glyph *glyph; + struct glyph *data; + FT_Error err; + FT_UInt idx; + FT_Bitmap *bmap; + FT_GlyphSlot slot; + size_t len; + const uint32_t *val; + bool res; + unsigned int i, j, wmax, hmax, idx1, idx2; + int ret, hoff1, hoff2, woff1, woff2; + + pthread_mutex_lock(&face->glyph_lock); + res = kmscon_hashtable_find(face->glyphs, (void**)&glyph, + (void*)(long)ch); + pthread_mutex_unlock(&face->glyph_lock); + if (res) { + *out = glyph; + return 0; + } + + manager_lock(); + + glyph = malloc(sizeof(*glyph) + sizeof(struct glyph)); + if (!glyph) { + log_error("cannot allocate memory for new glyph"); + ret = -ENOMEM; + goto out_unlock; + } + memset(glyph, 0, sizeof(*glyph) + sizeof(struct glyph)); + glyph->data = (void*)(((uint8_t*)glyph) + sizeof(*glyph)); + data = glyph->data; + + /* We currently ignore composed-symbols. That is, we only use the first + * UCS-4 code and draw this character. This works great for most simple + * ASCII characters but composed CJK characters often consist of + * multiple UCS-4 codes. + * TODO: Fix this by drawing all related characters into a single glyph + * and saving it or simply refer to the pango backend which already does + * that. */ + val = kmscon_symbol_get(&ch, &len); + if (len > 1 || !*val) { + ret = -ERANGE; + goto out_glyph; + } + + idx = FT_Get_Char_Index(face->face, *val); + err = FT_Load_Glyph(face->face, idx, FT_LOAD_DEFAULT); + if (err) { + ret = -ERANGE; + goto out_glyph; + } + + err = FT_Render_Glyph(face->face->glyph, FT_RENDER_MODE_NORMAL); + if (err) { + ret = -ERANGE; + goto out_glyph; + } + + slot = face->face->glyph; + bmap = &slot->bitmap; + if (slot->format != FT_GLYPH_FORMAT_BITMAP || + bmap->pixel_mode != FT_PIXEL_MODE_GRAY || + bmap->num_grays != 256 || + !bmap->rows || + !bmap->width) { + ret = -ERANGE; + goto out_glyph; + } + + data->width = bmap->width; + glyph->buf.width = face->real_attr.width; + glyph->buf.height = face->real_attr.height; + glyph->buf.stride = glyph->buf.width; + glyph->buf.format = UTERM_FORMAT_GREY; + glyph->buf.data = malloc(glyph->buf.stride * glyph->buf.height); + if (!glyph->buf.data) { + ret = -ENOMEM; + goto out_glyph; + } + + memset(glyph->buf.data, 0, glyph->buf.stride * glyph->buf.height); + + /* compute width-offsets and relative width-differences */ + if (slot->bitmap_left >= glyph->buf.width) { + wmax = 0; + woff1 = 0; + woff2 = 0; + } else if (slot->bitmap_left < 0) { + if (glyph->buf.width > bmap->width) + wmax = bmap->width; + else + wmax = glyph->buf.width; + woff1 = 0; + woff2 = 0; + } else { + wmax = glyph->buf.width - slot->bitmap_left; + if (wmax > bmap->width) + wmax = bmap->width; + woff1 = slot->bitmap_left; + woff2 = 0; + } + + /* compute height-offsets and relative height-differences */ + hoff1 = (int)glyph->buf.height - face->baseline; + if (hoff1 > slot->bitmap_top) { + hoff1 -= slot->bitmap_top; + hoff2 = 0; + } else { + hoff2 = slot->bitmap_top - hoff1; + hoff1 = 0; + } + + if (bmap->rows - hoff2 > glyph->buf.height - hoff1) + hmax = glyph->buf.height - hoff1; + else + hmax = bmap->rows - hoff2; + + /* copy bitmap into glyph buffer */ + for (i = 0; i < hmax; ++i) { + for (j = 0; j < wmax; ++j) { + idx1 = (i + hoff1) * glyph->buf.stride + (j + woff1); + idx2 = (i + hoff2) * bmap->pitch + (j + woff2); + glyph->buf.data[idx1] = bmap->buffer[idx2]; + } + } + + pthread_mutex_lock(&face->glyph_lock); + ret = kmscon_hashtable_insert(face->glyphs, (void*)(long)ch, glyph); + pthread_mutex_unlock(&face->glyph_lock); + if (ret) { + log_error("cannot add glyph to hashtable"); + goto out_buffer; + } + + *out = glyph; + goto out_unlock; + +out_buffer: + free(glyph->buf.data); +out_glyph: + free(glyph); +out_unlock: + manager_unlock(); + return ret; +} + +static void free_glyph(void *data) +{ + struct kmscon_glyph *glyph = data; + + free(glyph->buf.data); + free(glyph); +} + +static int manager_get_face(struct face **out, struct kmscon_font_attr *attr) +{ + struct kmscon_dlist *iter; + struct face *face, *f; + FcPattern *pat, *mat; + FcResult res; + FcChar8 *fname; + FT_Error err; + int ret, tmp, idx, weight, slant; + double s, em, xsc, ysc; + + manager_lock(); + + if (!attr->height) { + ret = -EINVAL; + goto out_unlock; + } + + if (!attr->width) + attr->width = attr->height; + + kmscon_dlist_for_each(iter, &manager__list) { + face = kmscon_dlist_entry(iter, struct face, list); + if (kmscon_font_attr_match(&face->attr, attr)) { + ++face->ref; + *out = face; + ret = 0; + goto out_unlock; + } + } + + ret = manager__ref(); + if (ret) + goto out_unlock; + + face = malloc(sizeof(*face)); + if (!face) { + log_error("cannot allocate memory for new face"); + ret = -ENOMEM; + goto err_manager; + } + memset(face, 0, sizeof(*face)); + face->ref = 1; + memcpy(&face->attr, attr, sizeof(*attr)); + memcpy(&face->real_attr, attr, sizeof(*attr)); + + ret = pthread_mutex_init(&face->glyph_lock, NULL); + if (ret) { + log_error("cannot initialize glyph lock"); + goto err_free; + } + + ret = kmscon_hashtable_new(&face->glyphs, kmscon_direct_hash, + kmscon_direct_equal, NULL, free_glyph); + if (ret) { + log_error("cannot allocate hashtable"); + goto err_lock; + } + + s = face->attr.height; + weight = face->attr.bold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL; + slant = face->attr.italic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN; + pat = FcPatternBuild(NULL, FC_FAMILY, FcTypeString, face->attr.name, + FC_PIXEL_SIZE, FcTypeDouble, s, + FC_WEIGHT, FcTypeInteger, weight, + FC_SLANT, FcTypeInteger, slant, + NULL); + if (!pat) { + log_error("cannot create font-config pattern"); + ret = -EFAULT; + goto err_htable; + } + + if (!FcConfigSubstitute(NULL, pat, FcMatchPattern)) { + FcPatternDestroy(pat); + log_error("cannot perform font-config substitutions"); + ret = -ENOMEM; + goto err_htable; + } + + res = FcResultMatch; + mat = FcFontMatch(NULL, pat, &res); + if (res != FcResultMatch) { + if (mat) + FcPatternDestroy(mat); + FcPatternDestroy(pat); + log_error("font-config cannot find font: %d", res); + ret = -EFAULT; + goto err_htable; + } + + res = FcPatternGetString(mat, FC_FILE, 0, &fname); + if (res != FcResultMatch) { + FcPatternDestroy(mat); + FcPatternDestroy(pat); + log_error("font-config cannot find font (name)"); + ret = -EFAULT; + goto err_htable; + } + res = FcPatternGetInteger(mat, FC_INDEX, 0, &idx); + if (res != FcResultMatch) { + FcPatternDestroy(mat); + FcPatternDestroy(pat); + log_error("font-config cannot find font (index)"); + ret = -EFAULT; + goto err_htable; + } + + log_debug("loading font %s:%d", (const char*)fname, idx); + err = FT_New_Face(manager__lib, (const char*)fname, idx, &face->face); + FcPatternDestroy(mat); + FcPatternDestroy(pat); + + if (err) { + if (err == FT_Err_Unknown_File_Format) + log_error("unknown font file format"); + else + log_error("cannot load font"); + + ret = -EFAULT; + goto err_htable; + } + + if (!face->face->charmap) { + log_warn("cannot load charmap of new font"); + ret = -EFAULT; + goto err_face; + } + + if (!FT_IS_SCALABLE(face->face)) { + log_warn("non-scalable font"); + ret = -EFAULT; + goto err_face; + } + + err = FT_Set_Pixel_Sizes(face->face, face->attr.width, + face->attr.height); + if (err) { + log_warn("cannot set pixel size of font"); + ret = -EFAULT; + goto err_face; + } + + /* Every font provides an ascender/descender value which we use to + * compute glyph-height and the baseline offset. We need monospace fonts + * as we have the same fixed bounding-box for every glyph. However, if + * the font is not a monospace font, then the most straight-forward + * approach would be using the biggest bounding box. This, however, will + * not work as some characters are extremely wide and the text will look + * horrible. Therefore, we use the ascender/descender values provided + * with each font. This guarantees that special characters like + * line-segments are properly aligned without spacing. If the font does + * not provide proper asc/desc values, then freetype2 will return proper + * subsitutions. */ + + em = face->face->units_per_EM; + xsc = face->face->size->metrics.x_ppem / em; + ysc = face->face->size->metrics.y_ppem / em; + + tmp = face->face->descender * ysc; + if (tmp > 0) + tmp = 0; + face->baseline = -tmp; + + tmp = face->face->ascender * ysc + face->baseline; + if (tmp < 0 || tmp < face->baseline) { + log_warn("invalid ascender/descender values for font"); + ret = -EFAULT; + goto err_face; + } + face->real_attr.height = tmp; + + /* For font-width we use the biggest bounding-box-width. After the font + * has been loaded, this is cut down by pre-rendering some characters + * and computing a better average. */ + + tmp = 1 + (int)(xsc * (face->face->bbox.xMax - face->face->bbox.xMin)); + if (tmp < 0) + tmp = 0; + face->real_attr.width = tmp; + + kmscon_font_attr_normalize(&face->real_attr); + if (!face->real_attr.height || !face->real_attr.width) { + log_warn("invalid scaled font sizes"); + ret = -EFAULT; + goto err_face; + } + + /* The real metrics probably differ from the requested metrics so try + * again to find a suitable cached font. */ + kmscon_dlist_for_each(iter, &manager__list) { + f = kmscon_dlist_entry(iter, struct face, list); + if (kmscon_font_attr_match(&f->real_attr, &face->real_attr)) { + ++f->ref; + *out = f; + ret = 0; + goto err_face; + } + } + + memcpy(attr, &face->real_attr, sizeof(*attr)); + kmscon_dlist_link(&manager__list, &face->list); + *out = face; + ret = 0; + goto out_unlock; + +err_face: + FT_Done_Face(face->face); +err_htable: + kmscon_hashtable_free(face->glyphs); +err_lock: + pthread_mutex_destroy(&face->glyph_lock); +err_free: + free(face); +err_manager: + manager__unref(); +out_unlock: + manager_unlock(); + return ret; +} + +static void manager_put_face(struct face *face) +{ + manager_lock(); + + if (--face->ref) { + kmscon_dlist_unlink(&face->list); + kmscon_hashtable_free(face->glyphs); + pthread_mutex_destroy(&face->glyph_lock); + FT_Done_Face(face->face); + free(face); + manager__unref(); + } + + manager_unlock(); +} + +static int generate_specials(struct face *face) +{ + size_t s; + struct kmscon_glyph *g; + int ret; + + face->empty.data = NULL; + face->empty.buf.width = face->real_attr.width; + face->empty.buf.height = face->real_attr.height; + face->empty.buf.stride = face->empty.buf.width; + face->empty.buf.format = UTERM_FORMAT_GREY; + s = face->empty.buf.stride * face->empty.buf.height; + face->empty.buf.data = malloc(s); + if (!face->empty.buf.data) + return -ENOMEM; + + memset(face->empty.buf.data, 0, s); + + ret = get_glyph(face, &g, kmscon_symbol_make('?')); + if (ret) { + memcpy(&face->inval, &face->empty, sizeof(face->inval)); + } else { + memcpy(&face->inval, g, sizeof(face->inval)); + } + + return 0; +} + +static int kmscon_font_freetype2_init(struct kmscon_font *out, + const struct kmscon_font_attr *attr) +{ + struct face *face; + int ret; + kmscon_symbol_t ch; + unsigned int i, width; + struct kmscon_glyph *glyph; + struct glyph *data; + + memcpy(&out->attr, attr, sizeof(*attr)); + kmscon_font_attr_normalize(&out->attr); + + log_debug("loading freetype2 font %s", out->attr.name); + + ret = manager_get_face(&face, &out->attr); + if (ret) + return ret; + out->baseline = face->baseline; + + /* Shrinking is done to get a better width-value for fonts. As not all + * fonts provide monospace-glyphs, we need to calculate a proper width + * by pre-rendering all ASCII characters and using the widest value. + * TODO: We should extend this with a better algorithm as there are + * common non-ASCII glyphs which are much wider. + * We enable shrinking by default as most fonts have a maximum-width + * which is about 3 times the size of 'M'.*/ + face->shrink = true; + + if (face->shrink) { + width = 0; + for (i = 0x20; i < 0x7f; ++i) { + ch = kmscon_symbol_make(i); + ret = get_glyph(face, &glyph, ch); + if (ret) + continue; + data = glyph->data; + + if (data->width > width) + width = data->width; + } + + if (!width) { + log_warning("cannot measure font"); + face->shrink = false; + } else if (width < face->real_attr.width) { + face->real_attr.width = width; + kmscon_font_attr_normalize(&face->real_attr); + memcpy(&out->attr, &face->real_attr, sizeof(out->attr)); + } + } + + /* generate inval/empty glyphs after shrinking */ + ret = generate_specials(face); + if (ret) + goto err_face; + + out->data = face; + return 0; + +err_face: + manager_put_face(face); + return ret; +} + +static void kmscon_font_freetype2_destroy(struct kmscon_font *font) +{ + struct face *face; + + face = font->data; + log_debug("unloading freetype2 font %s", face->real_attr.name); + free(face->empty.buf.data); + manager_put_face(face); +} + +static int kmscon_font_freetype2_render(struct kmscon_font *font, + kmscon_symbol_t sym, + const struct kmscon_glyph **out) +{ + struct kmscon_glyph *glyph; + struct glyph *data; + struct face *face; + int ret; + + ret = get_glyph(font->data, &glyph, sym); + if (ret) + return ret; + + face = font->data; + data = glyph->data; + if (face->shrink && !data->shrinked) { + data->shrinked = true; + glyph->buf.width = face->real_attr.width; + } + + *out = glyph; + return 0; +} + +static int kmscon_font_freetype2_render_empty(struct kmscon_font *font, + const struct kmscon_glyph **out) +{ + struct face *face = font->data; + + *out = &face->empty; + return 0; +} + +static int kmscon_font_freetype2_render_inval(struct kmscon_font *font, + const struct kmscon_glyph **out) +{ + struct face *face = font->data; + + *out = &face->inval; + return 0; +} + +static const struct kmscon_font_ops kmscon_font_freetype2_ops = { + .name = "freetype2", + .init = kmscon_font_freetype2_init, + .destroy = kmscon_font_freetype2_destroy, + .render = kmscon_font_freetype2_render, + .render_empty = kmscon_font_freetype2_render_empty, + .render_inval = kmscon_font_freetype2_render_inval, +}; + +int kmscon_font_freetype2_load(void) +{ + int ret; + + ret = kmscon_font_register(&kmscon_font_freetype2_ops); + if (ret) { + log_error("cannot register freetype2 font"); + return ret; + } + + return 0; +} + +void kmscon_font_freetype2_unload(void) +{ + kmscon_font_unregister(kmscon_font_freetype2_ops.name); +} diff --git a/src/text_font_pango.c b/src/text_font_pango.c index 4a7f2ec..399deb2 100644 --- a/src/text_font_pango.c +++ b/src/text_font_pango.c @@ -64,6 +64,8 @@ struct face { struct kmscon_dlist list; struct kmscon_font_attr attr; + struct kmscon_font_attr real_attr; + unsigned int baseline; PangoContext *ctx; pthread_mutex_t glyph_lock; struct kmscon_hashtable *glyphs; @@ -159,15 +161,12 @@ static int get_glyph(struct face *face, struct kmscon_glyph **out, line = pango_layout_get_line_readonly(layout, 0); pango_layout_line_get_pixel_extents(line, NULL, &rec); - glyph->ascent = -rec.y; - glyph->descent = rec.height - glyph->ascent; - glyph->buf.width = rec.width; - glyph->buf.height = rec.height; - glyph->buf.stride = rec.width; + glyph->buf.width = face->real_attr.width; + glyph->buf.height = face->real_attr.height; + glyph->buf.stride = glyph->buf.width; glyph->buf.format = UTERM_FORMAT_GREY; - if (!glyph->buf.width || !glyph->buf.height || - glyph->ascent > glyph->buf.height) { + if (!glyph->buf.width || !glyph->buf.height) { ret = -ERANGE; goto out_glyph; } @@ -222,9 +221,12 @@ static void free_glyph(void *data) static int manager_get_face(struct face **out, struct kmscon_font_attr *attr) { struct kmscon_dlist *iter; - struct face *face; + struct face *face, *f; PangoFontDescription *desc; - int ret; + PangoLayout *layout; + PangoRectangle rec; + int ret, num; + const char *str; manager_lock(); @@ -270,15 +272,8 @@ static int manager_get_face(struct face **out, struct kmscon_font_attr *attr) pango_context_set_language(face->ctx, pango_language_get_default()); desc = pango_font_description_from_string(attr->name); - - /* TODO: even though we specify an absolute size, we currently get - * slightly smaller fonts back from pango. This is very odd and we - * haven't found the reason for it, yet. It's not very problematic as - * our text renderer expects such behavior. However, fixing it would be - * nice. */ pango_font_description_set_absolute_size(desc, PANGO_SCALE * face->attr.height); - pango_font_description_set_weight(desc, attr->bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_NORMAL); pango_font_description_set_style(desc, @@ -289,11 +284,51 @@ static int manager_get_face(struct face **out, struct kmscon_font_attr *attr) pango_context_set_font_description(face->ctx, desc); pango_font_description_free(desc); + /* measure font */ + layout = pango_layout_new(face->ctx); + pango_layout_set_height(layout, 0); + pango_layout_set_spacing(layout, 0); + str = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "@!\"$%&/()=?\\}][{°^~+*#'<>|-_.:,;`´"; + num = strlen(str); + pango_layout_set_text(layout, str, num); + pango_layout_get_pixel_extents(layout, NULL, &rec); + + memcpy(&face->real_attr, &face->attr, sizeof(face->attr)); + face->real_attr.height = rec.height; + face->real_attr.width = rec.width / num; + face->baseline = PANGO_PIXELS_CEIL(pango_layout_get_baseline(layout)); + g_object_unref(layout); + + kmscon_font_attr_normalize(&face->real_attr); + if (!face->real_attr.height || !face->real_attr.width) { + log_warning("invalid scaled font sizes"); + ret = -EFAULT; + goto err_face; + } + + /* The real metrics probably differ from the requested metrics so try + * again to find a suitable cached font. */ + kmscon_dlist_for_each(iter, &manager__list) { + f = kmscon_dlist_entry(iter, struct face, list); + if (kmscon_font_attr_match(&f->real_attr, &face->real_attr)) { + ++f->ref; + *out = f; + ret = 0; + goto err_face; + } + } + + memcpy(attr, &face->real_attr, sizeof(*attr)); kmscon_dlist_link(&manager__list, &face->list); *out = face; ret = 0; goto out_unlock; +err_face: + g_object_unref(face->ctx); + kmscon_hashtable_free(face->glyphs); err_lock: pthread_mutex_destroy(&face->glyph_lock); err_free: @@ -326,53 +361,16 @@ static int kmscon_font_pango_init(struct kmscon_font *out, { struct face *face; int ret; - kmscon_symbol_t ch; - unsigned int i, num, width, asc, desc; - struct kmscon_glyph *glyph; - - log_debug("loading pango font %s", attr->name); memcpy(&out->attr, attr, sizeof(*attr)); kmscon_font_attr_normalize(&out->attr); + log_debug("loading pango font %s", out->attr.name); + ret = manager_get_face(&face, &out->attr); if (ret) return ret; - - /* Measure font face: We prerender all ASCII characters here so we can - * measure the average and maximum font width/height and as a bonus all - * characters will already be cached so the next renderings will be - * pretty fast. */ - - num = 0; - width = 0; - asc = 0; - desc = 0; - for (i = 0x20; i < 0x7f; ++i) { - ch = kmscon_symbol_make(i); - ret = get_glyph(face, &glyph, ch); - if (ret) - continue; - - if (glyph->ascent > asc) - asc = glyph->ascent; - if (glyph->descent > desc) - desc = glyph->descent; - if (glyph->buf.width > width) - width = glyph->buf.width; - ++num; - } - - if (!num) { - log_warning("cannot measure font"); - out->attr.width = out->attr.height; - out->baseline = 0; - } else { - out->attr.width = width; - out->attr.height = asc + desc; - out->baseline = desc; - } - kmscon_font_attr_normalize(&out->attr); + out->baseline = face->baseline; out->data = face; return 0; @@ -402,9 +400,16 @@ static int kmscon_font_pango_render(struct kmscon_font *font, return 0; } -static void kmscon_font_pango_drop(struct kmscon_font *font, - const struct kmscon_glyph *glyph) +static int kmscon_font_pango_render_empty(struct kmscon_font *font, + const struct kmscon_glyph **out) { + return kmscon_font_pango_render(font, ' ', out); +} + +static int kmscon_font_pango_render_inval(struct kmscon_font *font, + const struct kmscon_glyph **out) +{ + return kmscon_font_pango_render(font, '?', out); } static const struct kmscon_font_ops kmscon_font_pango_ops = { @@ -412,7 +417,8 @@ static const struct kmscon_font_ops kmscon_font_pango_ops = { .init = kmscon_font_pango_init, .destroy = kmscon_font_pango_destroy, .render = kmscon_font_pango_render, - .drop = kmscon_font_pango_drop, + .render_empty = kmscon_font_pango_render_empty, + .render_inval = kmscon_font_pango_render_inval, }; int kmscon_font_pango_load(void)