Page 1 of 1

There are some BUG in "CEGUIFreeTypeFont.cpp"

Posted: Mon Oct 23, 2006 14:05
by Cogredient
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;

Posted: Fri Oct 27, 2006 08:31
by CrazyEddie
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.

Posted: Fri Oct 27, 2006 11:30
by Cogredient
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.

Posted: Fri Oct 27, 2006 11:49
by Cogredient
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?

Posted: Fri Oct 27, 2006 13:04
by CrazyEddie
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.

Posted: Sat Oct 28, 2006 13:29
by CrazyEddie
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.

Posted: Tue Oct 31, 2006 14:55
by Cogredient
Thanks :)

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

Posted: Wed Nov 01, 2006 10:46
by CrazyEddie
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.

Posted: Fri Nov 03, 2006 11:26
by Cogredient
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 :!:

Posted: Sat Nov 04, 2006 16:54
by CrazyEddie
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.

Posted: Sat Nov 04, 2006 19:19
by Cogredient
It's cool!!
everything is working well
and thanks a lot for your work :D

Posted: Mon Nov 06, 2006 11:09
by CrazyEddie
Hey, no problemo :)

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

CE.