Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » U++ Developers corner » CJK woes
CJK woes [message #7639] Fri, 12 January 2007 03:36 Go to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
I just try the UWord with some japanese text,
but when i export it to PDF, then open it but no japanese character showed, only boxes.

Do you guys know how to get proper result?

Thanks

[Updated on: Mon, 22 January 2007 00:22] by Moderator

Report message to a moderator

Re: Howto export japanese word to pdf? [message #7643 is a reply to message #7639] Fri, 12 January 2007 11:12 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mobilehunter wrote on Thu, 11 January 2007 21:36

I just try the UWord with some japanese text,
but when i export it to PDF, then open it but no japanese character showed, only boxes.

Do you guys know how to get proper result?

Thanks



This is most likely a bug in PdfDraw. Maybe a problem in TTF handling code.

Well, first things first - do you see text in UWord correct? What is the platform? If platform is Win32, does it print OK? Can you save and load the text?

If the last answer is yes, please save&zip&upload here the text so that we can fix the issue.

Mirek
Re: Howto export japanese word to pdf? [message #7644 is a reply to message #7643] Fri, 12 January 2007 13:09 Go to previous messageGo to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
luzr wrote on Fri, 12 January 2007 19:12


This is most likely a bug in PdfDraw. Maybe a problem in TTF handling code.

Well, first things first - do you see text in UWord correct? What is the platform? If platform is Win32, does it print OK? Can you save and load the text?

If the last answer is yes, please save&zip&upload here the text so that we can fix the issue.

Mirek


My OS is Win XP Japanese.
I can see the text while editing.
I can open and see the content of qtf file properly, but not the pdf file.
Sorry i cannot print right now, i don't have one at home Smile
  • Attachment: japtest.rar
    (Size: 10.87KB, Downloaded 352 times)
Re: Howto export japanese word to pdf? [message #7647 is a reply to message #7644] Fri, 12 January 2007 17:20 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Interesting, if I load text into UWord, I see boxes.

Looks like some weird font problem. What font is used? Is this font different from normal English XP?

Mirek
Re: Howto export japanese word to pdf? [message #7660 is a reply to message #7647] Sat, 13 January 2007 01:50 Go to previous messageGo to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
luzr wrote on Sat, 13 January 2007 01:20

Interesting, if I load text into UWord, I see boxes.

Looks like some weird font problem. What font is used? Is this font different from normal English XP?

Mirek



Ah forgot to say. First i tried UWord from office computer with normal English XP(but able to show japanese characters), and the problem appeared. Then i tried at home with pure japanese, still have the problem.

If you mean font from UWord, i didn't use any special font.
My uword just has Arial and En-US.
How to find out which font i use?

Btw can you see japanese character from a japanese website?

Thanks
Re: Howto export japanese word to pdf? [message #7662 is a reply to message #7660] Sat, 13 January 2007 09:16 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mobilehunter wrote on Fri, 12 January 2007 19:50

luzr wrote on Sat, 13 January 2007 01:20

Interesting, if I load text into UWord, I see boxes.

Looks like some weird font problem. What font is used? Is this font different from normal English XP?

Mirek



Ah forgot to say. First i tried UWord from office computer with normal English XP(but able to show japanese characters), and the problem appeared. Then i tried at home with pure japanese, still have the problem.



Hm, could be that, now thinking about it, I do not have raw English version, but east-european...

Quote:


If you mean font from UWord, i didn't use any special font.
My uword just has Arial and En-US.
How to find out which font i use?



Arial then Smile

Quote:


Btw can you see japanese character from a japanese website?

Thanks


I think I can. Any website to test?

Somebody with English XP, could you test whether you see japanesse in UWord?

Mirek
Re: Howto export japanese word to pdf? [message #7663 is a reply to message #7662] Sat, 13 January 2007 11:51 Go to previous messageGo to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
Please try Google japan
Re: Howto export japanese word to pdf? [message #7664 is a reply to message #7663] Sat, 13 January 2007 12:44 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
mobilehunter wrote on Sat, 13 January 2007 05:51

Please try Google japan


No boxes, jananesse glyphs everywhere Wink

Mirek
Re: Howto export japanese word to pdf? [message #7665 is a reply to message #7664] Sat, 13 January 2007 13:47 Go to previous messageGo to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
luzr wrote on Sat, 13 January 2007 20:44

mobilehunter wrote on Sat, 13 January 2007 05:51

Please try Google japan


No boxes, jananesse glyphs everywhere Wink

Mirek


Can you also write japanese character at UWord or notepad?
I think if japanese character shown, it would also possible to write one.
Re: Howto export japanese word to pdf? [message #7669 is a reply to message #7665] Sat, 13 January 2007 23:43 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
No, I cannot - I do not have appropriate keyboard methods installed, and even if I would, I do not know how to use it...

For now, I would concentrate on fact that you can save and load the file, see japanesse, but I do not....

Mirek
Re: Howto export japanese word to pdf? [message #7670 is a reply to message #7669] Sun, 14 January 2007 02:06 Go to previous messageGo to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
luzr wrote on Sun, 14 January 2007 07:43

No, I cannot - I do not have appropriate keyboard methods installed, and even if I would, I do not know how to use it...

For now, I would concentrate on fact that you can save and load the file, see japanesse, but I do not....

Mirek


Hope this link setup japanese font help.
From the link, one of the font used is MSPMincho.
But thanks anyway.

[Updated on: Sun, 14 January 2007 02:25]

Report message to a moderator

Re: Howto export japanese word to pdf? [message #7675 is a reply to message #7670] Mon, 15 January 2007 00:09 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Interestingly, on my other machine, glyphs are visible in UWord.

So we are step further Wink

So I have checked what is going on and glyphs are simply missing in the font data that Win returns as font used.

It feels like for the sake of screen painting, Win32 "redirects" paint routine to the font with CJK glyphs - the one I unfortunately am not able to detect yet.

Sounds familiar to anybody?

Relevant code for loading font data is in PdfDraw.cpp at line
744....

Mirek

Re: Howto export japanese word to pdf? [message #7731 is a reply to message #7675] Thu, 18 January 2007 01:10 Go to previous messageGo to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
luzr wrote on Mon, 15 January 2007 08:09


Relevant code for loading font data is in PdfDraw.cpp at line
744....




I tried to write some japanase text with Ms Office, the font always back to Ms PMincho if@i changed to Arial,TimesNewRoman for example.

Then i add Font::Other to richedit code. Now the pdf can contain japanese character even the result was bad.

So may be if UWord default font can be added with Ms PMincho or any other CJK fonts, we can have correct result for PDF.

Reza
Re: Howto export japanese word to pdf? [message #7736 is a reply to message #7731] Thu, 18 January 2007 07:14 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
[quote title=mobilehunter wrote on Wed, 17 January 2007 19:10
I tried to write some japanase text with Ms Office, the font always back to Ms PMincho if@i changed to Arial,TimesNewRoman for example.
[/quote]

I guess, this is relevant trace Smile

Quote:


Then i add Font::Other to richedit code. Now the pdf can contain japanese character even the result was bad.



Not sure I quite understand.

Quote:


So may be if UWord default font can be added with Ms PMincho or any other CJK fonts, we can have correct result for PDF.



RichEdit::FontFaces(const Vector<int>& face);

allows you to set fonts to use with RichEdit. Can you try this with MS PMincho?

Anyway, the right solution still is to somewhat patch the system to work for Arial too...

Mirek
Re: Howto export japanese word to pdf? [message #7738 is a reply to message #7736] Thu, 18 January 2007 09:38 Go to previous messageGo to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
ff.Add(Font::OTHER);

I added that line to RichEdit constructor.

About adding new font, i'm still not quite sure how to add font based on font name, sorry.

Is there any function to add font just by name?

Re: Howto export japanese word to pdf? [message #7743 is a reply to message #7738] Thu, 18 January 2007 16:50 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ops.... Smile

OTHER means first index of font that is not "standard" Smile

Each font has an integer index ("face"). If you want to add specific font, you have to add its index.

You can enumerate fonts (getting index-name pairs), you can also find index for given face name.

See
http://www.ultimatepp.org/src$Draw$Font$en-us.html
Re: Howto export japanese word to pdf? [message #7764 is a reply to message #7743] Sat, 20 January 2007 16:41 Go to previous messageGo to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
luzr wrote on Fri, 19 January 2007 00:50


OTHER means first index of font that is not "standard" Smile



I have modified the UWord source to add japanese font
Vector<int> ff;
ff.Add(Font::ARIAL);
ff.Add(Font::ROMAN);
ff.Add(Font::COURIER);
for(int i = Font::COURIER + 1; i < Font::GetFaceCount(); i++)
    if(i==81) //This is MS PMincho for my system
    {
	if(Font::GetFaceInfo(i) & Font::SCALEABLE &&
	   !(Font::GetFaceInfo(i) & Font::SYMBOLTYPE))
		ff.Add(i);
    }
editor.FontFaces(ff);

But the rendering result is ugly, next character overlapped with half of the previous character.
Then i changed DrawText.cpp, GetPage function.
ptr->GetMetrics(page, ptr->default_width); 
//ptr->GetMetrics(140, ptr->default_width);
/*for(int i = 0; i < 256; i++)
	if(ptr->default_width[i].width) {
		for(int j = 0; j < 256; j++)
		ptr->default_width[j] = ptr->default_width[i];
		break;
        }*/


I don`t know my changes will break everything, but the result is better.

Which line that do text drawing for richedit control?

BTW the pdf exporting still error.
It stopped at this line from TTFReader.cpp
if(head.magicNumber != 0x5F0F3CF5)
	Error();


Thanks
Re: Howto export japanese word to pdf? [message #7765 is a reply to message #7764] Sun, 21 January 2007 09:20 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Quote:


Then i changed DrawText.cpp, GetPage function.
ptr->GetMetrics(page, ptr->default_width); 
//ptr->GetMetrics(140, ptr->default_width);
/*for(int i = 0; i < 256; i++)
	if(ptr->default_width[i].width) {
		for(int j = 0; j < 256; j++)
		ptr->default_width[j] = ptr->default_width[i];
		break;
        }*/


I don`t know my changes will break everything, but the result is better.



Well, the purpose of that code is to save the space needed for character widths for CJK fonts (as all glyphs seem to be monospaced).

Unfortunately, the code was designed for chinesse glyphs (tries to read specific characters starting at unicode 140*256) and very likely these characters are missing in PMincho.

BTW, it is also interesting that widths are correct when the font is accessed as Arial - most likely in that case, some other font is used there to provide chinesse chars.

Anyway, I guess we should try to fix this for PMincho as well. What we need to have there is the correct monospaced width of CJK glyph. Any ideas?

Can you check whether width is gound (break is taken)?

Thinking about it, perhaps we should simply check the first 'page' used instead of 140:

FontInfo::CharMetrics *FontInfo::GetPage(int page) const
{
	if(page >= 46 && !ptr->default_width) {
		ptr->default_width = new CharMetrics[256];
		ptr->GetMetrics(page, ptr->default_width);
		for(int i = 0; i < 256; i++)
			if(ptr->default_width[i].width) {
				for(int j = 0; j < 256; j++)
					ptr->default_width[j] = ptr->default_width[i];
				break;
			}
	}
	CharMetrics *& cm = ptr->width[page];
	if(!cm) {
		cm = new CharMetrics[256];
		ptr->GetMetrics(page, cm);
		if(page == 1)
			ComposeMetrics(ptr->font, cm);
		if(page >= 46) {
			for(int i = 0; i < 256; i++) {
				if(!(cm[i] == ptr->default_width[i]) && cm[i].width)
					return cm;
			}
			delete[] cm;
			cm = ptr->default_width;
		}
	}
	return cm;
}


Can you check please?

Mirek

[Updated on: Sun, 21 January 2007 09:37]

Report message to a moderator

Re: Howto export japanese word to pdf? [message #7766 is a reply to message #7765] Sun, 21 January 2007 09:45 Go to previous messageGo to next message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
luzr wrote on Sun, 21 January 2007 17:20


Can you check whether width is gound (break is taken)?


Hmm sorry, i dont understand about gound, any example?

luzr wrote on Sun, 21 January 2007 17:20


Thinking about it, perhaps we should simply check the first 'page' used instead of 140:


I replaced 140 with page, and commented the for loop below it.

luzr wrote on Sun, 21 January 2007 17:20


Can you check please?



Sorry, you mean check againt codes you just posted? I think it7s the same code with original GetPage codes.
Re: Howto export japanese word to pdf? [message #7767 is a reply to message #7766] Sun, 21 January 2007 12:24 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
gound -> found (typo) Smile

In fact, what I am asking for is to replace 140 with page, but leave the loop there.

The purpose of the loop is to avoid any zero width in the array. Zero width means missing glyph.

What we really are trying to do here is to save memory for monospaced CJK glyphs. We need an array with all values equal to CJK "mono" width. Then we can check for CJK chars whether all characters have the same width (or zero for missing chars) and in that case we can avoid using separate array for the "page" and use single shared array with default widths.

Mirek
Previous Topic: Linear sorted array vs. tree
Next Topic: Welcome to Portland!
Goto Forum:
  


Current Time: Fri Mar 29 13:23:40 CET 2024

Total time taken to generate the page: 0.01173 seconds