#define FT_CONFIG_STANDARD_LIBRARY_H #include #include "ftmisc.h" #include "ftimage.h" extern const FT_Raster_Funcs ft_standard_raster; void DrawBitmap(const FT_Bitmap *bitmap) { int y, x; unsigned char *ptr, shift, mod; for (y=0;yrows;y++){ ptr = bitmap->buffer + (y * bitmap->pitch) - 1; for(x=0;xwidth;x++){ if (x % 8 == 0) ptr++; mod = x % 8; shift = pow((double)2, (double)7 - mod); if(*ptr & shift) printf("X"); else printf("_"); } printf("\n"); } } /* The points before the outline is translated 'upwards' and 'right' to get all co-ords positive */ int OrigX[21] = { 6121, 6199, 6288, 6276, 6273, 6450, 6450, 6450, 6421, 6286,-445,-513,-561,-600,-698,-783, -783, -783, -735, -609,0}; int OrigY[21] = {-3896,-3920,-3937,-3937,-3937,-3856,-3775,-3702,-3646,-3597,-954,-922,-913,-913,-913,-994,-1075,-1156,-1196,-1253,0}; int PointsX[21] = { 6953, 7031, 7060, 7108, 7205, 7282, 7282, 7282, 7253, 7118, 387, 319, 271, 232, 136, 49, 49, 49, 97, 223,0}; int PointsY[21] = { 72, 48, 31, 31, 31, 112, 193, 266, 322, 371,3014,3046,3055,3055,3055,2974, 2893, 2812, 2772, 2715,0}; int MasterTags[21] = {1,2,2,1,2,2,1,2,2,1,1,2,2,1,2,2,1,2,2,1,0}; PopulatePointsRegular(FT_Vector *Points, char *Tags, int scale) { int i; /* Populate the regular glyph Points array */ if (scale == 72) { for(i=0;i<22;i++){ Points[i].x = PointsX[i]; Points[i].y = PointsY[i]; } } if (scale == 300) { for(i=0;i<22;i++){ Points[i].x = PointsX[i] * (300.0/72.0); Points[i].y = PointsY[i] * (300.0/72.0); } } for(i=0;i<22;i++) Tags[i] = MasterTags[i]; } int main(int argc, char *argv[], char *envp[]) { FT_Error Err; FT_Raster raster; FT_Bitmap bitmap; FT_Raster_Params params; unsigned char buffer[16*1024]; unsigned char pool[16*1024]; FT_Outline RegularOutline; FT_Vector RegularPoints[22]; char RegularTags[22]; short RegularContours[1]; FT_Outline RegularOutline300; FT_Vector RegularPoints300[22]; char RegularTags300[22]; short RegularContours300[1]; /* Initialise a few structures for safety */ memset(&RegularOutline, 0x00, sizeof(FT_Outline)); memset(&RegularOutline300, 0x00, sizeof(FT_Outline)); memset(¶ms, 0x00, sizeof(FT_Raster_Params)); /* Initialise the raster structure */ Err = ft_standard_raster.raster_new(NULL, &raster); /* Populate the regular glyph bitmap structure */ /* This is common to both the regular and inverted glyphs */ bitmap.buffer = (unsigned char *)&buffer; bitmap.palette = 0; bitmap.palette_mode = 0; bitmap.pitch = 16; bitmap.pixel_mode = 1; bitmap.rows = 48; bitmap.width = 114; /* Render the regular glyph */ PopulatePointsRegular((FT_Vector *)&RegularPoints, (char *)&RegularTags, 72); RegularContours[0] = 19; /* Populate the regular glyph Outline structure */ RegularOutline.n_contours = 1; RegularOutline.n_points = 20; RegularOutline.flags = 0x104; RegularOutline.tags = (char *)&RegularTags; RegularOutline.contours = (short *)&RegularContours; RegularOutline.points = (FT_Vector *)&RegularPoints; /* And finally populate the regular gyph params structure */ params.source = &RegularOutline; params.target = &bitmap; params.user = (void *)0x0; params.clip_box.xMin = 0; params.clip_box.xMax = 4095; params.clip_box.yMin = 4095; params.clip_box.yMax = 0; /* Clear the bitmap buffer before starting */ memset(&buffer, 0x00, 16*1024); /* At last, render the regular glyph */ ft_standard_raster.raster_reset(raster, pool, 16*1024); Err = ft_standard_raster.raster_render(raster, ¶ms); if (Err != 0) { printf("Encountered error %d rendering first glyph\n", Err); exit(1); } printf("\nFirst glyph bitmap (72 dpi)\n"); DrawBitmap(params.target); /* Now repeat the glyph at 300 dpi */ /* Populate the glyph bitmap structure for 300 dpi */ bitmap.buffer = (unsigned char *)&buffer; bitmap.palette = 0; bitmap.palette_mode = 0; bitmap.pitch = 60; bitmap.pixel_mode = 1; bitmap.rows = 198; bitmap.width = 473; /* Populate the regular glyph Points array */ PopulatePointsRegular((FT_Vector *)&RegularPoints300, (char *)&RegularTags300, 300); RegularContours300[0] = 19; /* Populate the inverted glyph Outline structure */ RegularOutline300.n_contours = 1; RegularOutline300.n_points = 20; RegularOutline300.flags = 0x104; RegularOutline300.tags = (char *)&RegularTags300; RegularOutline300.contours = (short *)&RegularContours300; RegularOutline300.points = (FT_Vector *)&RegularPoints300; /* And finally populate the inverted gyph params structure */ memset(¶ms, sizeof(FT_Raster_Params), 0x00); params.source = &RegularOutline300; params.target = &bitmap; params.user = (void *)0x0; params.clip_box.xMin = 0; params.clip_box.xMax = 17073; params.clip_box.yMin = 17073; params.clip_box.yMax = 0; /* Clear the bitmap buffer before starting */ memset(&buffer, 0x00, 16*1024); /* At last, render the inverted glyph */ ft_standard_raster.raster_reset(raster, pool, 16*1024); Err = ft_standard_raster.raster_render(raster, ¶ms); if (Err != 0) { printf("Encountered error %d rendering second glyph\n", Err); exit(1); } printf("\nSecond glyph bitmap (300 dpi)\n"); DrawBitmap(params.target); }