User forums > Using Code::Blocks
Editor enable DirectWrite or not have different font width
ollydbg:
I'm using this font: be5invis/Sarasa-Gothic: Sarasa Gothic / 更纱黑体 / 更紗黑體 / 更紗ゴシック / 사라사 고딕
Especially the mono Simplified Chinese(SC) version. That is: The width of the Chinese character is 2 times as the English character.
Now, the text shows differently when I have DirectWrite enabled or not, see the attachments. When DirectWrite is enabled, the alignment is broken.
Any ideas?
New Pagodi:
I'm not sure about codeblocks, but in the stc source the average char width for a font is set like this:
--- Code: ---m_averageCharWidth = textmetrics.width/extentTest.length();
--- End code ---
where extentTest is is a wxString built from " `~!@#$%^&*()-_=+\\|[]{};:\"\'<,>.?/1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
Obviously that's going to have trouble with nonlatin characters. A better test for average char width is needed that can account for nonlatin characters, but I have no clue how to do that.
ollydbg:
Hi, New Pagodi, thanks for the reply.
I just test the wxWidgets' font sample code.
It looks like when I choose the font size = 10 or font size = 12, the alignment is correct, while if I select the font size = 11, the alignment is wrong.
I just checked this issue under Notepad++, it works correctly in all the three font sizes.
So, my guess is that this issue if from the wxWidgets' font handling, not from the stc source.
See the screen shot below:
EDIT:
Compared with Notepad++, it looks like that in wx font sample, when the mis-alignment happens, the Chinese characters width is correct, and the English character has one extra space in the horizontal direction. So, the English text line is a bit longer than the Chinese text line.
ollydbg:
Hi, everyone, it looks like this is related to the font issue.
See this issue and discussion:
CJK characters alignment issue in some applications Issue #1 jonz94/Sarasa-Gothic-Nerd-Fonts
And this fork of the Sarasa-Gothic font fixed such issue.
ollydbg:
There are mainly two issues here:
1, different font size are not aligned correctly, this issue is related to font itself, see my previous post
2, the DirectWrite/Non-DirectWrite issue still remains. The alignment is totally wrong when DirectWrite is enabled.
Navigation
[0] Message Index
[#] Next page
Go to full version