freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fw: Example Code


From: Kevin Dance
Subject: Fw: Example Code
Date: Thu, 3 Aug 2000 00:04:03 +0100

Sorry - please ignore the previous email since I have solved my problem
 
-----Original Message-----
From: Kevin Dance <address@hidden>
To: address@hidden <address@hidden>
Date: 02 August 2000 23:33
Subject: Example Code

Has anyone got any example code on how to use the Freetype 2 library. I know that their are demos but this is too complicated for what I want to do.
 
All I want to do is to initialise the library, load a font and then create a bitmap for a particular character.
 
Take a look at the following...
 
{
 FT_Library Library;

 if (FT_Init_FreeType(&Library) == 0)
 {
  FT_Face Face;
 
  if (FT_New_Face(Library,"arial.ttf",0,&Face) == 0)
  {
   if (FT_Set_Char_Size(Face,0,50*64,72,72) == 0)
   {
    FT_GlyphSlot Slot = Face->glyph;
    FT_UInt  GlyphIndex;
    int  nX = 100;
    int  nY = 100;
    unsigned char String[] = "TEST";
    int  nIndex = 0;
   
    while (String[nIndex])
    {
     if (FT_Load_Char(Face,String[nIndex],FT_LOAD_RENDER) == 0)
     {
      Display( Slot->bitmap,
        nX + Slot->bitmap_left ,
        nY + Slot->bitmap_top );
 
      nX += Slot->advance.x;
      nY += Slot->advance.y;
     }
     nIndex++;
    }
   }
  }
 }
 
This should generate a bitmap of a character but the bitmap size is zero wide and has zero rows.
 
Could anyone tell me what I am doing wrong? Do I need to allocate the memory for the bitmap myself or is this done by the freetype library.
 
Thanks in advance
 
Kevin Dance

reply via email to

[Prev in Thread] Current Thread [Next in Thread]