Description
There have been discussions about this in the past (I'm afraid I can't find any good links at the moment - they're probably on the forum). But vaguely related issues are #1145 and #1311
Problem
- Smaller fonts are too thin to be readable
- Big/small font styles don't match
- We don't support any characters outside ISO8859-1 0..255 codepage with current fonts
- We don't have a nice way of choosing what font to use right now - every app implements its own solution, using hard-coded fonts
Where we are
- There is an awesome free font in different sizes, specifically designed for the Bangle's display (well, pebble's): https://github.com/pebble-dev/renaissance/tree/master - it's in PBF format
- Bangle.js now supports PBF loading and rendering
- Bangle.js 2 also now supports Unicode so can render non-ASCII chars too
- There's also GNU unifont which I've turned into a PBF file so we can even support full chinese/japanese/etc locally
So what's the issue?
It'd be nice if we had a global way of changing fonts (eg by installing an app/library via the App Loader) - to either change the look and feel, size of fonts, or to add native support for more character sets.
While we could have a library/function that handled simple font selection, eg require("font").getFont("big"/"medium"/"small")
I don't think that's really useful enough.
I think we need something that'll choose a font based on some text and how much space there is. For example:
... = require("font").getFont({
w : 176, h : 120,
wrap : true,
text : "Hello this is a lot of text I want to display on the screen"
});
... = require("font").getFont({
w : 60, h : 60,
wrap : false,
text : "10m"
})
Any thoughts on this? I think the main things it needs to be able to handle are:
- Blocks of text in messages
- Small bits of text for labels or values (eg the 'run' app)
- Ideally being aware of images in the text - no point using a tiny font when there are images that are 16px high anyway
- Maybe returning the pre-wrapped, pre-cropped (with
...
) text as well as the font just to save on computing things twice - Specifying a maximum/minimum font height?
- Do we need to think about multiple text items? For example if we have a list (like in the Launcher) maybe we want to make everything in the list the same size?
I guess it might be good to think about existing apps that would benefit from this (messagegui
, launcher
, run
, E.showMenu
, E.showPrompt
, etc) and what kind of features they would need?
Also, I guess this may need to be something that runs quite fast - so do we actually want a built-in function that just looks at a list of available fonts? Or maybe we get it working in JS first, then if it's slow we look at moving it inside the firmware.