aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorinmarket <inmarket@ugfx.org>2017-01-18 14:27:25 +1000
committerinmarket <inmarket@ugfx.org>2017-01-18 14:27:25 +1000
commit9360b2725035727262df05ae720654a48d620c69 (patch)
tree6d2cc409cbaa9c5d42c58745dce704f3adf1e952
parentb8ece23f18d184a66b6a59ab982cd2d2a0e0964d (diff)
downloaduGFX-9360b2725035727262df05ae720654a48d620c69.tar.gz
uGFX-9360b2725035727262df05ae720654a48d620c69.tar.bz2
uGFX-9360b2725035727262df05ae720654a48d620c69.zip
Update font demo to show Anti-aliased drawing
-rw-r--r--demos/modules/gdisp/fonts/gfxconf.h4
-rw-r--r--demos/modules/gdisp/fonts/main.c35
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;
+
+ // 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
+ // 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) {