Author Topic: Encoding change will make indentation guides become very strange  (Read 2102 times)

Offline jianguhan

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
When I change the encoding to 50936,indentation guides become deviated

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1666
  • Karma: +29/-2
    • View Profile
    • HippoEDIT
Re: Encoding change will make indentation guides become very strange
« Reply #1 on: December 26, 2009, 11:42:28 am »
Hi jianguhan,

normally hippoedit tries to find charset value which suits best to selected encoding (generally windows does it).
Charset value passed to windows font creation routines and helps Windows to do font substitution if  current font does not have complete symbol set for proffered charset.

Probably this is a reason in your case. Windows has substitute current font by some other font which symbol set suits better but probably the font is not monospaced.
Because font is not monospaced, indent guides can not be drawn correctly (because, for example width of the space is not equal to other literal symbols).

So... This is by design, just select monospaced Chinese font (or any other monospaced font with full symbol set) to be current for this type of documents.

Best regards,
Alex.

Offline jianguhan

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Encoding change will make indentation guides become very strange
« Reply #2 on: December 31, 2009, 08:45:20 am »
Hi alex,
when I change the encoding to 50936,
No matter what I set the fonts(Toos->Options->Syntax settings->Defult->Fonts And Colors),
finally the fonts are displayed '宋体',
and the indentation guides are still wrong :'(

I had already tried all font inside my system,
but still cann't resolve this problem.
« Last Edit: December 31, 2009, 10:02:10 am by jianguhan »

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1666
  • Karma: +29/-2
    • View Profile
    • HippoEDIT
Re: Encoding change will make indentation guides become very strange
« Reply #3 on: December 31, 2009, 04:39:38 pm »
Hi jianguhan,

of course Chinese symbols will be displayed, because current font is substituted by some which has Chinese char set. And probably this is not a mono spaced font.
You need to select as current for default some monospaced Chinese font.

Just Google for Chinese mospaced font and first link is this http://www.pinyinjoe.com/pinyin/pinyin_XPfonts.htm.
Try with NSimSun or MingLiU as font for Default syntax (then will be available everywhere).

Best regards,
Alex.

Offline jianguhan

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Encoding change will make indentation guides become very strange
« Reply #4 on: January 08, 2010, 09:50:05 am »
Hi alex,
I have tried use MingLiU font for Default syntax,
the result is the same,
then I tried set the Selected Text to Bold,
the indentation guides seems to be correct,
I wonder whether the width of the Bold font used on the Normal font?
« Last Edit: January 08, 2010, 10:12:04 am by jianguhan »

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1666
  • Karma: +29/-2
    • View Profile
    • HippoEDIT
Re: Encoding change will make indentation guides become very strange
« Reply #5 on: January 08, 2010, 03:12:48 pm »
Hi jianguhan,

to calculate indentation size for drawing I use multiplied size of the 'W' char drawn with both bold and italic styles enabled. This is normally maximum char width for roman charset even with non monospaced fonts.

For monospaced fonts width of all characters in all styles are same. So non bold, no italic space equal to bold and italic W for example. This is a reason why indentation guides and block selection works for them correctly.

But what we see... (I have checked your example with MingLiU) that this is not a rule for non roman fonts. I think it is really complicated to create monospaced font for mixture of English and Chinese symbols, just because of the symbol nature... Maybe they exist bu I do not know. MingLiU is also not really monospaced and because of this size of the W not equal to size of space.

The solution I can provide is to calculate indentation guides based on space symbol size.  This is also not perfect because will solve problem only with leading spaces, but will not match to size of characters in other lines but this will cover more scenarios then current state. I think.
Also this does not solve block selection. Because it is column base and not a pixel base, you will get mostly same problem. But I do not see easy solution for this now.

SO.. I will fix your example in beta 1.48 (will be available in some days) and let us see.
The good thing that this rather safe and do not destroy existing logic for the rest.

Best regards,
Alex.

Offline jianguhan

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Encoding change will make indentation guides become very strange
« Reply #6 on: January 11, 2010, 03:30:19 am »
1.48 is ok,
Thanks ;D

Offline jianguhan

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Encoding change will make indentation guides become very strange
« Reply #7 on: January 11, 2010, 04:51:29 am »
There is a little problem,
when I press the Enter key  the cursor position is wrong(1.jpg),
then i press I the cursor position is correct(2.jpg)

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1666
  • Karma: +29/-2
    • View Profile
    • HippoEDIT
Re: Encoding change will make indentation guides become very strange
« Reply #8 on: January 11, 2010, 12:10:58 pm »
yes, I can reproduce this.

The reason is same as before, width of bold italic W used instead of space.
HE does not insert spaces immediately when creating indent for new line, but only after you actually type something. Before this there are virtual spaces, calculated from size of W.

Will fix with next 1.48 beta. Probably will be available in a week.

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1666
  • Karma: +29/-2
    • View Profile
    • HippoEDIT
Re: Encoding change will make indentation guides become very strange
« Reply #9 on: January 13, 2010, 04:24:16 pm »
I have found more or less monospaced font for Chinese - SimSun.
Try it, but in addition probably from next beta I will disable automatic charset recognition, because it does not provide too much benefits... This will lead to result that everywhere will be used default system wide charset and probably then Courier New will work fine.
Maybe in 1.50 it will come back as an option.

Added:
another thing what you can already do, is to disable automatic charset determination by setting some specific charset in def_spec.xml (of it is not overwritten in def_user.xml):
Code: [Select]
    <FONTS>
      <Font only_monospaced="false" size="10" face_name="Courier New" quality="0" charset="1"/>
    </FONTS>
For example set charset to 0.
« Last Edit: January 13, 2010, 04:33:16 pm by alex »

Offline jianguhan

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Encoding change will make indentation guides become very strange
« Reply #10 on: January 19, 2010, 03:04:20 am »
I tried 756,
it's great :D

Offline alex

  • Developer
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1666
  • Karma: +29/-2
    • View Profile
    • HippoEDIT
Re: Encoding change will make indentation guides become very strange
« Reply #11 on: January 19, 2010, 10:38:02 am »
good. Probably because now you get a real Courier New, not substituted by something else...
In addition to the space based calculation for virtual space position I have also added.

 

Related Topics

  Subject / Started by Replies Last post
3 Replies
456 Views
Last post August 27, 2009, 08:43:20 pm
by alex
3 Replies
744 Views
Last post September 15, 2009, 07:29:11 pm
by alex
0 Replies
731 Views
Last post December 11, 2008, 09:16:37 am
by Stefan
5 Replies
577 Views
Last post August 13, 2010, 02:57:51 pm
by alex
1 Replies
296 Views
Last post June 06, 2011, 01:14:44 pm
by alex