+ int xadvance, left, top, height;
+ pGlyph ng;
+ int xborder = 0;
+
+ if (border)
+ {
+ /* TODO: scale border radius with current_font scaling */
+ if (current_font->getGlyphImage(glyphIndex, &ng.image, &ng.borderimage, 64 * border))
+ return 1;
+ if (ng.image && ng.image->format != FT_GLYPH_FORMAT_BITMAP)
+ {
+ FT_Glyph_To_Bitmap(&ng.image, FT_RENDER_MODE_NORMAL, NULL, 1);
+ if (ng.image->format != FT_GLYPH_FORMAT_BITMAP) return 1;
+ }
+ if (ng.borderimage && ng.borderimage->format != FT_GLYPH_FORMAT_BITMAP)
+ {
+ FT_Glyph_To_Bitmap(&ng.borderimage, FT_RENDER_MODE_NORMAL, NULL, 1);
+ if (ng.borderimage->format != FT_GLYPH_FORMAT_BITMAP) return 1;
+ }
+ FT_BitmapGlyph glyph = NULL;
+ if (ng.borderimage)
+ {
+ xadvance = ng.borderimage->advance.x;
+ if (!previous)
+ {
+ /* Move the first character, to make sure the border does not get cut off by the boundingbox (xborder is in pixel units, so just divide the width difference by two) */
+ xborder = (((FT_BitmapGlyph)ng.borderimage)->bitmap.width - ((FT_BitmapGlyph)ng.image)->bitmap.width) / 2;
+ }
+ glyph = (FT_BitmapGlyph)ng.borderimage;
+ }
+ else if (ng.image)
+ {
+ xadvance = ng.image->advance.x;
+ glyph = (FT_BitmapGlyph)ng.image;
+ }
+ else
+ {
+ return 1;
+ }
+ xadvance >>= 16;
+
+ left = glyph->left;
+ top = glyph->top;
+ height = glyph->bitmap.rows;
+ }
+ else
+ {
+ FTC_SBit glyph;
+ if (current_font->getGlyphBitmap(glyphIndex, &glyph))
+ return 1;
+
+ xadvance = glyph->xadvance;
+ left = glyph->left;
+ top = glyph->top;
+ height = glyph->height;
+ }