10 #if GFX_USE_GDISP && GDISP_NEED_TEXT
12 #include "mcufont/mcufont.h"
14 #define FONT_FLAG_DYNAMIC 0x80
15 #define FONT_FLAG_UNLISTED 0x40
17 static const struct mf_font_list_s *fontList;
22 static gBool matchfont(
const char *pattern,
const char *name) {
27 return pattern[1] == 0;
28 if (pattern[1] == name[0])
36 if (name[0] != pattern[0])
46 const struct mf_font_list_s *fp;
49 fontList = mf_get_font_list();
52 for(fp = fontList; fp; fp = fp->next) {
53 if (matchfont(name, fp->font->full_name))
58 for(fp = fontList; fp; fp = fp->next) {
59 if (matchfont(name, fp->font->short_name))
64 return mf_get_font_list()->font;
68 if ((font->flags & (FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED)) == (FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED)) {
70 ((
struct mf_font_s *)font)->render_character = 0;
79 struct mf_scaledfont_s *newfont;
81 if (!(newfont =
gfxAlloc(
sizeof(
struct mf_scaledfont_s))))
84 mf_scale_font(newfont, font, scale_x, scale_y);
85 ((
struct mf_font_s *)newfont)->flags |= FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED;
86 return (
gFont)newfont;
90 return font->short_name;
94 struct mf_font_list_s *hdr;
96 if ((font->flags & (FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED)) != (FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED))
99 if (!(hdr =
gfxAlloc(
sizeof(
struct mf_font_list_s))))
103 fontList = mf_get_font_list();
104 hdr->font = (
const struct mf_font_s *)font;
105 hdr->next = fontList;
106 ((
struct mf_font_s *)font)->flags &= ~FONT_FLAG_UNLISTED;
gFont gdispOpenFont(const char *name)
Find a font and return it.
void gdispCloseFont(gFont font)
Release a font after use.
gBool gdispAddFont(gFont font)
Add a font permanently to the font list.
const struct mf_font_s * gFont
The type of a font.
const char * gdispGetFontName(gFont font)
Get the name of the specified font.
gFont gdispScaleFont(gFont font, gU8 scale_x, gU8 scale_y)
Make a scaled copy of an existing font.
void * gfxAlloc(gMemSize sz)
Allocate memory.
void gfxFree(void *ptr)
Free memory.