50214f805964207ffae51a783513167cb51f5e2e braney Tue Sep 29 17:49:32 2020 -0700 support font choice in freetype font support diff --git src/lib/memgfx.c src/lib/memgfx.c index 66abe18..d03054c 100644 --- src/lib/memgfx.c +++ src/lib/memgfx.c @@ -796,60 +796,54 @@ int mgGetFontPixelHeight(struct memGfx *mg, MgFont *font) /* How high in pixels is font? */ { return mgFontPixelHeight(font); } int mgFontLineHeight(MgFont *font) /* How many pixels to next line ideally? */ { return font_line_height(font); } int mgFontWidth(MgFont *font, char *chars, int charCount) /* How wide are a couple of letters? */ { -/* -switch (mg->fontMethod) - { - case FONT_METHOD_GEM: - */ - return 1.00 * fnstring_width(font, (unsigned char *)chars, charCount); - //case FONT_METHOD_FREETYPE: - //return ftWidth(font, (unsigned char *)chars, charCount); - // } +if (face == NULL) // have we turned on freetype + return fnstring_width(font, (unsigned char *)chars, charCount); +return ftWidth(font, (unsigned char *)chars, charCount); } int mgFontStringWidth(MgFont *font, char *string) /* How wide is a string? */ { return mgFontWidth(font, string, strlen(string)); } int mgGetFontStringWidth(struct memGfx *mg, MgFont *font, char *string) /* How wide is a string? */ { return mgFontStringWidth(font, string); } -void mgSetFontMethod(struct memGfx *mg, unsigned int method) +void mgSetFontMethod(struct memGfx *mg, unsigned int method, char *fontFile) /* Which font drawing method shoud we use. */ { mg->fontMethod = method; if (method == FONT_METHOD_FREETYPE) - ftInitialize(); + ftInitialize(fontFile); } int mgFontCharWidth(MgFont *font, char c) /* How wide is a character? */ { return mgFontWidth(font, &c, 1); } char *mgFontSizeBackwardsCompatible(char *size) /* Given "size" argument that may be in old tiny/small/medium/big/huge format, * return it in new numerical string format. Do NOT free the return string*/ { if (isdigit(size[0])) return size; else if (sameWord(size, "tiny"))