Added type gFont to replace V2.x font_t

release/v2.9
inmarket 2018-07-08 13:05:27 +10:00
parent a24fab0d72
commit cbf1d4dfa0
33 changed files with 76 additions and 74 deletions

View File

@ -23,6 +23,7 @@ CHANGE: Added type gPoint to replace V2.x point and point_t
CHANGE: Added type gCoord to replace V2.x coord_t CHANGE: Added type gCoord to replace V2.x coord_t
CHANGE: Added type gPixel to replace V2.x pixel_t CHANGE: Added type gPixel to replace V2.x pixel_t
CHANGE: Added type gColor to replace V2.x color_t CHANGE: Added type gColor to replace V2.x color_t
CHANGE: Added type gFont to replace V2.x font_t
CHANGE: Added type gPowermode to replace V2.x powermode_t, and values gPowerXXX replace powerXXX CHANGE: Added type gPowermode to replace V2.x powermode_t, and values gPowerXXX replace powerXXX
CHANGE: Added type gJustify to replace V2.x justify_t, and values gJustifyXXX replace justifyXXX CHANGE: Added type gJustify to replace V2.x justify_t, and values gJustifyXXX replace justifyXXX
CHANGE: Added type gFontmetric to replace V2.x fontmetric_t, and values gFontXXX replace fontXXX CHANGE: Added type gFontmetric to replace V2.x fontmetric_t, and values gFontXXX replace fontXXX

View File

