[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Freetype] Platform independent viewer (Maybe OT?)
From: |
Dexter |
Subject: |
[Freetype] Platform independent viewer (Maybe OT?) |
Date: |
Sun, 25 Aug 2002 19:17:11 +0200 |
Hello!
Excuse me if i'm Off Topic (i didnt knew where else to ask help) but i'm
having a lot of troubles :(
I have to write a program, with platform independent code, that outputs
loaded font to a bitmap.
I have written this function to work under Win32 but i have no idea on how
to make it platform independent.
It shouldnt be linked to anthing but os libs and freetype lib!
That function has also a problem... i dont know some characters are screwed
and are drawn
like a simple chaotic mess (fu*ked characterrs are for example 'D' ...)...
Please help me :)
That's the code i use
HBITMAP CFontManager::Render(const int iIndex,Enum_FontMode iMode)
{
FT_Glyph glyph;
FT_BitmapGlyph glyph_bitmap;
int pen_x = 0, pen_y = 0;
// -> Creates a generic bitmap
HDC dc = CreateCompatibleDC(NULL);
BITMAPINFO i;
ZeroMemory( &i.bmiHeader, sizeof(BITMAPINFOHEADER));
switch(iMode)
{
case MODE_256_256:
i.bmiHeader.biWidth = i.bmiHeader.biHeight = 256;
break;
case MODE_512_512:
i.bmiHeader.biWidth = i.bmiHeader.biHeight = 512;
break;
case MODE_1024_1024:
i.bmiHeader.biWidth = i.bmiHeader.biHeight = 1024;
break;
}
i.bmiHeader.biPlanes = 1;
i.bmiHeader.biBitCount = 8;
i.bmiHeader.biSizeImage = 0;
i.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
i.bmiHeader.biClrUsed = 0;
i.bmiHeader.biClrImportant = 0;
i.bmiHeader.biCompression = BI_RGB;
VOID *pvBits;
HBITMAP hbmp = CreateDIBSection(dc,&i,DIB_RGB_COLORS,&pvBits,NULL,0);
if(!hbmp)
{
m_fntError = FT_Err_Missing_Bbx_Field + 1;
return NULL;
}
unsigned int index = 0;
for(unsigned int j = 0; j < 256; j++,index++)
{
m_fntError = FT_Load_Char(m_FaceArray[iIndex], j, FT_LOAD_RENDER);
if(m_fntError)
continue;
m_fntError = FT_Get_Glyph(m_FaceArray[iIndex]->glyph, &glyph);
// convert to a bitmap (default render mode + destroy old)
if(glyph->format != ft_glyph_format_bitmap)
{
m_fntError = FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, 0, 1);
}
// access bitmap content by typecasting
glyph_bitmap = (FT_BitmapGlyph)glyph;
RenderChar(glyph_bitmap,hbm,dc,pen_x,pen_y);
if(index == 16)
{
pen_x = 10;
//pen_y += glyph->metrics.height + 10;
index = 0;
}
}
return hbmp;
}
END CODE
Thank you,
Dexter
- [Freetype] Platform independent viewer (Maybe OT?),
Dexter <=