<div dir="ltr"><div class="gmail_extra">Hi David<br><br><div class="gmail_quote">2013/3/9 David Herrmann <span dir="ltr"><<a href="mailto:dh.herrmann@gmail.com" target="_blank">dh.herrmann@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Hi<br>
<div class="im"><br>
On Sat, Mar 9, 2013 at 8:41 AM, Chang Liu <<a href="mailto:cl91tp@gmail.com">cl91tp@gmail.com</a>> wrote:<br>
> This patch fixes a rendering problem of certain CJK fonts which causes<br>
> the rendered CJK characters to appear downward-shifted.<br>
><br>
> For some CJK fonts, pango_layout_get_pixel_extent() returns different<br>
> logical_rect for CJK glyphs and Latin glyphs. Therefore, using -rec.y<br>
> as the y position of the baseline will render the CJK glyphs downward-<br>
> shifted. face.baseline will be a better choice.<br>
><br>
> ---<br>
>  src/font_pango.c | 2 +-<br>
>  1 file changed, 1 insertion(+), 1 deletion(-)<br>
><br>
> diff --git a/src/font_pango.c b/src/font_pango.c<br>
> index c2954c6..0964123 100644<br>
> --- a/src/font_pango.c<br>
> +++ b/src/font_pango.c<br>
> @@ -199,7 +199,7 @@ static int get_glyph(struct face *face, struct kmscon_glyph **out,<br>
>         bitmap.pixel_mode = FT_PIXEL_MODE_GRAY;<br>
>         bitmap.buffer = glyph->buf.data;<br>
><br>
> -       pango_ft2_render_layout_line(&bitmap, line, -rec.x, -rec.y);<br>
> +       pango_ft2_render_layout_line(&bitmap, line, -rec.x, face->baseline);<br>
<br>
</div>Ok, lets summarize how this is supposed to work (as I myself don't<br>
remember it correctly):<br>
We calculate the width/height of a cell by drawing the basic ASCII<br>
characters in a cache and measuring them. Every other glyph is then<br>
supposed to fit into multiples of these cells (multiples only in<br>
horizontal direction).<br>
"face->baseline" is set according to the baseline of this measurement<br>
(that is, the ASCII characters).<br>
<br>
So what this basically does is calculating a bounding box for our<br>
glyphs and computing the logical origin. Every glyph that we draw<br>
should be drawn at the logical origin (which is face->baseline) and<br>
clipped according to this box.<br>
So we do have to use face->baseline here, indeed. Using -rec.y aligns<br>
to the bottom edge instead, which is obviously wrong. </blockquote><div style>Yes, my thoughts exactly.</div><div style><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Could you tell me the font-name so I can reproduce this?</blockquote><div style>For Latin languages I am using  Lucida Console and for Chinese I am using</div><div style>Microsoft YaHei. Both of them are default fonts in MS Win 8 which I illegally ^_^<br>
</div><div style>downloaded from the Internet. Not sure if you could do this in Europe but I guess</div><div style>you might need a valid license of Win 8 before you could legally use these fonts.</div><div style>However these fonts are available in Win 7 too and I don't think they underwent</div>
<div style>substantial changes since then. Since most laptop came with a pre-installed Win 7</div><div style>I think you can legally copy these fonts from a Win 7 installation and use them</div><div style>for testing. They are located in C:\Windows\Fonts and named lucida.ttf and</div>
<div style>msyh{,bd}.ttc.</div><div style><br></div><div style>There are also a bunch of CJK fonts in MS Win 7 which I tested. Look for .ttf or .ttc</div><div style>files which are larger than 1 MB, they are most certainly CJK fonts. They are rendered</div>
<div style>correctly after the patch is applied.</div><div style><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 <br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
I changed your commit-message to mention why this fix is correct and<br>
then applied the patch. I hope you don't mind.<br></blockquote><div style>No, not at all. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

Commit: e874518153e509b74aa8e3e52b02642718eb5575<br></blockquote><div style><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

There's also ./docs/unicode-test.txt. Could you check whether there<br>
are symbols in it that show this wrong behavior? If not, could you<br>
tell me what symbols you used in your screenshots so I can add them.<br>
<br></blockquote><div style>Yes. The 4th line (empty line included), the line with a `Unicode' in it, is Chinese</div><div style>for `What is Unicode?'. All the Chinese characters in that line show this behavior.</div>
<div style> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Thanks a lot for reporting this!<br>
David<br>
<div class="im"><br>
>         pthread_mutex_lock(&face->glyph_lock);<br>
>         ret = shl_hashtable_insert(face->glyphs, (void*)(long)id, glyph);<br>
> --<br>
> 1.8.1.5<br>
><br>
</div>> _______________________________________________<br>
> kmscon-devel mailing list<br>
> <a href="mailto:kmscon-devel@lists.freedesktop.org">kmscon-devel@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/kmscon-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/kmscon-devel</a><br>
</blockquote></div><br></div></div>