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
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 previous message
mirek is currently offline  mirek
Messages: 13980
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

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


Current Time: Wed May 15 17:25:47 CEST 2024

Total time taken to generate the page: 0.02593 seconds