7216fbf3ffc72cb77bf509c0bffe719a1daa0ed5 braney Sun Sep 6 16:20:34 2020 -0700 first cut at using FreeType for font support diff --git src/inc/vGfx.h src/inc/vGfx.h index 269fc8f..a5afb00 100644 --- src/inc/vGfx.h +++ src/inc/vGfx.h @@ -1,26 +1,29 @@ /* vGfx - interface to polymorphic graphic object * that currently can either be a memory buffer or * a postScript file. */ #ifndef VGFX_H #define VGFX_H #ifndef MEMGFX_H #include "memgfx.h" #endif +#define FONT_METHOD_GEM 0 +#define FONT_METHOD_FREETYPE 1 + struct vGfx /* Virtual graphic object - mostly a bunch of function * pointers. */ { struct vGfx *next; /* Next in list. */ void *data; /* Type specific data. */ boolean pixelBased; /* Real pixels, not PostScript or something. */ int width, height; /* Virtual pixel dimensions. */ void (*close)(void **pV); /* Finish writing out and free structure. */ void (*dot)(void *v, int x, int y, int colorIx); /* Draw a single pixel. Try to work at a higher level * when possible! */ @@ -93,30 +96,33 @@ boolean isDashed); /* Draw a segment of an anti-aliased curve within 3 points (quadratic Bezier) * Return max y value. Optionally draw curve as dashed line. */ void (*setHint)(void *v, char *hint, char *value); /* Set hint */ char *(*getHint)(void *v, char *hint); /* Get hint */ int (*getFontPixelHeight)(void *v, void *font); /* How high in pixels is font? */ int (*getFontStringWidth)(void *v, void *font, char *string); /* How wide is a string? */ + + void (*setFontMethod)(void *v, unsigned int method); + /* Which font drawing method shoud we use. */ }; struct vGfx *vgOpenPng(int width, int height, char *fileName, boolean useTransparency); /* Open up something that will write out a PNG file upon vgClose. * If useTransparency, then the first color in memgfx's colormap/palette is * assumed to be the image background color, and pixels of that color * are made transparent. */ struct vGfx *vgOpenPostScript(int width, int height, char *fileName); /* Open up something that will someday be a PostScript file. */ void vgClose(struct vGfx **pVg); /* Close down virtual graphics object, and finish writing it to file. */ #define vgCircle(v,x,y, rad, color, filled) v->circle(v->data,x,y,rad,color,filled) @@ -201,23 +207,26 @@ v->setHint(v->data,hint,value) /* Set hint */ #define vgGetHint(v,hint) \ v->getHint(v->data,hint) /* Get hint */ #define vgGetFontPixelHeight(v,font) \ v->getFontPixelHeight(v->data,font) /* How high in pixels is font? */ #define vgGetFontStringWidth(v,font,string) \ v->getFontStringWidth(v->data,font,string) /* How wide is a string? */ +define vgSetFontMethod(v,method) \ + v->setFontMethod(v->data,method) + int vgFindRgb(struct vGfx *vg, struct rgbColor *rgb); /* Find color index corresponding to rgb color. */ Color vgContrastingColor(struct vGfx *vg, int backgroundIx); /* Return black or white whichever would be more visible over * background. */ #endif /* VGFX_H */