+
+ /* load the glyph image (in its native format) */
+ /* for now, we take a monochrome glyph bitmap */
+ error = FT_Load_Glyph (face, glyph->index, FT_LOAD_DEFAULT);
+ if (error) {
+ fprintf (stderr, "couldn't load glyph: %c\n", letter);
+ continue;
+ }
+ error = FT_Get_Glyph (slot, &glyph->image);
+ if (error) {
+ fprintf (stderr, "couldn't get glyph from slot: %c\n", letter);
+ continue;
+ }
+ /* if we are in tabbing mode, we replace the tab with a space and shift the position
+ of the space so that its left edge is where the tab was supposed to land us */
+ if (gottab){
+ /* we are in gridfitting mode so the calculations happen in 1/64 pixles */
+ ft_pen.x = tabwidth*64.0 * (float)(1 + (long)(ft_pen.x / (tabwidth * 64.0))) - slot->advance.x;
+ }
+ /* store current pen position */
+ glyph->pos.x = ft_pen.x;
+ glyph->pos.y = ft_pen.y;
+
+
+ ft_pen.x += slot->advance.x;
+ ft_pen.y += slot->advance.y;
+
+ /* rotate glyph */
+ vec = glyph->pos;
+ FT_Vector_Transform (&vec, &string->transform);
+ error = FT_Glyph_Transform (glyph->image, &string->transform, &vec);
+ if (error) {
+ fprintf (stderr, "couldn't transform glyph\n");
+ continue;
+ }
+
+ /* convert to a bitmap - destroy native image */
+ error = FT_Glyph_To_Bitmap (&glyph->image, FT_RENDER_MODE_NORMAL, 0, 1);
+ if (error) {
+ fprintf (stderr, "couldn't convert glyph to bitmap\n");
+ continue;
+ }
+
+ /* increment number of glyphs */
+ previous = glyph->index;
+ string->num_glyphs++;
+ }
+/* printf ("number of glyphs = %d\n", string->num_glyphs);*/
+ compute_string_bbox( string );
+ /* the last character was a tab */
+ if (gottab) {
+ string->width = ft_pen.x;
+ } else {
+ string->width = string->bbox.xMax - string->bbox.xMin;
+ }
+ string->height = string->bbox.yMax - string->bbox.yMin;
+ return string;