text: font: draw multi-cell characters correctly

Instead of clipping every character to a one-cell boundary, we now render
multi-cell characters correctly into multiple cells.

This does not adjust the console-renderers but only the font renderers to
provide the correct glyphs.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-12-10 15:40:48 +01:00
parent f52baf9896
commit 0de1de25fd
5 changed files with 279 additions and 5 deletions

View File

@ -107,13 +107,14 @@ static void print_unifont_glyph(FILE *out, const struct unifont_glyph *g)
}
fprintf(out, "\t{ /* %d 0x%x */\n"
"\t\t.width = %d,\n"
"\t\t.buf = {\n"
"\t\t\t.width = %d,\n"
"\t\t\t.height = 16,\n"
"\t\t\t.stride = %d,\n"
"\t\t\t.format = UTERM_FORMAT_GREY,\n"
"\t\t\t.data = (uint8_t[]){\n",
g->codepoint, g->codepoint,
g->codepoint, g->codepoint, 1,
width * 4, width * 4);
for (i = 0; i < g->len; ++i) {

View File

@ -70,6 +70,7 @@ bool kmscon_font_attr_match(const struct kmscon_font_attr *a1,
struct kmscon_glyph {
struct uterm_video_buffer buf;
unsigned int width;
void *data;
};

File diff suppressed because it is too large Load Diff

View File

@ -147,9 +147,15 @@ static int get_glyph(struct face *face, struct kmscon_glyph **out,
FT_Bitmap *bmap;
FT_GlyphSlot slot;
bool res;
unsigned int i, j, wmax, hmax, idx1, idx2;
unsigned int i, j, wmax, hmax, idx1, idx2, cwidth;
int ret, hoff1, hoff2, woff1, woff2;
if (!len)
return -ERANGE;
cwidth = tsm_ucs4_get_width(*ch);
if (!cwidth)
return -ERANGE;
pthread_mutex_lock(&face->glyph_lock);
res = shl_hashtable_find(face->glyphs, (void**)&glyph,
(void*)(long)id);
@ -170,6 +176,7 @@ static int get_glyph(struct face *face, struct kmscon_glyph **out,
memset(glyph, 0, sizeof(*glyph) + sizeof(struct glyph));
glyph->data = (void*)(((uint8_t*)glyph) + sizeof(*glyph));
data = glyph->data;
glyph->width = cwidth;
/* 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
@ -208,7 +215,7 @@ static int get_glyph(struct face *face, struct kmscon_glyph **out,
}
data->width = bmap->width;
glyph->buf.width = face->real_attr.width;
glyph->buf.width = face->real_attr.width * cwidth;
glyph->buf.height = face->real_attr.height;
glyph->buf.stride = glyph->buf.width;
glyph->buf.format = UTERM_FORMAT_GREY;
@ -535,6 +542,7 @@ static int generate_specials(struct face *face)
int ret;
static const uint32_t question_mark = '?';
face->empty.width = 1;
face->empty.data = NULL;
face->empty.buf.width = face->real_attr.width;
face->empty.buf.height = face->real_attr.height;
@ -649,7 +657,7 @@ static int kmscon_font_freetype2_render(struct kmscon_font *font, uint32_t id,
data = glyph->data;
if (face->shrink && !data->shrinked) {
data->shrinked = true;
glyph->buf.width = face->real_attr.width;
glyph->buf.width = face->real_attr.width * glyph->width;
}
*out = glyph;

View File

@ -117,11 +117,18 @@ static int get_glyph(struct face *face, struct kmscon_glyph **out,
PangoRectangle rec;
PangoLayoutLine *line;
FT_Bitmap bitmap;
unsigned int cwidth;
size_t ulen, cnt;
char *val;
bool res;
int ret;
if (!len)
return -ERANGE;
cwidth = tsm_ucs4_get_width(*ch);
if (!cwidth)
return -ERANGE;
pthread_mutex_lock(&face->glyph_lock);
res = shl_hashtable_find(face->glyphs, (void**)&glyph,
(void*)(long)id);
@ -140,6 +147,7 @@ static int get_glyph(struct face *face, struct kmscon_glyph **out,
goto out_unlock;
}
memset(glyph, 0, sizeof(*glyph));
glyph->width = cwidth;
layout = pango_layout_new(face->ctx);
@ -166,7 +174,7 @@ 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->buf.width = face->real_attr.width;
glyph->buf.width = face->real_attr.width * cwidth;
glyph->buf.height = face->real_attr.height;
glyph->buf.stride = glyph->buf.width;
glyph->buf.format = UTERM_FORMAT_GREY;