freetype
[Top][All Lists]
Advanced

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

[Freetype] (no subject)


From: Michael Pfeiffer
Subject: [Freetype] (no subject)
Date: Thu, 07 Jun 2001 14:43:17 +0200

Hello

I am replacing the Type 1 and FreeType 1.x renderer in BePDF (a pdf viewer for 
the
Be Operating System, based on xpdf) with FreeType 2.x.
It already works find but needs some fine tuning. I just want to ensure that it
is implemented as efficient as possible and contains no memory leaks. 
The relevant portion of the source code follows below. 

Could someone please have a look at it?

Any help is appreciated, thanks,
Michael

PS: Sorry for my broken English.

Notes to the source code:
- class FontFile holds one font face.
- FT2Font uses a face from a FontFile with a given size and rotation and caches 
glyphes converted to bitmaps
  (there can be several FT2Font objects that all use one face but have 
different sizes and rotations).

FT_Matrix matrix; // transformation matirx (rotation only)
float size; // font size
FT_Face   fontFile->face; // the current face
FT_BitmapGlyph   bitmapGlyph; // the current bitmap glyph
bool fontFile->engine->aa; // anti-alias or monochrome bitmap

GBool FT2Font::getGlyphPixmap(Gushort c) {
  int i, j, k;

  // check the cache (pseudo code)
  if (inCache(c)) {
    bitmapGlyph = cached_bitmap_glyph(c);
    return gTrue;
  }
  FT_UInt   glyph_index;
  FT_Glyph  glyph;
  FT_Vector vec;
  int error;
  FT_Set_Char_Size(fontFile->face, 0, size * 64, 72, 72);
  // retrieve glyph index from character code
  glyph_index = fontFile->decode(c);
  // load glyph image into the slot (erase previous one)
  error = FT_Load_Glyph( fontFile->face, glyph_index, FT_LOAD_DEFAULT );
  if (error) return gFalse;  
  error = FT_Get_Glyph( fontFile->face->glyph, &glyph );
  if (error) return gFalse;
  // convert to an anti-aliased/monochrome bitmap
  FT_Glyph_Transform(glyph, &matrix, NULL);
  error = FT_Glyph_To_Bitmap(&glyph, fontFile->engine->aa ? 
ft_render_mode_normal : ft_render_mode_mono, NULL, 0);
  if (error) return gFalse;
  bitmapGlyph = (FT_BitmapGlyph)glyph;

  // store glyph pixmap in cache (pseudo code)
  store_in_bitmap_cache(bitmapGlyph); // frees old glyphs if cache is full with 
FT_Done_Glyph()
  return gTrue;
}





reply via email to

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