|
|
Home » U++ Library support » U++ Libraries and TheIDE: i18n, Unicode and Internationalization » It's suspected to be an issue with Font.
It's suspected to be an issue with Font. [message #31658] |
Fri, 18 March 2011 23:50 |
Lance
Messages: 526 Registered: March 2007
|
Contributor |
|
|
The programs I used to compare are UWord from the UPP, and MS Word. The platform is Windows 7.
The text I used to test is:
ultimate++是一个性能优良的C++GUI库
The problem with U++ drawed text is that some characters are notably larger than others and some have incorrect horizontal displacement.
Please see attached picture for a visual effect.
I also encountered issue where chinese characters are displayed correctly displayed on Windows but are blank on Ubuntu. And when I copies the same text that was displayed as blank to, say gedit, the text displayed correctly as in Windows. That part I will attach picture in future.
|
|
|
Re: It's suspected to be an issue with Font. [message #31942 is a reply to message #31658] |
Sun, 10 April 2011 14:42 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
Lance wrote on Fri, 18 March 2011 18:50 | The programs I used to compare are UWord from the UPP, and MS Word. The platform is Windows 7.
The text I used to test is:
ultimate++是一个性能优良的C++GUI库
The problem with U++ drawed text is that some characters are notably larger than others and some have incorrect horizontal displacement.
|
It works fine on my Windows 7. However, I believe that the problem is caused by font substitution mechanism and perhaps on your system, you have some font that takes precendence for some glyphs, but does not contain other characters.
However, I have noticed that OpenOffice or Wordpad are preferring SimSun font, so I have given it higher priority now. Please check.
The core table for font subsitutions is in Draw/FontCR, table sFontReplacements. If U++ does not find required glyph in the font, it tries to get the glyph by going through fonts in this table and uses first glyph available... Maybe you could play with it a bit to get better results.
Quote: |
I also encountered issue where chinese characters are displayed correctly displayed on Windows but are blank on Ubuntu. And when I copies the same text that was displayed as blank to, say gedit, the text displayed correctly as in Windows. That part I will attach picture in future.
|
I believe this is basically the same issue - gedit has better knowledge about fonts, so is able to find a better replacement.
Maybe, if openoffice behaves similary in Ubuntu as in Windows, you can try to paste characters into Openoffice and then check what font it has actually used for it. Then we can add this font to replacement table...
Alternatively please post some problematic text here so that I can do this myself.
|
|
|
|
|
|
Re: It's suspected to be an issue with Font. [message #32006 is a reply to message #32005] |
Sat, 16 April 2011 21:02 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
#include <CtrlLib/CtrlLib.h>
using namespace Upp;
struct MyApp : TopWindow {
virtual void Paint(Draw& w) {
w.DrawRect(GetSize(), White);
w.DrawText(10, 10, "ultimate++是一个性能优良的C++GUI库");
}
};
GUI_APP_MAIN
{
MyApp().Run();
}
And this DDUMP
bool Replace(Font fnt, int chr, Font& rfnt)
{
static Vector<int> rface;
static Vector<dword> l, h;
ONCELOCK {
for(int i = 0; i < __countof(sFontReplacements) && rface.GetCount() < 20; i++) {
int q = Font::FindFaceNameIndex(sFontReplacements[i].name);
if(q > 0) {
rface.Add(q);
l.Add(sFontReplacements[i].l);
h.Add(sFontReplacements[i].h);
}
}
}
Font f = fnt;
dword tl = chr < 4096 ? 0x80000000 >> (chr >> 7) : 0;
dword th = 0x8000000 >> ((dword)chr >> 11);
// DDUMP(FormatIntHex(chr));
// DDUMP(FormatIntHex(th));
for(int i = 0; i < rface.GetCount(); i++) {
// DDUMP(Font(rface[i], 10));
// DDUMP(FormatIntHex(h[i]));
// DDUMP(FormatIntHex(h[i] & th));
if(((l[i] & tl) || (h[i] & th)) && IsNormal(f.Face(rface[i]), chr)) {
int a = fnt.GetAscent();
int d = fnt.GetDescent();
if(f.GetAscent() > a || f.GetDescent() > d) {
static sFontMetricsReplacement cache[256];
int q = CombineHash(fnt, f) & 255;
if(cache[q].src != fnt || cache[q].dst != f) {
cache[q].src = fnt;
cache[q].dst = f;
while((f.GetAscent() > a || f.GetDescent() > d) && f.GetHeight() > 1) {
f.Height(max(1, min(f.GetHeight() - 1, f.GetHeight() * 9 / 10)));
}
cache[q].mdst = f;
}
else
f = cache[q].mdst;
}
rfnt = f;
DDUMP(rfnt.GetFaceName()); // <<- HERE
return true;
}
}
return false;
}
[Updated on: Sat, 16 April 2011 21:03] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: It's suspected to be an issue with Font. [message #32240 is a reply to message #32235] |
Mon, 02 May 2011 20:07 |
|
mirek
Messages: 13975 Registered: November 2005
|
Ultimate Member |
|
|
Lance wrote on Mon, 02 May 2011 10:11 | By the way, SimSun should be a safe bet. Any Chinese characters should be representable in SimSun. Say there is a fancy font FancyFont. It only implemented 2000 most common chinese characters, than a character that's not in this set should be displayed in SimSun
|
Well, but problem is that SimSun is already tested and required...
It is all really weird. In Windows, it works for me just fine. In your machine, it seems to choose "Arial Unicode MS" instead.
Hm, one possible explanation: Do not you have the same Arial Unicode MS installed on ubuntu?
It actually seems there is something wrong with that font, the replacement algorithm seems to have detected required glyphs in it...
OK, one more try: try to move SimSun in the list BEFORE Arial Unicode MS.
struct sRFace {
const char *name;
dword l, h;
} sFontReplacements[] = {
{ "sans-serif", 0xffee0008, 0xdc000801 },
{ "Arial", 0xfffe0000, 0x09c00080 },
{ "SimSun", 0xfd800000, 0x09ffff00 },
{ "Arial Unicode MS", 0xfffc3fef, 0xfa7ff7e7 },
{ "MS UI Gothic", 0xffc01008, 0x0fffff00 },
{ "MS Mincho", 0xffc01008, 0x0fffff00 },
.....
Let us see, maybe it could help in windows.
Another thing to consider is to list all fonts to find out whether there is something bad with names:
GUI_APP_MAIN
{
for(int i = 0; i < Font::GetFaceCount(); i++)
LOG(Font::GetFaceName(i));
}
[Updated on: Mon, 02 May 2011 20:07] Report message to a moderator
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Apr 26 15:54:03 CEST 2024
Total time taken to generate the page: 0.02046 seconds
|
|
|