[kmscon-devel] [PATCH] font: pango: fix a rendering problem of certain CJK fonts

Chang Liu cl91tp at gmail.com
Fri Mar 8 23:41:28 PST 2013


This patch fixes a rendering problem of certain CJK fonts which causes
the rendered CJK characters to appear downward-shifted.

For some CJK fonts, pango_layout_get_pixel_extent() returns different
logical_rect for CJK glyphs and Latin glyphs. Therefore, using -rec.y
as the y position of the baseline will render the CJK glyphs downward-
shifted. face.baseline will be a better choice.
---
 src/font_pango.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/font_pango.c b/src/font_pango.c
index c2954c6..0964123 100644
--- a/src/font_pango.c
+++ b/src/font_pango.c
@@ -199,7 +199,7 @@ static int get_glyph(struct face *face, struct kmscon_glyph **out,
 	bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;
 	bitmap.buffer = glyph->buf.data;
 
-	pango_ft2_render_layout_line(&bitmap, line, -rec.x, -rec.y);
+	pango_ft2_render_layout_line(&bitmap, line, -rec.x, face->baseline);
 
 	pthread_mutex_lock(&face->glyph_lock);
 	ret = shl_hashtable_insert(face->glyphs, (void*)(long)id, glyph);
-- 
1.8.1.5



More information about the kmscon-devel mailing list