Cahnge Font Size in Python



  • I'm working on online font converter which will be available on my server.
    It will convert any ttf font to c source file and/or compiled fon file compatible with this MicroPython.
    It should be ready in a couple of weeks (I don't have much free time).


  • M5Stack

    @loboris very cool, look forward to trying it out, meanwhile I will find a way to use the tool you suggested, for some reason I have never been able to successfully install homebrew on my mac. BTW I was wondering does it work with non roman fonts? japanese, thai, arabic etc..



  • @loboris While you are working on this, could you also make it an output option to create the .h files needed to use the font with Adafruit's gfx library? (See here for details.) Is there any way for me to help?



  • @ropCahnge Font Size in Python 中说:

    @loboris While you are working on this, could you also make it an output option to create the .h files needed to use the font with Adafruit's gfx library? (See here for details.) Is there any way for me to help?

    Maybe, if you can provide the exact and detailed description of the format.



  • @loboris Not sure what server you would be running this on. If linux or other unix it should be relatively easy. As per the link I sent earlier:

    Adding New Fonts
    If you want to create new font sizes not included with the library, or adapt entirely new fonts, we have a command-line tool (in the fontconvert folder) for this. It should work on many Linux- or UNIX-like systems (Raspberry Pi, Mac OS X, maybe Cygwin for Windows, among others).
    Building this tool requires the gcc compiler and FreeType library. Most Linux distributions include both by default. For others, you may need to install developer tools and download and build FreeType from the source. Then edit the Makefile to match your setup before invoking make.
    fontconvert expects at least two arguments: a font filename (such as a scalable TrueType vector font) and a size, in points (72 points = 1 inch; the code presumes a screen resolution similar to the Adafruit 2.8" TFT displays). The output should be redirected to a .h file…you can call this whatever you like but I try to be somewhat descriptive:

    ./fontconvert myfont.ttf 12 > myfont12pt7b.h
    


  • I have finished the font converter (written in Python) for the font format used in this MicroPython port and it works wery well.
    I'm working on the web interface now, the online converter will be available soon on my server, after some more testing.
    It will also be available as a standalone Python program (should work on any OS).

    Some features:

    • Converting any ttf font to C source file which can be compiled with tft.font_compile() or included into the build to be compiled into the firmware is supported

    • Converting directly to binary fon file which can be used with tft.font() is also supported

    • Convert full ascii character set (32 - 127) or only the selected characters

    • Adding characters from cp1252 and cp1250 code pages is supported (more code pages will be probably added later).
      Including characters like Ä, , ß, Č, Đ, ž, ø, µ, ° is now supported
      I'll try to add support for non-Latin character sets like Cyrillic, Hebrew, Arabic, Chinese, later.

    • Font sizes from 8 to 110 pixels are supported

    At the moment I don't have enough free time to support conversion to any other format.



  • @loboris
    thanks :) can test it when its ready ...



  • The online font creator is now ready for testing.
    More instructions and examples will be added later, but it should work.
    Please, test and report the issues.

    LoBo Font creator


  • M5Stack

    Awesome can we share this or do you want to keep the testing to a small number of people?



  • @lukasmaximusCahnge Font Size in Python 中说:

    Awesome can we share this or do you want to keep the testing to a small number of people?

    It should be ready for use, by "testing" I've meant I would like to get some information if any issue is detected or any improvement is wanted.
    I've already found a small "bug", if hebrew characters are included the wrong C file is generated (caused by right to left writting), the bynary fon file is OK.


登录后回复
 

与 M5Stack Community 的连接断开,我们正在尝试重连,请耐心等待