FT_Bitmap* R_RenderGlyph(FT_GlyphSlot glyph, glyphInfo_t* glyphOut) { FT_Bitmap* bit2; int left, right, width, top, bottom, height, pitch, size; R_GetGlyphInfo(glyph, &left, &right, &width, &top, &bottom, &height, &pitch); if (glyph->format == ft_glyph_format_outline) { size = pitch * height; bit2 = (FT_Bitmap*) ri.Z_Malloc(sizeof(FT_Bitmap)); bit2->width = width; bit2->rows = height; bit2->pitch = pitch; bit2->pixel_mode = ft_pixel_mode_grays; bit2->buffer = (unsigned char*) ri.Z_Malloc(pitch * height); bit2->num_grays = 256; Com_Memset(bit2->buffer, 0, size); FT_Outline_Translate(&glyph->outline, -left, -bottom); FT_Outline_Get_Bitmap(ftLibrary, &glyph->outline, bit2); glyphOut->height = height; glyphOut->pitch = pitch; glyphOut->top = (glyph->metrics.horiBearingY >> 6) + 1; glyphOut->bottom = bottom; return bit2; } else {
/** * @brief R_RenderGlyph * @param[in] glyph * @param[out] glyphOut * @return */ FT_Bitmap *R_RenderGlyph(FT_GlyphSlot glyph, glyphInfo_t *glyphOut) { FT_Bitmap *bit2; int left, right, width, top, bottom, height, pitch, size; R_GetGlyphInfo(glyph, &left, &right, &width, &top, &bottom, &height, &pitch); if (glyph->format != FT_GLYPH_FORMAT_OUTLINE) { Ren_Print("Non-outline fonts are not supported\n"); return NULL; } size = pitch * height; bit2 = (FT_Bitmap *)ri.Z_Malloc(sizeof(FT_Bitmap)); bit2->width = width; bit2->rows = height; bit2->pitch = pitch; bit2->pixel_mode = FT_PIXEL_MODE_GRAY; bit2->buffer = (unsigned char *)ri.Z_Malloc(size); bit2->num_grays = 256; Com_Memset(bit2->buffer, 0, size); FT_Outline_Translate(&glyph->outline, -left, -bottom); FT_Outline_Get_Bitmap(ftLibrary, &glyph->outline, bit2); glyphOut->height = height; glyphOut->pitch = pitch; glyphOut->top = _TRUNC(glyph->metrics.horiBearingY) + 1; glyphOut->bottom = bottom; glyphOut->xSkip = _TRUNC(glyph->metrics.horiAdvance) + 1; return bit2; }