Page 1 of 1

Iterating over all loaded fonts

Posted: Sun Jan 01, 2006 16:41
by phoenix
Hi all,

I'm currently trying to iterate over all loaded fonts to add the missing umlaut glyphs to each font.
So i tried the following:

Code: Select all

FontManager* fmgr = FontManager::getSingletonPtr();
String new_glyphs = "äöüÄÖÜ";

for( FontManager::FontIterator it = fmgr->getIterator(); !it.isAtEnd(); it++ )
{
   Font* font = *it;

   String glyphset( font->getAvailableGlyphs() );

   for( int i = 0; i < new_glyphs.length(); i++ )
   {
      if( glyphset.find( new_glyphs[i] ) == String::npos )
      {
         glyphset += new_glyphs[i];
      }
   }

   font->defineFontGlyphs( glyphset );
}


In my scheme file I have loaded 4 different font files. But the above code only seems to find one of them. After the first loop, dereferencing the iterator yields 0xcdcdcdcd and therefore usage of the font pointer throws an exception.

Am I using the iterator in a wrong way or is this a bug?

thx

Re: Iterating over all loaded fonts

Posted: Sat Jan 07, 2006 20:35
by phoenix
*bump*
:oops:

Re: Iterating over all loaded fonts

Posted: Mon Jan 09, 2006 00:08
by lindquist
try

Code: Select all

String new_glyphs = (utf8*)"äöüÄÖÜ";

and be sure to save the source file utf8 encoded.

This did the trick for me... I did manage to get it to crash when using special character without the cast and correct encoding. It is noted.