Skip to content

Commit

Permalink
Suppress CGUITTFONT build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeno- committed Feb 13, 2015
1 parent af7f369 commit d44cb54
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/cguittfont/CGUITTFont.cpp
Expand Up @@ -29,6 +29,7 @@
*/

#include <irrlicht.h>
#include <iostream>
#include "CGUITTFont.h"

namespace irr
Expand Down Expand Up @@ -64,8 +65,24 @@ scene::SMesh CGUITTFont::shared_plane_;

//

/** Checks that no dimension of the FT_BitMap object is negative. If either is
* negative, abort execution.
*/
inline void checkFontBitmapSize(const FT_Bitmap &bits)
{
if ((s32)bits.rows < 0 || (s32)bits.width < 0) {
std::cout << "Insane font glyph size. File: "
<< __FILE__ << " Line " << __LINE__
<< std::endl;
abort();
}
}

video::IImage* SGUITTGlyph::createGlyphImage(const FT_Bitmap& bits, video::IVideoDriver* driver) const
{
// Make sure our casts to s32 in the loops below will not cause problems
checkFontBitmapSize(bits);

// Determine what our texture size should be.
// Add 1 because textures are inclusive-exclusive.
core::dimension2du d(bits.width + 1, bits.rows + 1);
Expand All @@ -87,10 +104,11 @@ video::IImage* SGUITTGlyph::createGlyphImage(const FT_Bitmap& bits, video::IVide
const u32 image_pitch = image->getPitch() / sizeof(u16);
u16* image_data = (u16*)image->lock();
u8* glyph_data = bits.buffer;
for (int y = 0; y < bits.rows; ++y)

for (s32 y = 0; y < (s32)bits.rows; ++y)
{
u16* row = image_data;
for (int x = 0; x < bits.width; ++x)
for (s32 x = 0; x < (s32)bits.width; ++x)
{
// Monochrome bitmaps store 8 pixels per byte. The left-most pixel is the bit 0x80.
// So, we go through the data each bit at a time.
Expand All @@ -116,10 +134,10 @@ video::IImage* SGUITTGlyph::createGlyphImage(const FT_Bitmap& bits, video::IVide
const u32 image_pitch = image->getPitch() / sizeof(u32);
u32* image_data = (u32*)image->lock();
u8* glyph_data = bits.buffer;
for (int y = 0; y < bits.rows; ++y)
for (s32 y = 0; y < (s32)bits.rows; ++y)
{
u8* row = glyph_data;
for (int x = 0; x < bits.width; ++x)
for (s32 x = 0; x < (s32)bits.width; ++x)
{
image_data[y * image_pitch + x] |= static_cast<u32>(255.0f * (static_cast<float>(*row++) / gray_count)) << 24;
//data[y * image_pitch + x] |= ((u32)(*bitsdata++) << 24);
Expand Down

0 comments on commit d44cb54

Please sign in to comment.