Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: edwardlucas on October 10, 2017, 06:23:53 am

Title: Non-English character displayed lower than normal and mutilated,How can I fix it
Post by: edwardlucas on October 10, 2017, 06:23:53 am
I have tried code::blocks 16.01 on ubuntu 16.04.3, ubuntu 17.04, mint 18.2 xfce,  and have same problem as below:
Chinese characters displayed in the code editor were mutilated because they were lower than English characters. and I have tried several fonts, no lucky.
Please take a look these screenshots on ubuntu:

Editor settings choose font DejaVu Sans Mono 11
(http://forums.codeblocks.org/index.php?action=dlattach;topic=22192.0;attach=8884)

use font ubuntu Mono 11 get even worse
(http://forums.codeblocks.org/index.php?action=dlattach;topic=22192.0;attach=8886)
Title: Re: Non-English character displayed lower than normal and mutilated,How can I fix it
Post by: oBFusCATed on October 10, 2017, 07:05:42 am
Does it work correctly in other scintilla based editors like scite or geany?
Title: Re: Non-English character displayed lower than normal and mutilated,How can I fix it
Post by: edwardlucas on October 10, 2017, 07:17:07 am
Does it work correctly in other scintilla based editors like scite or geany?

Geany works fine.
Title: Re: Non-English character displayed lower than normal and mutilated,How can I fix it
Post by: oBFusCATed on October 10, 2017, 07:47:51 am
Can you upload a sample file and tell me what are you encoding/locale settings?
Title: Re: Non-English character displayed lower than normal and mutilated,How can I fix it
Post by: New Pagodi on October 10, 2017, 08:14:43 am
I suspect the problem is that in PlatWX.cpp, SurfaceImpl uses a hard coded string with only latin characters to compute ascent and decent.

Code
#define EXTENT_TEST wxT(" `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

XYPOSITION SurfaceImpl::Ascent(Font &font) {
    SetFont(font);
    int w, h, d, e;
    hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
    const int ascent = h - d;
    SetAscent(font, ascent);
    return ascent;
}

XYPOSITION SurfaceImpl::Descent(Font &font) {
    SetFont(font);
    int w, h, d, e;
    hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
    return d;
}

You can see in the pictures posted that the ascent of the characters after the "//TODO" are higher than for the "//TODO" part, so the numbers computed computed using the hard coded sting won't work for rendering those characters. 

Is there a font where Asian and Latin characters are rendered with the same ascent?  If so, that font should work.
Title: Re: Non-English character displayed lower than normal and mutilated,How can I fix it
Post by: edwardlucas on October 10, 2017, 11:28:54 am
Can you upload a sample file and tell me what are you encoding/locale settings?

Please see the attachment.

file using UTF-8 encoding.
Title: Re: Non-English character displayed lower than normal and mutilated,How can I fix it
Post by: edwardlucas on October 10, 2017, 11:35:24 am
I suspect the problem is that in PlatWX.cpp, SurfaceImpl uses a hard coded string with only latin characters to compute ascent and decent.

Code
#define EXTENT_TEST wxT(" `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

XYPOSITION SurfaceImpl::Ascent(Font &font) {
    SetFont(font);
    int w, h, d, e;
    hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
    const int ascent = h - d;
    SetAscent(font, ascent);
    return ascent;
}

XYPOSITION SurfaceImpl::Descent(Font &font) {
    SetFont(font);
    int w, h, d, e;
    hdc->GetTextExtent(EXTENT_TEST, &w, &h, &d, &e);
    return d;
}

You can see in the pictures posted that the ascent of the characters after the "//TODO" are higher than for the "//TODO" part, so the numbers computed computed using the hard coded sting won't work for rendering those characters. 

Is there a font where Asian and Latin characters are rendered with the same ascent?  If so, that font should work.

I tried font "WenQuanYi Micro Hei Mono" which include Chinese and Latin character, it works fine! but I don't like the Latin  and number characters in this font.

Please see the screen shot.
Title: Re: Non-English character displayed lower than normal and mutilated,How can I fix it
Post by: oBFusCATed on October 11, 2017, 12:51:13 am
@New Pagodi: Can we do something about this problem?
@edwardlucas: Do you use the same font in geany as in c::b?
Title: Re: Non-English character displayed lower than normal and mutilated,How can I fix it
Post by: New Pagodi on October 11, 2017, 01:56:38 am
@New Pagodi: Can we do something about this problem?

Maybe.  I don't know enough about fonts or non-English languages to have a better solution.
Title: Re: Non-English character displayed lower than normal and mutilated,How can I fix it
Post by: edwardlucas on October 11, 2017, 03:07:48 am
@edwardlucas: Do you use the same font in geany as in c::b?

Yes I tried same fonts in geany, all fonts have problem displayed in C::B all work fine in geany.

thanks.