- if (font[i])
- {
- TTF_CloseFont(font[i]);
- }
-
- #if USEPAK
- font[i] = TTF_OpenFont(tempPath, ++size);
- #else
- font[i] = TTF_OpenFont("data/vera.ttf", ++size);
- #endif
-
- if (!font[i])
- {
- engine->reportFontFailure();
- }
-
- TTF_GlyphMetrics(font[i], '8', &minx, &maxx, &miny, &maxy, &advance);
-
- // great! we have an exact match
- if (maxx == pixelSize)
- {
- break;
- }
-
- // we've overshot, so we'll use the previous size!
- if (maxx > pixelSize)
- {
- TTF_CloseFont(font[i]);
-
- #if USEPAK
- font[i] = TTF_OpenFont(tempPath, size - 1);
- #else
- font[i] = TTF_OpenFont("data/vera.ttf", size - 1);
- #endif
-
- TTF_GlyphMetrics(font[i], '8', &minx, &maxx, &miny, &maxy, &advance);
-
- break;
- }
-
- if (size >= 100)
- {
- debug(("Pixel size has exceeded 99 pixels! I'm giving up!\n"));
- engine->reportFontFailure();
- }