FTBitmapGlyph.cpp
Go to the documentation of this file.00001 #include <string>
00002
00003 #include "FTBitmapGlyph.h"
00004
00005 FTBitmapGlyph::FTBitmapGlyph( FT_GlyphSlot glyph)
00006 : FTGlyph( glyph),
00007 destWidth(0),
00008 destHeight(0),
00009 data(0)
00010 {
00011 err = FT_Render_Glyph( glyph, FT_RENDER_MODE_MONO);
00012 if( err || ft_glyph_format_bitmap != glyph->format)
00013 {
00014 return;
00015 }
00016
00017 FT_Bitmap bitmap = glyph->bitmap;
00018
00019 unsigned int srcWidth = bitmap.width;
00020 unsigned int srcHeight = bitmap.rows;
00021 unsigned int srcPitch = bitmap.pitch;
00022
00023 destWidth = srcWidth;
00024 destHeight = srcHeight;
00025 destPitch = srcPitch;
00026
00027 if( destWidth && destHeight)
00028 {
00029 data = new unsigned char[destPitch * destHeight];
00030 unsigned char* dest = data + (( destHeight - 1) * destPitch);
00031
00032 unsigned char* src = bitmap.buffer;
00033
00034 for( unsigned int y = 0; y < srcHeight; ++y)
00035 {
00036 memcpy( dest, src, srcPitch);
00037 dest -= destPitch;
00038 src += srcPitch;
00039 }
00040 }
00041
00042 pos.x = glyph->bitmap_left;
00043 pos.y = static_cast<int>(srcHeight) - glyph->bitmap_top;
00044 }
00045
00046
00047 FTBitmapGlyph::~FTBitmapGlyph()
00048 {
00049 delete [] data;
00050 }
00051
00052
00053 float FTBitmapGlyph::Render( const FTPoint& pen)
00054 {
00055 if( data)
00056 {
00057 glBitmap( 0, 0, 0.0, 0.0, pen.x + pos.x, pen.y - pos.y, (const GLubyte*)0 );
00058
00059 glPixelStorei( GL_UNPACK_ROW_LENGTH, destPitch * 8);
00060 glBitmap( destWidth, destHeight, 0.0f, 0.0, 0.0, 0.0, (const GLubyte*)data);
00061
00062 glBitmap( 0, 0, 0.0, 0.0, -pen.x - pos.x, -pen.y + pos.y, (const GLubyte*)0 );
00063 }
00064
00065 return advance;
00066 }
Generated on Mon May 17 16:04:56 2004 for FTGL by
1.3.7