I’m hoping someone can save me a learning curve here. I’m messing with the Adafruit GFX library here with a view to making a subset of my normal MQTT-based code supporting the little 160*128 LCD displays. All of this is working – I can put text up directly from an MQTT message – no problem.
But I’m having trouble getting my head around the GFX fonts.
Firstly – there seems to be a source code command line tool for generating fonts – and I need an LCD-type font… but I cannot find a precompiled version of the tool or similar for Windows and reference to Windows is so vague in the GFX info I’m not sure I want to go experimenting. Has anyone successfully made fonts in Windows for this library?
Secondly font height. The cursor positioning is based on pixels – and it seems that if you want to go to line X of text you have to guess how many pixels you need to use as a multiplier – that can’t be right surely? There is a function for figuring out the XY bounds of a string so you can use a block erase before writing but that too is in pixels and assumes you know the height of the font. Surely there must be a function somewhere that simply returns the height of the current font?
Pete.
Well you were right Martin – you do have to share D Drive – makes sense really I guess…. but there’s a bug in Docket – and under no circumstances will it accept my Windows 10 user password…. you have to wonder…
Hi Peter, if you are familiar with docker, this link will take less than 2 minutes to solve your issue with font conversion:
https://github.com/sepal/docker_fontconverter
If you need help with docker itself, just check:
https://www.docker.com/products/docker#/windows
BTW, Mike I’m also interested in your adafruits gfx new functions.
Well, I tried. With a working Docker in Windows 10 Pro, I made sure the sepal/docker_fontconverter file existed with that github stuff in it and….
D:\tmp>docker run –rm -i -t -v `pwd`:/fonts sepal/docker_fontconverter fontconvert Inconsolata.otf 12 > Inconsolata.h
Unable to find image ‘sepal/docker_fontconverter:latest’ locally
Mmmm it should try to download the image if it’s not locally…. works for me the first try in Mac OS.
Does the classic test works for you?
$ docker run -it ubuntu bash
PS C:\Users\samstevens> docker run -it ubuntu bash
Unable to find image ‘ubuntu:latest’ locally
latest: Pulling from library/ubuntu
5a132a7e7af1: Pull complete
fd2731e4c50c: Pull complete
28a2f68d1120: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:4e85ebe01d056b43955250bbac22bdb8734271122e3c78d21e55ee235fc6802d
Status: Downloaded newer image for ubuntu:latest
So when I tried that other program – it would not load the remote version.
Funny enough I’m getting the same with the Ubuntu – network timed out..
I’m running reasonably fast (6 meg down) internet and no firewall on Windows 10.
C:\Windows\System32>docker run -it ubuntu bash
Unable to find image ‘ubuntu:latest’ locally
Pulling repository docker.io/library/ubuntu
docker: Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/ubuntu/images. You may want to check your internet connection or if you are behind a proxy..
See ‘docker run –help’.
C:\Windows\System32>
Ok I give up – finally got Docker to work – it was DNS lookup…. fix was on the site…
docker run –rm -i -t -v pwd:/fonts sepal/fontconverter fontconvert Inconsolata.otf 12 > Inconsolata.h
Getting an error – the font is there – makes a header with nothing but a short error message in it – anything you can see wrong with that command line?
Yes, the `pwd`is a unix command to print the current directory… try something like this:
docker run –rm -i -t -v c:\path\to\your\fontdir:/fonts sepal/fontconverter fontconvert Inconsolata.otf 12 > Inconsolata.h
Same error – what is ending up in the header is …
Font load error: 1
In other words it does not like that font – if I spell the font incorrectly I get the same – as if it isn’t seeing the font.
I’ve tried d:\tmp\Inconsolata.otf
\tmp\Inconsolata.otf
/tmp/Inconsolata.otf
Same error every time – yet this is the example given on the website!!
Maybe you have to share D: drive?
https://docs.docker.com/docker-for-windows/#/shared-drives
BTW, I have converted all ttf fonts, don’t know if this tool converts otf fonts files.
I quickly had a look at the changes I made, and I made a big rewrite of the text/font handling including adding of functions to set/get text position X/Y (as character position, not pixel which you rightly state is all that is there in the Adafruit library).
Ok Mike – you definitely have my interest… look forward to it. Link here or direct to my email pete at scargill dot org…..
I have sent you an email
Getting excited already to see your mods..
Towards the end of last year I wrote a whole load of extensions and enhancements to that library. In my case I was using a Nokia 5110 device, but that is neither here nor there.
I can let you have a copy of my changes if you would like, however the code isn’t documented other than .h and .cpp comments which may make your life easier in some ways and more problematic in others. Let me know.
The OLED_I2C library at http://www.rinkydinkelectronics.com/library.php?id=79 has font support and online font maker iş present at http://www.rinkydinkelectronics.com/resources.php
Maybe looking at the library source helps. 😉
Excellent – the esp8266 of course has no I2c – it’s all done in software. Interestingly I’m sitting playing with the Arduino/ESP8266 driver for the QTECH displays (160×120) – and they are SPI – which the ESP does have – and that is FAST.
why don’t you do the conversion on the raspberry? i think it’s simpler than finding a windows binary… in the end, it’s a one time job… or you can try to do a MAKE in that directory, using cygwin on windows