From 9360b2725035727262df05ae720654a48d620c69 Mon Sep 17 00:00:00 2001 From: inmarket Date: Wed, 18 Jan 2017 14:27:25 +1000 Subject: [PATCH] Update font demo to show Anti-aliased drawing --- demos/modules/gdisp/fonts/gfxconf.h | 4 +++- demos/modules/gdisp/fonts/main.c | 35 ++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/demos/modules/gdisp/fonts/gfxconf.h b/demos/modules/gdisp/fonts/gfxconf.h index 64481774..1ea84e1b 100644 --- a/demos/modules/gdisp/fonts/gfxconf.h +++ b/demos/modules/gdisp/fonts/gfxconf.h @@ -50,9 +50,10 @@ #define GDISP_INCLUDE_FONT_UI1 FALSE #define GDISP_INCLUDE_FONT_UI2 TRUE #define GDISP_INCLUDE_FONT_LARGENUMBERS FALSE -#define GDISP_INCLUDE_FONT_DEJAVUSANS10 TRUE +#define GDISP_INCLUDE_FONT_DEJAVUSANS10 FALSE #define GDISP_INCLUDE_FONT_DEJAVUSANS12 FALSE #define GDISP_INCLUDE_FONT_DEJAVUSANS16 FALSE +#define GDISP_INCLUDE_FONT_DEJAVUSANS20 FALSE #define GDISP_INCLUDE_FONT_DEJAVUSANS24 FALSE #define GDISP_INCLUDE_FONT_DEJAVUSANS32 FALSE #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12 FALSE @@ -61,6 +62,7 @@ #define GDISP_INCLUDE_FONT_FIXED_5x8 FALSE #define GDISP_INCLUDE_FONT_DEJAVUSANS12_AA FALSE #define GDISP_INCLUDE_FONT_DEJAVUSANS16_AA FALSE +#define GDISP_INCLUDE_FONT_DEJAVUSANS20_AA TRUE #define GDISP_INCLUDE_FONT_DEJAVUSANS24_AA FALSE #define GDISP_INCLUDE_FONT_DEJAVUSANS32_AA FALSE #define GDISP_INCLUDE_FONT_DEJAVUSANSBOLD12_AA FALSE diff --git a/demos/modules/gdisp/fonts/main.c b/demos/modules/gdisp/fonts/main.c index 0384b737..b43e32dc 100644 --- a/demos/modules/gdisp/fonts/main.c +++ b/demos/modules/gdisp/fonts/main.c @@ -30,7 +30,7 @@ #include "gfx.h" int main(void) { - coord_t width; + coord_t width, y; font_t font1, font2; coord_t fheight1, fheight2; const char *line1, *line2; @@ -52,19 +52,32 @@ int main(void) { //font2 = gdispOpenFont("PF Ronda*"); //font2 = gdispOpenFont("Apple*"); - // Font 1 - line1 = "a b c d e f h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z"; - line2 = "0 1 2 3 4 5 6 7 8 9 ~ ! @ # $ % ^ & * _ - + = ( ) { } [ ] < > | / \\ : ; , . ? ' \" `"; + y = 0; fheight1 = gdispGetFontMetric(font1, fontHeight)+2; - gdispFillStringBox(0, 0, width, fheight1, line1, font1, Black, White, justifyCenter); - gdispFillStringBox(0, fheight1+1, width, fheight1, line2, font1, Black, White, justifyCenter); + fheight2 = gdispGetFontMetric(font2, fontHeight)+2; + + line1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + line2 = "0123456789~!@#$%^&*_-+=(){}[]<>|/\\:;,.?'\"`"; + + // Font 1 + gdispFillStringBox(0, y, width, fheight1, line1, font1, Black, White, justifyCenter); + y += fheight1+1; + gdispFillStringBox(0, y, width, fheight1, line2, font1, Black, White, justifyCenter); + y += fheight1+1; // Font 2 - fheight2 = gdispGetFontMetric(font2, fontHeight)+2; - gdispFillStringBox(0, 2*fheight1+2, width, fheight2, line1, font2, Black, White, justifyCenter); - gdispFillStringBox(0, 2*fheight1+fheight2+3, width, fheight2, line2, font2, Black, White, justifyCenter); + gdispFillStringBox(0, y, width, fheight2, line1, font2, Black, White, justifyCenter); + y += fheight2+1; + gdispFillStringBox(0, y, width, fheight2, line2, font2, Black, White, justifyCenter); + y += fheight2+1; - // Show Sizes + // Font 1 drawing White on the (black) background + gdispDrawStringBox(0, y, width, fheight1, line1, font1, White, justifyCenter); + y += fheight1+1; + gdispDrawStringBox(0, y, width, fheight1, line2, font1, White, justifyCenter); + y += fheight1+1; + + // Show Sizes buf[0] = (fheight1-2)/10 + '0'; buf[1] = (fheight1-2)%10 + '0'; buf[2] = ','; @@ -72,7 +85,7 @@ int main(void) { buf[4] = (fheight2-2)/10 + '0'; buf[5] = (fheight2-2)%10 + '0'; buf[6] = 0; - gdispFillStringBox(0, 2*fheight1+2*fheight2+4, width, fheight1, buf, font1, Red, White, justifyCenter); + gdispFillStringBox(0, y, width, fheight1, buf, font1, Red, White, justifyCenter); // Wait forever while(TRUE) {