Skip to content

Commit 37ceda5

Browse files
committed
Fix Graphics.setFontBitmap on builds with no vector font (fix #1671)
1 parent 6ef2123 commit 37ceda5

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Ensure that a console stays locked even after
1010
Ensure interpreter flags (eg echo) are cleared after a `reset()`
1111
nRF5x: When watchdog is on and automatic, automatically wake up often enough to service it
12+
Fix Graphics.setFontBitmap on builds with no vector font (fix #1671)
1213

1314
2v03 : nRF5x: Fix issue when calling NRF.setAdvertising while connected via BLE (fix #1659)
1415
nRF5x: 'dump()' not outputs `NRF.setSecurity` line if it has been called.

libs/graphics/jswrap_graphics.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,12 +773,13 @@ Make subsequent calls to `drawString` use the built-in 4x6 pixel bitmapped Font
773773
}
774774
Make subsequent calls to `drawString` use a Vector Font of the given height
775775
*/
776-
JsVar *jswrap_graphics_setFontSizeX(JsVar *parent, int size, bool checkValid) {
776+
JsVar *jswrap_graphics_setFontSizeX(JsVar *parent, int size, bool isVectorFont) {
777777
JsGraphics gfx; if (!graphicsGetFromVar(&gfx, parent)) return 0;
778778
#ifdef NO_VECTOR_FONT
779-
jsExceptionHere(JSET_ERROR, "No vector font in this build");
779+
if (isVectorFont)
780+
jsExceptionHere(JSET_ERROR, "No vector font in this build");
780781
#else
781-
if (checkValid) {
782+
if (isVectorFont) {
782783
if (size<1) size=1;
783784
if (size>1023) size=1023;
784785
}

libs/graphics/jswrap_graphics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ int jswrap_graphics_getPixel(JsVar *parent, int x, int y);
4343
JsVar *jswrap_graphics_setPixel(JsVar *parent, int x, int y, JsVar *color);
4444
JsVar *jswrap_graphics_setColorX(JsVar *parent, JsVar *r, JsVar *g, JsVar *b, bool isForeground);
4545
JsVarInt jswrap_graphics_getColorX(JsVar *parent, bool isForeground);
46-
JsVar *jswrap_graphics_setFontSizeX(JsVar *parent, int size, bool checkValid);
46+
JsVar *jswrap_graphics_setFontSizeX(JsVar *parent, int size, bool isVectorFont);
4747
JsVar *jswrap_graphics_setFontCustom(JsVar *parent, JsVar *bitmap, int firstChar, JsVar *width, int height);
4848
JsVar *jswrap_graphics_setFontAlign(JsVar *parent, int x, int y, int r);
4949
JsVar *jswrap_graphics_drawString(JsVar *parent, JsVar *str, int x, int y);

0 commit comments

Comments
 (0)