FcBool FcConfigAddConfigFile (FcConfig *config, const FcChar8 *f) { FcBool ret; FcChar8 *file = FcConfigFilename (f); if (!file) return FcFalse; ret = FcStrSetAdd (config->configFiles, file); FcStrFree (file); return ret; }
int main(int argc, char** argv) { cairo_t *cr; cairo_status_t status; cairo_surface_t *surface; //FT_Bitmap bmp = {0}; int stride = 0; int width = 640; int height = 480; bool ok = FcConfigAppFontAddFile(NULL, (FcChar8*)"fonts/ComicSansAfrica.ttf"); if (!ok) { printf("Failed to load ComicSansAfrica.ttf\n"); } FcChar8 *configName = FcConfigFilename(NULL); printf("%s", (const char*)configName); printf("\n"); FcConfig* config = FcConfigCreate(); FcConfigParseAndLoad(config, configName, true); FcConfigSetCurrent(config); /* FT buffer */ //FT_Bitmap_New(&bmp); //bmp.rows = height; //bmp.width = width; //bmp.buffer = (unsigned char*)malloc(bmp.rows * bmp.width * 4); // if (NULL == bmp.buffer) // { // printf("+ error: cannot allocate the buffer for the output bitmap.\n"); // exit(EXIT_FAILURE); // } //bmp.pitch = ((width+3) & -4) * 4; //bmp.pixel_mode = FT_PIXEL_MODE_BGRA; //printf("%d\n", bmp.pitch); //stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); //printf("%d\n", stride); //surface = cairo_image_surface_create_for_data(bmp.buffer, CAIRO_FORMAT_ARGB32, width, height, stride); surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); if (CAIRO_STATUS_SUCCESS != cairo_surface_status(surface)) { printf("+ error: couldn't create the surface.\n"); exit(EXIT_FAILURE); } cr = cairo_create(surface); if (CAIRO_STATUS_NO_MEMORY == cairo_status(cr)) { printf("+ error: out of memory, cannot create cairo_t*\n"); exit(EXIT_FAILURE); } cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 1.0); cairo_paint(cr); rendertext(cr); status = cairo_surface_write_to_png(surface, "out.png"); cairo_surface_destroy(surface); cairo_destroy(cr); return 0; }