@ -75,7 +75,7 @@ const char *tsCalibRead(uint16_t instance) {
int main(void) { int main(void) {
font_t font = gdispOpenFont("UI2"); gFont font = gdispOpenFont("UI2");
/* initialize the hardware and the OS */ /* initialize the hardware and the OS */
gfxInit(); gfxInit();

View File

@ -47,7 +47,7 @@ static GHandle gstatusConsole; // GConsole Handle to the Status Bar
static GEventMouse curPtr; // Holder for current pointer location static GEventMouse curPtr; // Holder for current pointer location
static font_t font; static gFont font;
static gCoord swidth, sheight; static gCoord swidth, sheight;
// The toolbar buttons - Self-Explanatory // The toolbar buttons - Self-Explanatory

View File

@ -70,7 +70,7 @@ static const GWidgetStyle YellowWidgetStyle = {
}; };
/* The variables we need */ /* The variables we need */
static font_t font; static gFont font;
static GListener gl; static GListener gl;
static GHandle ghConsole; static GHandle ghConsole;
static GTimer FlashTimer; static GTimer FlashTimer;

View File

@ -44,7 +44,7 @@
void drawScreen(void) { void drawScreen(void) {
char *msg = "uGFX"; char *msg = "uGFX";
font_t font1, font2; gFont font1, font2;
font1 = gdispOpenFont("DejaVuSans24*"); font1 = gdispOpenFont("DejaVuSans24*");
font2 = gdispOpenFont("DejaVuSans12*"); font2 = gdispOpenFont("DejaVuSans12*");

View File

@ -90,7 +90,7 @@ void benchmark(void) {
char pps_str[25]; char pps_str[25];
gCoord height, width, rx, ry, rcx, rcy; gCoord height, width, rx, ry, rcx, rcy;
gColor random_color; gColor random_color;
font_t font; gFont font;
gdispSetOrientation(GDISP_ROTATE_90); gdispSetOrientation(GDISP_ROTATE_90);

View File

@ -30,7 +30,7 @@ gdispImage jg10Image[JG10_MAX_COUNT];
const char *jg10GraphAnim[] = {"a1.bmp","a2.bmp","a3.bmp","a4.bmp","background.bmp"}; // 5 elements (0-4) const char *jg10GraphAnim[] = {"a1.bmp","a2.bmp","a3.bmp","a4.bmp","background.bmp"}; // 5 elements (0-4)
gdispImage jg10ImageAnim[JG10_ANIM_IMAGES]; gdispImage jg10ImageAnim[JG10_ANIM_IMAGES];
uint8_t jg10MaxVal=4; // Max value in field... uint8_t jg10MaxVal=4; // Max value in field...
font_t font; gFont font;
#if JG10_SHOW_SPLASH #if JG10_SHOW_SPLASH
GTimer jg10SplashBlink; GTimer jg10SplashBlink;
gBool jg10SplashTxtVisible = gFalse; gBool jg10SplashTxtVisible = gFalse;

View File

@ -5,7 +5,7 @@ int main(void)
{ {
GEventMouse ev; GEventMouse ev;
#if !JG10_SHOW_SPLASH #if !JG10_SHOW_SPLASH
font_t font; gFont font;
#endif #endif
gfxInit(); gfxInit();

View File

@ -40,7 +40,7 @@ int main(void)
{ {
GEventMouse ev; GEventMouse ev;
#if !MINES_SHOW_SPLASH #if !MINES_SHOW_SPLASH
font_t font; gFont font;
#endif #endif
gfxInit(); gfxInit();

View File

@ -93,7 +93,7 @@ static void printStats(void)
{ {
char pps_str[12]; char pps_str[12];
font_t font = gdispOpenFont("fixed_5x8"); gFont font = gdispOpenFont("fixed_5x8");
uitoa(MINES_MINE_COUNT, pps_str, sizeof(pps_str)); uitoa(MINES_MINE_COUNT, pps_str, sizeof(pps_str));
gdispFillString(minesStatusIconWidth+8, gdispGetHeight()-11, " ", font, GFX_BLACK, GFX_BLACK); gdispFillString(minesStatusIconWidth+8, gdispGetHeight()-11, " ", font, GFX_BLACK, GFX_BLACK);
gdispDrawString(minesStatusIconWidth+8, gdispGetHeight()-11, pps_str, font, GFX_WHITE); gdispDrawString(minesStatusIconWidth+8, gdispGetHeight()-11, pps_str, font, GFX_WHITE);
@ -110,7 +110,7 @@ static void minesUpdateTime(void)
if (minesTime > 9999) if (minesTime > 9999)
minesTime = 9999; minesTime = 9999;
font_t font = gdispOpenFont("digital_7__mono_20"); gFont font = gdispOpenFont("digital_7__mono_20");
uitoa(minesTime, pps_str, sizeof(pps_str)); uitoa(minesTime, pps_str, sizeof(pps_str));
gdispFillArea((MINES_FIELD_WIDTH*MINES_CELL_WIDTH)-gdispGetStringWidth("9999", font), gdispGetHeight()-15, gdispGetWidth(), 15, GFX_BLACK); gdispFillArea((MINES_FIELD_WIDTH*MINES_CELL_WIDTH)-gdispGetStringWidth("9999", font), gdispGetHeight()-15, gdispGetWidth(), 15, GFX_BLACK);
gdispDrawString((MINES_FIELD_WIDTH*MINES_CELL_WIDTH)-gdispGetStringWidth(pps_str, font), gdispGetHeight()-15, pps_str, font, GFX_LIME); gdispDrawString((MINES_FIELD_WIDTH*MINES_CELL_WIDTH)-gdispGetStringWidth(pps_str, font), gdispGetHeight()-15, pps_str, font, GFX_LIME);
@ -251,7 +251,7 @@ static DECLARE_THREAD_FUNCTION(thdMines, msg)
static void printGameOver(void) static void printGameOver(void)
{ {
if (minesGameOver) { if (minesGameOver) {
font_t font = gdispOpenFont("DejaVuSans16"); gFont font = gdispOpenFont("DejaVuSans16");
if (minesGameWinner) { if (minesGameWinner) {
gdispDrawString((gdispGetWidth()-gdispGetStringWidth("You LIVE!", font))/2, gdispGetHeight()-15, "You LIVE!", font, GFX_WHITE); gdispDrawString((gdispGetWidth()-gdispGetStringWidth("You LIVE!", font))/2, gdispGetHeight()-15, "You LIVE!", font, GFX_WHITE);
} else { } else {
@ -271,7 +271,7 @@ static void initField(void)
minesGameOver = gFalse; minesGameOver = gFalse;
printGameOver(); printGameOver();
font_t font = gdispOpenFont("fixed_5x8"); gFont font = gdispOpenFont("fixed_5x8");
gdispImageOpenFile(&minesImage, "plainmine.bmp"); gdispImageOpenFile(&minesImage, "plainmine.bmp");
// Saving status icons width/height for later use // Saving status icons width/height for later use
minesStatusIconWidth = minesImage.width; minesStatusIconWidth = minesImage.width;
@ -391,7 +391,7 @@ void minesStart(void)
if (!minesGameWinner) { if (!minesGameWinner) {
// Print generated mines for player to see // Print generated mines for player to see
font_t font = gdispOpenFont("fixed_10x20"); gFont font = gdispOpenFont("fixed_10x20");
for (x = 0; x < MINES_FIELD_WIDTH; x++) { for (x = 0; x < MINES_FIELD_WIDTH; x++) {
for (y = 0; y < MINES_FIELD_HEIGHT; y++) { for (y = 0; y < MINES_FIELD_HEIGHT; y++) {
if (minesField[x][y].num == 9 && !minesField[x][y].flag) { if (minesField[x][y].num == 9 && !minesField[x][y].flag) {

View File

@ -89,8 +89,8 @@ unsigned long tetrisScore = 0;
gBool tetrisKeysPressed[5] = {gFalse, gFalse, gFalse, gFalse, gFalse}; // left/down/right/up/pause gBool tetrisKeysPressed[5] = {gFalse, gFalse, gFalse, gFalse, gFalse}; // left/down/right/up/pause
gBool tetrisPaused = gFalse; gBool tetrisPaused = gFalse;
gBool tetrisGameOver = gFalse; gBool tetrisGameOver = gFalse;
font_t font16; gFont font16;
font_t font12; gFont font12;
GEventMouse ev; GEventMouse ev;

View File

@ -137,7 +137,7 @@ int main(void) {
gCoord swidth, sheight; gCoord swidth, sheight;
#if defined(MY_DIAL_DEVICE) || defined(MY_TEMP_DEVICE) #if defined(MY_DIAL_DEVICE) || defined(MY_TEMP_DEVICE)
GHandle ghText; GHandle ghText;
font_t font; gFont font;
#endif #endif
gfxInit(); gfxInit();

View File

@ -43,7 +43,7 @@
* Application entry point. * Application entry point.
*/ */
int main(void) { int main(void) {
font_t font; gFont font;
GFILE *f; GFILE *f;
char *errmsg; char *errmsg;
uint32_t toplay; uint32_t toplay;

View File

@ -45,7 +45,7 @@ static char whdr[32];
* Application entry point. * Application entry point.
*/ */
int main(void) { int main(void) {
font_t font; gFont font;
GFILE *f; GFILE *f;
char *errmsg; char *errmsg;
uint32_t toplay; uint32_t toplay;

View File

@ -31,7 +31,7 @@
int main(void) { int main(void) {
gCoord width, y; gCoord width, y;
font_t font1, font2; gFont font1, font2;
gCoord fheight1, fheight2; gCoord fheight1, fheight2;
const char *line1, *line2; const char *line1, *line2;
char buf[8]; char buf[8];

View File

@ -30,7 +30,7 @@
#include "gfx.h" #include "gfx.h"
int main(void) { int main(void) {
font_t font1; gFont font1;
// Initialize uGFX and the underlying system // Initialize uGFX and the underlying system
gfxInit(); gfxInit();

View File

@ -47,7 +47,7 @@
int main(void) { int main(void) {
gCoord width, height; gCoord width, height;
gCoord display, i, j, cnt; gCoord display, i, j, cnt;
font_t f; gFont f;
GDisplay *g; GDisplay *g;
char buf[16]; char buf[16];
@ -91,7 +91,7 @@
int main(void) { int main(void) {
gCoord width, height; gCoord width, height;
gCoord display, i, j, cnt; gCoord display, i, j, cnt;
font_t f; gFont f;
char buf[16]; char buf[16];
/* Initialize and clear the display */ /* Initialize and clear the display */

View File

@ -33,7 +33,7 @@
#define COLOR_BACKGROUND GFX_SILVER #define COLOR_BACKGROUND GFX_SILVER
#define COLOR_TEXT GFX_BLACK #define COLOR_TEXT GFX_BLACK
font_t font; gFont font;
// English Translation // English Translation
static const char* EnglishStrings[] = { static const char* EnglishStrings[] = {

View File

@ -34,7 +34,7 @@ GHandle GW1, GW2, GW3;
int main(void) { int main(void) {
uint8_t i; uint8_t i;
font_t font1, font2; gFont font1, font2;
/* initialize and clear the display */ /* initialize and clear the display */
gfxInit(); gfxInit();

View File

@ -28,7 +28,7 @@
#include "gfx.h" #include "gfx.h"
/* The variables we need */ /* The variables we need */
static font_t font; static gFont font;
static GListener gl; static GListener gl;
static GHandle ghConsole; static GHandle ghConsole;
static GHandle ghKeyboard; static GHandle ghKeyboard;

View File

@ -77,7 +77,7 @@ static const GWidgetStyle YellowWidgetStyle = {
}; };
/* The variables we need */ /* The variables we need */
static font_t font; static gFont font;
static GListener gl; static GListener gl;
static GHandle ghConsole; static GHandle ghConsole;
static GTimer FlashTimer; static GTimer FlashTimer;

View File

@ -33,7 +33,7 @@
#include "src/ginput/ginput_driver_mouse.h" #include "src/ginput/ginput_driver_mouse.h"
static GConsoleObject gc; static GConsoleObject gc;
static font_t font; static gFont font;
static gCoord bHeight; static gCoord bHeight;
static GHandle ghc; static GHandle ghc;
static gCoord swidth, sheight; static gCoord swidth, sheight;

View File

@ -37,7 +37,7 @@
static GConsoleObject gc; static GConsoleObject gc;
static GListener gl; static GListener gl;
static font_t font; static gFont font;
static gCoord bWidth, bWidth2, bHeight; static gCoord bWidth, bWidth2, bHeight;
static GHandle ghc; static GHandle ghc;
static gCoord swidth, sheight; static gCoord swidth, sheight;

View File

@ -37,7 +37,7 @@
static GConsoleObject gc; static GConsoleObject gc;
static GListener gl; static GListener gl;
static font_t font; static gFont font;
static gCoord bHeight; static gCoord bHeight;
static GHandle ghc; static GHandle ghc;
static gCoord swidth, sheight; static gCoord swidth, sheight;

View File

@ -111,7 +111,7 @@
static GListener gl; static GListener gl;
#endif #endif
static SOCKET_TYPE netfd = (SOCKET_TYPE)-1; static SOCKET_TYPE netfd = (SOCKET_TYPE)-1;
static font_t font; static gFont font;
#define STRINGOF_RAW(s) #s #define STRINGOF_RAW(s) #s
#define STRINGOF(s) STRINGOF_RAW(s) #define STRINGOF(s) STRINGOF_RAW(s)

View File

@ -3363,7 +3363,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
} }
#endif #endif
void gdispGDrawChar(GDisplay *g, gCoord x, gCoord y, uint16_t c, font_t font, gColor color) { void gdispGDrawChar(GDisplay *g, gCoord x, gCoord y, uint16_t c, gFont font, gColor color) {
if (!font) if (!font)
return; return;
MUTEX_ENTER(g); MUTEX_ENTER(g);
@ -3378,7 +3378,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
MUTEX_EXIT(g); MUTEX_EXIT(g);
} }
void gdispGFillChar(GDisplay *g, gCoord x, gCoord y, uint16_t c, font_t font, gColor color, gColor bgcolor) { void gdispGFillChar(GDisplay *g, gCoord x, gCoord y, uint16_t c, gFont font, gColor color, gColor bgcolor) {
if (!font) if (!font)
return; return;
MUTEX_ENTER(g); MUTEX_ENTER(g);
@ -3400,7 +3400,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
MUTEX_EXIT(g); MUTEX_EXIT(g);
} }
void gdispGDrawString(GDisplay *g, gCoord x, gCoord y, const char *str, font_t font, gColor color) { void gdispGDrawString(GDisplay *g, gCoord x, gCoord y, const char *str, gFont font, gColor color) {
if (!font) if (!font)
return; return;
MUTEX_ENTER(g); MUTEX_ENTER(g);
@ -3416,7 +3416,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
MUTEX_EXIT(g); MUTEX_EXIT(g);
} }
void gdispGFillString(GDisplay *g, gCoord x, gCoord y, const char *str, font_t font, gColor color, gColor bgcolor) { void gdispGFillString(GDisplay *g, gCoord x, gCoord y, const char *str, gFont font, gColor color, gColor bgcolor) {
if (!font) if (!font)
return; return;
MUTEX_ENTER(g); MUTEX_ENTER(g);
@ -3439,7 +3439,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
MUTEX_EXIT(g); MUTEX_EXIT(g);
} }
void gdispGDrawStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, font_t font, gColor color, gJustify justify) { void gdispGDrawStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, gFont font, gColor color, gJustify justify) {
gCoord totalHeight; gCoord totalHeight;
if (!font) if (!font)
@ -3517,7 +3517,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
MUTEX_EXIT(g); MUTEX_EXIT(g);
} }
void gdispGFillStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, font_t font, gColor color, gColor bgcolor, gJustify justify) { void gdispGFillStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, gFont font, gColor color, gColor bgcolor, gJustify justify) {
gCoord totalHeight; gCoord totalHeight;
if (!font) if (!font)
@ -3608,7 +3608,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
MUTEX_EXIT(g); MUTEX_EXIT(g);
} }
gCoord gdispGetFontMetric(font_t font, gFontmetric metric) { gCoord gdispGetFontMetric(gFont font, gFontmetric metric) {
if (!font) if (!font)
return 0; return 0;
/* No mutex required as we only read static data */ /* No mutex required as we only read static data */
@ -3625,14 +3625,14 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
return 0; return 0;
} }
gCoord gdispGetCharWidth(char c, font_t font) { gCoord gdispGetCharWidth(char c, gFont font) {
if (!font) if (!font)
return 0; return 0;
/* No mutex required as we only read static data */ /* No mutex required as we only read static data */
return mf_character_width(font, c); return mf_character_width(font, c);
} }
gCoord gdispGetStringWidthCount(const char* str, font_t font, uint16_t count) { gCoord gdispGetStringWidthCount(const char* str, gFont font, uint16_t count) {
if (!str || !font) if (!str || !font)
return 0; return 0;
@ -3644,7 +3644,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
#endif #endif
} }
gCoord gdispGetStringWidth(const char* str, font_t font) { gCoord gdispGetStringWidth(const char* str, gFont font) {
return gdispGetStringWidthCount(str, font, 0); return gdispGetStringWidthCount(str, font, 0);
} }
#endif #endif

View File

@ -90,7 +90,7 @@ typedef enum gFontmetric {
/** /**
* @brief The type of a font. * @brief The type of a font.
*/ */
typedef const struct mf_font_s* font_t; typedef const struct mf_font_s* gFont;
/** /**
* @enum orientation * @enum orientation
@ -917,7 +917,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* *
* @api * @api
*/ */
void gdispGDrawChar(GDisplay *g, gCoord x, gCoord y, uint16_t c, font_t font, gColor color); void gdispGDrawChar(GDisplay *g, gCoord x, gCoord y, uint16_t c, gFont font, gColor color);
#define gdispDrawChar(x,y,s,f,c) gdispGDrawChar(GDISP,x,y,s,f,c) #define gdispDrawChar(x,y,s,f,c) gdispGDrawChar(GDISP,x,y,s,f,c)
/** /**
@ -933,7 +933,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* *
* @api * @api
*/ */
void gdispGFillChar(GDisplay *g, gCoord x, gCoord y, uint16_t c, font_t font, gColor color, gColor bgcolor); void gdispGFillChar(GDisplay *g, gCoord x, gCoord y, uint16_t c, gFont font, gColor color, gColor bgcolor);
#define gdispFillChar(x,y,s,f,c,b) gdispGFillChar(GDISP,x,y,s,f,c,b) #define gdispFillChar(x,y,s,f,c,b) gdispGFillChar(GDISP,x,y,s,f,c,b)
/** /**
@ -948,7 +948,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* *
* @api * @api
*/ */
void gdispGDrawString(GDisplay *g, gCoord x, gCoord y, const char *str, font_t font, gColor color); void gdispGDrawString(GDisplay *g, gCoord x, gCoord y, const char *str, gFont font, gColor color);
#define gdispDrawString(x,y,s,f,c) gdispGDrawString(GDISP,x,y,s,f,c) #define gdispDrawString(x,y,s,f,c) gdispGDrawString(GDISP,x,y,s,f,c)
/** /**
@ -964,7 +964,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* *
* @api * @api
*/ */
void gdispGFillString(GDisplay *g, gCoord x, gCoord y, const char *str, font_t font, gColor color, gColor bgcolor); void gdispGFillString(GDisplay *g, gCoord x, gCoord y, const char *str, gFont font, gColor color, gColor bgcolor);
#define gdispFillString(x,y,s,f,c,b) gdispGFillString(GDISP,x,y,s,f,c,b) #define gdispFillString(x,y,s,f,c,b) gdispGFillString(GDISP,x,y,s,f,c,b)
/** /**
@ -981,7 +981,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* *
* @api * @api
*/ */
void gdispGDrawStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, font_t font, gColor color, gJustify justify); void gdispGDrawStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, gFont font, gColor color, gJustify justify);
#define gdispDrawStringBox(x,y,cx,cy,s,f,c,j) gdispGDrawStringBox(GDISP,x,y,cx,cy,s,f,c,j) #define gdispDrawStringBox(x,y,cx,cy,s,f,c,j) gdispGDrawStringBox(GDISP,x,y,cx,cy,s,f,c,j)
/** /**
@ -1000,7 +1000,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* *
* @api * @api
*/ */
void gdispGFillStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, font_t font, gColor color, gColor bgColor, gJustify justify); void gdispGFillStringBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, const char* str, gFont font, gColor color, gColor bgColor, gJustify justify);
#define gdispFillStringBox(x,y,cx,cy,s,f,c,b,j) gdispGFillStringBox(GDISP,x,y,cx,cy,s,f,c,b,j) #define gdispFillStringBox(x,y,cx,cy,s,f,c,b,j) gdispGFillStringBox(GDISP,x,y,cx,cy,s,f,c,b,j)
/** /**
@ -1013,7 +1013,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* *
* @api * @api
*/ */
gCoord gdispGetFontMetric(font_t font, gFontmetric metric); gCoord gdispGetFontMetric(gFont font, gFontmetric metric);
/** /**
* @brief Get the pixel width of a character. * @brief Get the pixel width of a character.
@ -1025,7 +1025,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* *
* @api * @api
*/ */
gCoord gdispGetCharWidth(char c, font_t font); gCoord gdispGetCharWidth(char c, gFont font);
/** /**
* @brief Get the pixel width of a string of a given character length. * @brief Get the pixel width of a string of a given character length.
@ -1040,7 +1040,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* *
* @api * @api
*/ */
gCoord gdispGetStringWidthCount(const char* str, font_t font, uint16_t count); gCoord gdispGetStringWidthCount(const char* str, gFont font, uint16_t count);
/** /**
* @brief Get the pixel width of an entire string. * @brief Get the pixel width of an entire string.
@ -1052,7 +1052,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* *
* @api * @api
*/ */
gCoord gdispGetStringWidth(const char* str, font_t font); gCoord gdispGetStringWidth(const char* str, gFont font);
/** /**
* @brief Find a font and return it. * @brief Find a font and return it.
@ -1066,7 +1066,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* *
* @api * @api
*/ */
font_t gdispOpenFont(const char *name); gFont gdispOpenFont(const char *name);
/** /**
* @brief Release a font after use. * @brief Release a font after use.
@ -1076,7 +1076,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* *
* @api * @api
*/ */
void gdispCloseFont(font_t font); void gdispCloseFont(gFont font);
/** /**
* @brief Make a scaled copy of an existing font. * @brief Make a scaled copy of an existing font.
@ -1090,7 +1090,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* @param[in] scale_x The scale factor in horizontal direction. * @param[in] scale_x The scale factor in horizontal direction.
* @param[in] scale_y The scale factor in vertical direction. * @param[in] scale_y The scale factor in vertical direction.
*/ */
font_t gdispScaleFont(font_t font, uint8_t scale_x, uint8_t scale_y); gFont gdispScaleFont(gFont font, uint8_t scale_x, uint8_t scale_y);
/** /**
* @brief Get the name of the specified font. * @brief Get the name of the specified font.
@ -1101,7 +1101,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* *
* @api * @api
*/ */
const char *gdispGetFontName(font_t font); const char *gdispGetFontName(gFont font);
/** /**
* @brief Add a font permanently to the font list. * @brief Add a font permanently to the font list.
@ -1112,7 +1112,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
* *
* @api * @api
*/ */
gBool gdispAddFont(font_t font); gBool gdispAddFont(gFont font);
#endif #endif
/* Extra Arc Functions */ /* Extra Arc Functions */
@ -1234,6 +1234,7 @@ void gdispGDrawBox(GDisplay *g, gCoord x, gCoord y, gCoord cx, gCoord cy, gColor
typedef gPixel pixel_t; typedef gPixel pixel_t;
typedef gCoord coord_t; typedef gCoord coord_t;
typedef gPoint point, point_t; typedef gPoint point, point_t;
typedef gFont font_t;
typedef gPowermode powermode_t; typedef gPowermode powermode_t;
#define powerOff gPowerOff #define powerOff gPowerOff
#define powerDeepSleep gPowerDeepSleep #define powerDeepSleep gPowerDeepSleep

View File

@ -362,7 +362,7 @@ struct GDisplay {
#if GDISP_NEED_TEXT #if GDISP_NEED_TEXT
// Text rendering parameters // Text rendering parameters
struct { struct {
font_t font; gFont font;
gColor color; gColor color;
gColor bgcolor; gColor bgcolor;
gCoord clipx0, clipy0; gCoord clipx0, clipy0;

View File

@ -42,7 +42,7 @@ static gBool matchfont(const char *pattern, const char *name) {
} }
} }
font_t gdispOpenFont(const char *name) { gFont gdispOpenFont(const char *name) {
const struct mf_font_list_s *fp; const struct mf_font_list_s *fp;
if (!fontList) if (!fontList)
@ -64,7 +64,7 @@ font_t gdispOpenFont(const char *name) {
return mf_get_font_list()->font; return mf_get_font_list()->font;
} }
void gdispCloseFont(font_t font) { void gdispCloseFont(gFont font) {
if ((font->flags & (FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED)) == (FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED)) { if ((font->flags & (FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED)) == (FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED)) {
/* Make sure that no-one can successfully use font after closing */ /* Make sure that no-one can successfully use font after closing */
((struct mf_font_s *)font)->render_character = 0; ((struct mf_font_s *)font)->render_character = 0;
@ -74,7 +74,7 @@ void gdispCloseFont(font_t font) {
} }
} }
font_t gdispScaleFont(font_t font, uint8_t scale_x, uint8_t scale_y) gFont gdispScaleFont(gFont font, uint8_t scale_x, uint8_t scale_y)
{ {
struct mf_scaledfont_s *newfont; struct mf_scaledfont_s *newfont;
@ -83,14 +83,14 @@ font_t gdispScaleFont(font_t font, uint8_t scale_x, uint8_t scale_y)
mf_scale_font(newfont, font, scale_x, scale_y); mf_scale_font(newfont, font, scale_x, scale_y);
((struct mf_font_s *)newfont)->flags |= FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED; ((struct mf_font_s *)newfont)->flags |= FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED;
return (font_t)newfont; return (gFont)newfont;
} }
const char *gdispGetFontName(font_t font) { const char *gdispGetFontName(gFont font) {
return font->short_name; return font->short_name;
} }
gBool gdispAddFont(font_t font) { gBool gdispAddFont(gFont font) {
struct mf_font_list_s *hdr; struct mf_font_list_s *hdr;
if ((font->flags & (FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED)) != (FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED)) if ((font->flags & (FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED)) != (FONT_FLAG_DYNAMIC|FONT_FLAG_UNLISTED))

View File

@ -467,7 +467,7 @@ static void MousePoll(void *param) {
gPoint points[4]; // The x, y readings obtained from the mouse for each test point gPoint points[4]; // The x, y readings obtained from the mouse for each test point
uint32_t err; uint32_t err;
#if GDISP_NEED_TEXT #if GDISP_NEED_TEXT
font_t font1, font2; gFont font1, font2;
#endif #endif
#if GDISP_NEED_TEXT #if GDISP_NEED_TEXT

View File

@ -33,7 +33,7 @@ static const gwinVMT basegwinVMT = {
static gColor defaultFgColor = GFX_WHITE; static gColor defaultFgColor = GFX_WHITE;
static gColor defaultBgColor = GFX_BLACK; static gColor defaultBgColor = GFX_BLACK;
#if GDISP_NEED_TEXT #if GDISP_NEED_TEXT
static font_t defaultFont; static gFont defaultFont;
#endif #endif
/* These init functions are defined by each module but not published */ /* These init functions are defined by each module but not published */
@ -178,11 +178,11 @@ gColor gwinGetDefaultBgColor(void) {
} }
#if GDISP_NEED_TEXT #if GDISP_NEED_TEXT
void gwinSetDefaultFont(font_t font) { void gwinSetDefaultFont(gFont font) {
defaultFont = font; defaultFont = font;
} }
font_t gwinGetDefaultFont(void) { gFont gwinGetDefaultFont(void) {
return defaultFont; return defaultFont;
} }
#endif #endif
@ -218,7 +218,7 @@ gBool gwinGetEnabled(GHandle gh) {
} }
#if GDISP_NEED_TEXT #if GDISP_NEED_TEXT
void gwinSetFont(GHandle gh, font_t font) { void gwinSetFont(GHandle gh, gFont font) {
gh->font = font; gh->font = font;
} }
#endif #endif

View File

@ -52,7 +52,7 @@ typedef struct GWindowObject {
gColor bgcolor; /**< The current background drawing color */ gColor bgcolor; /**< The current background drawing color */
uint32_t flags; /**< Window flags (the meaning is private to the GWIN class) */ uint32_t flags; /**< Window flags (the meaning is private to the GWIN class) */
#if GDISP_NEED_TEXT #if GDISP_NEED_TEXT
font_t font; /**< The current font */ gFont font; /**< The current font */
#endif #endif
#if GWIN_NEED_CONTAINERS #if GWIN_NEED_CONTAINERS
GHandle parent; /**< The parent window */ GHandle parent; /**< The parent window */
@ -174,7 +174,7 @@ gColor gwinGetDefaultBgColor(void);
* *
* @api * @api
*/ */
void gwinSetDefaultFont(font_t font); void gwinSetDefaultFont(gFont font);
/** /**
* @brief Get the current default font * @brief Get the current default font
@ -183,7 +183,7 @@ gColor gwinGetDefaultBgColor(void);
* *
* @api * @api
*/ */
font_t gwinGetDefaultFont(void); gFont gwinGetDefaultFont(void);
#endif #endif
/*------------------------------------------------- /*-------------------------------------------------
@ -595,7 +595,7 @@ void gwinRedraw(GHandle gh);
* *
* @api * @api
*/ */
void gwinSetFont(GHandle gh, font_t font); void gwinSetFont(GHandle gh, gFont font);
#endif #endif
/*------------------------------------------------- /*-------------------------------------------------

View File

@ -21,14 +21,14 @@
#define gw2obj ((GLabelObject *)gw) #define gw2obj ((GLabelObject *)gw)
// simple: single line with no wrapping // simple: single line with no wrapping
static gCoord getwidth(const char *text, font_t font, gCoord maxwidth) { static gCoord getwidth(const char *text, gFont font, gCoord maxwidth) {
(void) maxwidth; (void) maxwidth;
return gdispGetStringWidth(text, font)+2; // Allow one pixel of padding on each side return gdispGetStringWidth(text, font)+2; // Allow one pixel of padding on each side
} }
// simple: single line with no wrapping // simple: single line with no wrapping
static gCoord getheight(const char *text, font_t font, gCoord maxwidth) { static gCoord getheight(const char *text, gFont font, gCoord maxwidth) {
(void) text; (void) text;
(void) maxwidth; (void) maxwidth;