Skip to content

Commit e648635

Browse files
committed
Add new custom-tweaked 30px font, Make findFont work with Bangle.js 1
1 parent c52bbd1 commit e648635

15 files changed

+29032
-16
lines changed

boards/BANGLEJS2.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@
6969
'DEFINES += -DESPR_NO_LINE_NUMBERS=1', # we execute mainly from flash, so line numbers can be worked out
7070
'INCLUDE += -I$(ROOT)/libs/banglejs -I$(ROOT)/libs/misc',
7171
'WRAPPERSOURCES += libs/banglejs/jswrap_bangle.c',
72-
'WRAPPERSOURCES += libs/banglejs/jswrap_font_15.c',
73-
'WRAPPERSOURCES += libs/banglejs/jswrap_font_19.c',
74-
'WRAPPERSOURCES += libs/banglejs/jswrap_font_22.c',
72+
'WRAPPERSOURCES += libs/graphics/jswrap_font_15.c',
73+
'WRAPPERSOURCES += libs/graphics/jswrap_font_19.c',
74+
'WRAPPERSOURCES += libs/graphics/jswrap_font_22.c',
75+
'WRAPPERSOURCES += libs/graphics/jswrap_font_30.c',
7576
'WRAPPERSOURCES += libs/graphics/jswrap_font_6x15.c',
7677
'WRAPPERSOURCES += libs/graphics/jswrap_font_12x20.c',
7778
'SOURCES += libs/misc/nmea.c',

libs/graphics/font/README.md

+45-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,50 @@ Fonts
33

44

55
This directory contains font maps of various fonts, as well
6-
as a tool to interpret them (`scripts/create_custom_font.js`)
6+
as tools to interpret them
77

8-
Currently this is only used for testing purposes.
8+
## Tools
9+
10+
These are now (mainly) stored in https://github.com/espruino/EspruinoWebTools
11+
12+
## 4x6 and 6x8
13+
14+
These are fixed-width fonts, created from:
15+
16+
* font4x6.png
17+
* font6x8.png
18+
19+
```
20+
node ~/workspace/EspruinoWebTools/cli/fontconverter.js font4x6.png --height 6 --debug --oh bitmap_font_4x6.h
21+
node ~/workspace/EspruinoWebTools/cli/fontconverter.js font6x8.png --height 8 --debug --oh bitmap_font_6x8.h
22+
```
23+
24+
This doesn't generate the exact file, as the code to decode it (`graphicsDrawChar4x6`/etc) is usually on the end.
25+
26+
## Vector Fonts
27+
28+
The vector font is stored in `fontmap_13x19.svg` and is decoded with `build_vector_font.js`
29+
30+
## renaissance Fonts
31+
32+
These fonts are used by Bangle.js 2. These are turned into Espruino files (embedded `pbf` fonts) with the following commands:
33+
34+
```
35+
node ~/workspace/EspruinoWebTools/cli/fontconverter.js renaissance_28.pbff --range All --height 22 --shiftUp 10 --nudge --debug --spaceWidth 4 --opbfc 22
36+
node ~/workspace/EspruinoWebTools/cli/fontconverter.js renaissance_24_bold.pbff --range All --height 19 --shiftUp 8 --nudge --debug --spaceWidth 3 --opbfc 19
37+
node ~/workspace/EspruinoWebTools/cli/fontconverter.js renaissance_18_bold.pbff --range All --height 15 --shiftUp 7 --nudge --debug --spaceWidth 3 --opbfc 15
38+
node ~/workspace/EspruinoWebTools/cli/fontconverter.js renaissance_18_doubled.pbff --range All --height 30 --spaceWidth 6 --opbfc 30
39+
```
40+
41+
`renaissance_18_doubled.pbff` was originally created with:
42+
43+
```
44+
node ~/workspace/EspruinoWebTools/cli/fontconverter.js renaissance_18.pbff --range All --height 15 --shiftUp 7 --nudge --doubleSize --opbff renaissance_18_doubled.pbff
45+
```
46+
47+
And then patched up by hand to attempt to smooth it out. Some glyphs are still not complete.
48+
49+
## Testing
950

1051
You can dump a font map from Espruino using something like this:
1152

@@ -14,8 +55,8 @@ var W=4,H=6,FONT="4x6";
1455
//var W=6,H=8,FONT="6x8";
1556
var b = Graphics.createArrayBuffer(W*16,H*16,1,{msb:true});
1657
b.clear(1).setFont(FONT);
17-
for (var y=0;y<16;y++) {
18-
for (var x=0;x<16;x++) {
58+
for (var y=0;y<16;y++) {
59+
for (var x=0;x<16;x++) {
1960
if (x || y) b.drawString(String.fromCharCode(x+(y*16)),x*W,y*H)
2061
}
2162
}

0 commit comments

Comments
 (0)