remove vector font on devices that are short of flash

This commit is contained in:
Gordon Williams 2014-06-24 15:30:02 +01:00
parent 4851cd9eaf
commit 33f430928b
3 changed files with 11 additions and 2 deletions

View File

@ -14,7 +14,9 @@
#include "graphics.h"
#include "bitmap_font_4x6.h"
#ifndef SAVE_ON_FLASH
#include "vector_font.h"
#endif
#include "jsutils.h"
#include "jsvar.h"
#include "jsparse.h"
@ -303,7 +305,7 @@ void graphicsFillPoly(JsGraphics *gfx, int points, short *vertices) {
}
}
#ifndef SAVE_ON_FLASH
// prints character, returns width
unsigned int graphicsFillVectorChar(JsGraphics *gfx, short x1, short y1, short size, char ch) {
// no need to modify coordinates as graphicsFillPoly does that
@ -341,6 +343,7 @@ unsigned int graphicsVectorCharWidth(JsGraphics *gfx, short size, char ch) {
VectorFontChar vector = vectorFonts[ch-vectorFontOffset];
return (vector.width * (unsigned int)size)/(VECTOR_FONT_POLY_SIZE*2);
}
#endif
// Splash screen
void graphicsSplash(JsGraphics *gfx) {

View File

@ -88,8 +88,10 @@ void graphicsDrawRect(JsGraphics *gfx, short x1, short y1, short x2, short y2);
void graphicsDrawString(JsGraphics *gfx, short x1, short y1, const char *str);
void graphicsDrawLine(JsGraphics *gfx, short x1, short y1, short x2, short y2);
void graphicsFillPoly(JsGraphics *gfx, int points, short *vertices); // may overwrite vertices...
#ifndef SAVE_ON_FLASH
unsigned int graphicsFillVectorChar(JsGraphics *gfx, short x1, short y1, short size, char ch); ///< prints character, returns width
unsigned int graphicsVectorCharWidth(JsGraphics *gfx, short size, char ch); ///< returns the width of a character
#endif
void graphicsSplash(JsGraphics *gfx); ///< splash screen
void graphicsIdle(); ///< called when idling

View File

@ -346,7 +346,7 @@ JsVarInt jswrap_graphics_getColorX(JsVar *parent, bool isForeground) {
"description" : "Set Graphics to draw with a Bitmapped Font",
"generate_full" : "jswrap_graphics_setFontSizeX(parent, JSGRAPHICS_FONTSIZE_4X6, false)"
}*/
/*JSON{ "type":"method", "class": "Graphics", "name" : "setFontVector",
/*JSON{ "type":"method", "class": "Graphics", "name" : "setFontVector", "ifndef" : "SAVE_ON_FLASH",
"description" : "Set Graphics to draw with a Vector Font of the given size",
"generate_full" : "jswrap_graphics_setFontSizeX(parent, size, true)",
"params" : [ [ "size", "int32", "The size as an integer" ] ]
@ -428,8 +428,10 @@ void jswrap_graphics_drawString(JsVar *parent, JsVar *var, int x, int y) {
while (jsvStringIteratorHasChar(&it)) {
char ch = jsvStringIteratorGetChar(&it);
if (gfx.data.fontSize>0) {
#ifndef SAVE_ON_FLASH
int w = (int)graphicsFillVectorChar(&gfx, (short)x, (short)y, gfx.data.fontSize, ch);
x+=w;
#endif
} else if (gfx.data.fontSize == JSGRAPHICS_FONTSIZE_4X6) {
graphicsDrawChar4x6(&gfx, (short)x, (short)y, ch);
x+=4;
@ -506,7 +508,9 @@ JsVarInt jswrap_graphics_stringWidth(JsVar *parent, JsVar *var) {
while (jsvStringIteratorHasChar(&it)) {
char ch = jsvStringIteratorGetChar(&it);
if (gfx.data.fontSize>0) {
#ifndef SAVE_ON_FLASH
width += (int)graphicsVectorCharWidth(&gfx, gfx.data.fontSize, ch);
#endif
} else if (gfx.data.fontSize == JSGRAPHICS_FONTSIZE_4X6) {
width += 4;
} else if (gfx.data.fontSize == JSGRAPHICS_FONTSIZE_CUSTOM) {