static int cdfont(cdCtxCanvas *ctxcanvas, const char *type_face, int style, int size) { char filename[10240]; /* try the pre-defined names and pre-defined style suffix */ if (!cdGetFontFileNameDefault(type_face, style, filename)) { /* try to find the file in the native system */ if (!cdGetFontFileNameSystem(type_face, style, filename)) { /* try the type_face as file name, here assume type_face is a full path */ strcpy(filename, type_face); } } ctxcanvas->font = ftglCreateTextureFont(filename); if (!ctxcanvas->font) return 0; if (size < 0) size = cdGetFontSizePoints(ctxcanvas->canvas, size); /* FTGL: One point in pixel space maps to 1 unit in opengl space, so a glyph that is 18 points high should be 18.0 units high. */ /* CD: that means 1 point is actually being mapped to 1 pixel */ size = cdGetFontSizePixels(ctxcanvas->canvas, size); ftglSetFontFaceSize(ctxcanvas->font, size, (int)(ctxcanvas->canvas->xres*25.4)); ftglSetFontCharMap(ctxcanvas->font, ft_encoding_unicode); return 1; }
static int cdfont(cdCtxCanvas *ctxcanvas, const char *type_face, int style, int size) { long index = 0; if (cdStrEqualNoCase(type_face, "System")) switch (style&3) { case CD_PLAIN: index = 1; break; case CD_BOLD: index = 5; break; case CD_ITALIC: index = 9; break; case CD_BOLD_ITALIC: index = 13; break; } else if (cdStrEqualNoCase(type_face, "Courier")) switch (style&3) { case CD_PLAIN: index = 2; break; case CD_BOLD: index = 6; break; case CD_ITALIC: index = 10; break; case CD_BOLD_ITALIC: index = 14; break; } else if (cdStrEqualNoCase(type_face, "Times")) switch (style&3) { case CD_PLAIN: index = 3; break; case CD_BOLD: index = 7; break; case CD_ITALIC: index = 11; break; case CD_BOLD_ITALIC: index = 15; break; } else if (cdStrEqualNoCase(type_face, "Helvetica")) switch (style&3) { case CD_PLAIN: index = 4; break; case CD_BOLD: index = 8; break; case CD_ITALIC: index = 12; break; case CD_BOLD_ITALIC: index = 16; break; } if (index == 0) return 0; cgm_char_height ( ctxcanvas->cgm, cdGetFontSizePixels(ctxcanvas->canvas, size)); cgm_text_font_index( ctxcanvas->cgm, index ); return 1; }