Author Topic: Non-English character displayed lower than normal and mutilated,How can I fix it  (Read 3619 times)

Offline edwardlucas

  • Single posting newcomer
  • *
  • Posts: 7
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
« Last Edit: October 10, 2017, 06:26:05 am by edwardlucas »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
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!]

Offline edwardlucas

  • Single posting newcomer
  • *
  • Posts: 7
Does it work correctly in other scintilla based editors like scite or geany?

Geany works fine.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
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!]

Offline New Pagodi

  • Multiple posting newcomer
  • *
  • Posts: 41
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.

Offline edwardlucas

  • Single posting newcomer
  • *
  • Posts: 7
Can you upload a sample file and tell me what are you encoding/locale settings?

Please see the attachment.

file using UTF-8 encoding.

Offline edwardlucas

  • Single posting newcomer
  • *
  • Posts: 7
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
@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!]

Offline New Pagodi

  • Multiple posting newcomer
  • *
  • Posts: 41
@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.

Offline edwardlucas

  • Single posting newcomer
  • *
  • Posts: 7
@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.