News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Non-English character displayed lower than normal and mutilated,How can I fix it

Started by edwardlucas, October 10, 2017, 06:23:53 AM

Previous topic - Next topic

edwardlucas

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


use font ubuntu Mono 11 get even worse

oBFusCATed

Does it work correctly in other scintilla based editors like scite or geany?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

edwardlucas


oBFusCATed

Can you upload a sample file and tell me what are you encoding/locale settings?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

New Pagodi

I suspect the problem is that in PlatWX.cpp, SurfaceImpl uses a hard coded string with only latin characters to compute ascent and decent.


#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.

edwardlucas

Quote from: oBFusCATed on October 10, 2017, 07:47:51 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.

edwardlucas

Quote from: 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.


#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.

oBFusCATed

@New Pagodi: Can we do something about this problem?
@edwardlucas: Do you use the same font in geany as in c::b?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

New Pagodi

Quote from: oBFusCATed on October 11, 2017, 12:51:13 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.

edwardlucas

Quote from: oBFusCATed on October 11, 2017, 12:51:13 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.