There are some BUG in "CEGUIFreeTypeFont.cpp"

Discussion regarding the development of CEGUI itself - as opposed to questions about CEGUI usage that should be in the help forums.

Moderators: CEGUI MVP, CEGUI Team

Cogredient
Just popping in
Just popping in
Posts: 6
Joined: Mon Oct 23, 2006 11:29

There are some BUG in "CEGUIFreeTypeFont.cpp"

Postby Cogredient » Mon Oct 23, 2006 14:05

I'm Chinese user of Ogre with CEGUI.(so I'm not good at English.)
I will resolve the problems of Chinese Input.
I glad to know that CEGUI 0.5.0 can auto load TTF Font.
but I think I find some BUG in "CEGUIFreeTypeFont.cpp".

1. When I put "一"(the WCHAR), its UNCODE "0x4E00",the BUG is coming out.(the same as other Font with UNCODE like "0x??00").

2.When I put "?"(the WCHAR),its UNCODE "0xFF1F", another BUG is coming out.(the same as other Font with bigger UNCODE).

I see the codes, There are some problem in

Code: Select all

void FreeTypeFont::rasterize (utf32 start_codepoint, utf32 end_codepoint){
    CodepointMap::const_iterator s = d_cp_map.upper_bound(start_codepoint);
   int i = s->first;
    if (s == d_cp_map.end ())
        return;

    CodepointMap::const_iterator orig_s = s;
    CodepointMap::const_iterator e = d_cp_map.upper_bound(end_codepoint);


There are wrong range and no enough check.(in my opinion)

So I fixed the code to

Code: Select all

void FreeTypeFont::rasterize (utf32 start_codepoint, utf32 end_codepoint)
{
   CodepointMap::const_iterator s = d_cp_map.lower_bound (start_codepoint);
   int i = s->first;
    if (s == d_cp_map.end ())
        return;

    CodepointMap::const_iterator orig_s = s;
    CodepointMap::const_iterator e = d_cp_map.lower_bound (end_codepoint);
   if(e == d_cp_map.end())
      --e;
Last edited by Cogredient on Fri Oct 27, 2006 11:55, edited 3 times in total.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Fri Oct 27, 2006 08:31

Hi,

I understand that English is not your first language, I have read this over a few times now, have thought about it some, but I am unclear as to exactly what the bug is that you are reporting.

A more explicit description of the specific bug or bugs that you are reporting would be most appreciated.

It's possible that I have just missed something in your post, if that's the case, please accept my apologies. If this is the case, if one of the other devs could clear it up for me - using simple terms that even I can understand :lol:

Thanks,

CE.

Cogredient
Just popping in
Just popping in
Posts: 6
Joined: Mon Oct 23, 2006 11:29

Postby Cogredient » Fri Oct 27, 2006 11:30

I'm sorry~

try my best :oops:

Example: I need Font of "0x4E00".

Code: Select all

const FontGlyph *Font::getGlyphData (utf32 codepoint)
{

Code: Select all

    //look here!!!!!!   codepoint == 0x4E00;

Code: Select all

 
   if (codepoint > d_maxCodepoint)
        return 0;

    if (d_glyphPageLoaded)
    {
        // Check if glyph page has been rasterized
        uint page = codepoint / GLYPHS_PER_PAGE;
        uint mask = 1 << (page & (BITS_PER_UINT - 1));
        if (!(d_glyphPageLoaded [page / BITS_PER_UINT] & mask))
        {
            d_glyphPageLoaded [page / BITS_PER_UINT] |= mask;
           

Code: Select all

          //look here!!!!!!  codepoint & ~(GLYPHS_PER_PAGE - 1) == 0x4E00
           //codepoint | (GLYPHS_PER_PAGE - 1)) == 0x4EFF

Code: Select all

 
           rasterize (codepoint & ~(GLYPHS_PER_PAGE - 1),
                       codepoint | (GLYPHS_PER_PAGE - 1));
        }
    }

    CodepointMap::const_iterator pos = d_cp_map.find (codepoint);
    return (pos != d_cp_map.end()) ? &pos->second : 0;
}



You will load all of [0x4E00, 0x4EFF) for me.
but in fact

Code: Select all


void FreeTypeFont::rasterize (utf32 start_codepoint, utf32 end_codepoint)
{
    CodepointMap::const_iterator s = d_cp_map.upper_bound (start_codepoint);

Code: Select all

   //look here!!!!!!   s.first == 0x4E01

Code: Select all

    if (s == d_cp_map.end ())
        return;

    CodepointMap::const_iterator orig_s = s;
    CodepointMap::const_iterator e = d_cp_map.upper_bound (end_codepoint);

Code: Select all

     //look here!!!!!!   e.first == 0x4F00




So I need "0X4E00",But I get all of [0X4E01,0X4EFF],There are out of 0X4E00.

Cogredient
Just popping in
Just popping in
Posts: 6
Joined: Mon Oct 23, 2006 11:29

Postby Cogredient » Fri Oct 27, 2006 11:49

other bug
I need the font of "0xFF1F"

Code: Select all

const FontGlyph *Font::getGlyphData (utf32 codepoint)
{

Code: Select all

      //look here!!!!!!  now codepoint == 0xFF1F;

Code: Select all

if (codepoint > d_maxCodepoint)
        return 0;

    if (d_glyphPageLoaded)
    {
        // Check if glyph page has been rasterized
        uint page = codepoint / GLYPHS_PER_PAGE;
        uint mask = 1 << (page & (BITS_PER_UINT - 1));
        if (!(d_glyphPageLoaded [page / BITS_PER_UINT] & mask))
        {
            d_glyphPageLoaded [page / BITS_PER_UINT] |= mask;

Code: Select all

      //look here!!!!!!  codepoint & ~(GLYPHS_PER_PAGE - 1) == 0xFF00
      //codepoint | (GLYPHS_PER_PAGE - 1)) == 0xFFFF

Code: Select all

               rasterize (codepoint & ~(GLYPHS_PER_PAGE - 1),
                       codepoint | (GLYPHS_PER_PAGE - 1));
        }
    }

    CodepointMap::const_iterator pos = d_cp_map.find (codepoint);
    return (pos != d_cp_map.end()) ? &pos->second : 0;
}


You will load all of [0xFF00 , 0xFFFF ) for me.
but in fact

Code: Select all

void FreeTypeFont::rasterize (utf32 start_codepoint, utf32 end_codepoint)
{
    CodepointMap::const_iterator s = d_cp_map.upper_bound (start_codepoint);

Code: Select all

   //look here!!!!!!   s.first == 0xFF01

Code: Select all

 if (s == d_cp_map.end ())
        return;

    CodepointMap::const_iterator orig_s = s;
    CodepointMap::const_iterator e = d_cp_map.upper_bound (end_codepoint);



Code: Select all


    //look here!!!!!!   e == d_cp_map.end()
    // &&e.first == ??????

So I need "0XFF1F",But I get all of [0XFF01,??????),and... What are there?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Fri Oct 27, 2006 13:04

Hi,

Thanks for the clarification on those points; it definitely seems that there could be some problems there.

I have added it to my list of things to be looked into over this coming weekend. I'll report back once I have some news.

CE.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Sat Oct 28, 2006 13:29

I have now fixed some bugs in the font system code.

The first issue that you highlighted has been addressed, and was caused by the use of upper_bound (which is exclusive of the value passed) to get an iterator for the starting codepoint - this should have been lower_bound, and is now fixed in SVN.

The other point you raised, about then ending iterator 'e' being set to d_cp_map.end(); there is no issue here. the iterator is never dereferenced, and is just used to know when to stop iterating. The reason it's set to end() in the first place is basically because the font in use contains no glyph code higher than 0xFFFF so the system instead renders as much of that range as it can (i.e. up until d_cp_map.end()).

If you could test current SVN code and let us know if there are any further issues, that would be most appreciated.

Thanks again for raising these points :)

CE.

Cogredient
Just popping in
Just popping in
Posts: 6
Joined: Mon Oct 23, 2006 11:29

Postby Cogredient » Tue Oct 31, 2006 14:55

Thanks :)

But I don't know why,
when I load "0xFF1F", my application to break off. like there is something always loading .

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Wed Nov 01, 2006 10:46

Hmm, is this still happening with the fixes I made?

It sounds kind of related to another fix I did, but if it's still doing it with the latest code, then I guess there must be something else.

CE.

Cogredient
Just popping in
Just popping in
Posts: 6
Joined: Mon Oct 23, 2006 11:29

Postby Cogredient » Fri Nov 03, 2006 11:26

The
upper_bound --upper_lower

maybe fixed.




But,
But I don't know why,
when I load "0xFF1F", my application to break off. like there is something always loading .

Maybe not fixed. I get the latest code from SVN today.
and using the DEMO(FontDemo.cpp),The Bug is still happening :!:

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Sat Nov 04, 2006 16:54

Hi,

Thanks for the updated report. I have now, to the best of my knowledge, fixed this last issue too. See SVN rev. 1439.

HTH

CE.

Cogredient
Just popping in
Just popping in
Posts: 6
Joined: Mon Oct 23, 2006 11:29

Postby Cogredient » Sat Nov 04, 2006 19:19

It's cool!!
everything is working well
and thanks a lot for your work :D

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Mon Nov 06, 2006 11:09

Hey, no problemo :)

I was happy to be able to fix some of these more obscure issues.

CE.


Return to “CEGUI Library Development Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest