Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: ILI9341 seven segment font

  1. #1
    Member
    Join Date
    Oct 2016
    Location
    Farnborough, UK
    Posts
    27

    ILI9341 seven segment font

    Sorry, very much a newby, I want to write 7 segment font ( 0 to 9 only) to the QVGA 2.2" display 240x320.
    I have no idea how to a) find a suitable font, b) how to call it for use in the code.

    I have been playing with the code below (completely unfinished) but if I can change the default font to 7 Segment display type that will get me on my way.

    BR Pete D.
    Attached Files Attached Files

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,939
    Sorry hopefully some one who has edited their own fonts will chime in and give some more help.

    Also most of my stuff playing with this has been done using our own Teensy oriented drivers, like ILI9341_t3 or more with my own ILI9341_t3n

    For these drivers we also have a different Font format defined, and there are some github projects up with lots of fonts like up at: https://github.com/Paulstoffregen/ILI9341_fonts

    You can copy them in to your project or you can put these into a proper library location and simply include the header file for the font... Warning however with this version of the font library it will include all of the fonts into your project which use up space. A few of us created version of that library: https://github.com/mjs513/ILI9341_fonts
    Which sets it up as arduino new library format, which allows us to create an archive file from it, which than will cause Arduino linker to only include those fonts which are used.

    There are also places mentioned up on forum on tools and the like to create the fonts.

    Adafruit GFX library also includes a set of fonts.

    Now depending on which Graphic library you end up using, you need to then have your sketch include the include file for the font... My ILI9341_t3n library has examples, which include both types of fonts.
    Example (ILI_Ada_FontTest4),

    Like:
    Code:
    #include <ILI9341_t3n.h>
    
    #include "font_Arial.h"
    #include "font_ArialBold.h"
    #include "font_ComicSansMS.h"
    ...
    // maybe a few GFX FOnts?
    #include <Fonts/FreeMono9pt7b.h>
    #include <Fonts/FreeSerif9pt7b.h>
    Now to use the fonts you would use the library method setFont.
    Again my _t3n gives support for the both the Adafruit fonts by passing in pointer to font
    Or to the ILI9341 font format by passing in reference to one of those fonts.

    So again for Adafruit font, like the FreeSerif... You would do something like:
    Code:
    tft.setFont( &FreeMono9pt7b);
    Note: I believe that Adafruit fonts are one font structure per file, note the same name as the include...

    For ILI fonts, we pass in something like:
    Code:
    tft.setFont(Arial_12);
    where the file font_Arial.h above actually defined Ariel font for several different sizes, so you need to look at header file to see which ones.

    Once you set the font, you can simply do things like: tft.print("ABCD");
    Which will output in the currently selected font

  3. #3
    Member
    Join Date
    Oct 2016
    Location
    Farnborough, UK
    Posts
    27
    Thanks Kurt,

    Now need to spend a bit of time absorbing your detailed information.
    Thanks again.
    BR Pete D.

  4. #4
    If you can move to use the ILI9341_t3, here's a video that shows how to create and use custom fonts from Windows TTF fonts. Shown is how to use a utility that let's you convert fonts, adjust kerning, and create just a range 0-9 for example. The utility is pretty easy to use, links to it provide in the vid
    https://youtu.be/YNUbvpTaaCY

    If you must stick with the Adafruit driver, here's a video on how to create and use custom fonts from Windows TTF fonts. Shown is a command prompt based utility where you feed some parameters in an old c:\> type prompt. The utility came from Adafruit and while its not too capable it gets the job done
    https://youtu.be/L8MmTISmwZ8


    Note when using custom fonts that are proportional (like Arial) to draw data that updates, say a time, you will not be able to simply pass a background color to erase the previous data--hence filled box drawing to blank out the old data. This causes a flicker and can look unprofessional. This vid show how to use a flicker free library to get better drawing.
    https://youtu.be/uMqTAoCCCX8


    Welcome to Teensy and this forum

  5. #5
    Member
    Join Date
    Oct 2016
    Location
    Farnborough, UK
    Posts
    27
    Hi Kris,

    That was amazingly useful. The only reason I was using Adafruit library is because I did not know any better. Now switched to _t3 and created my own font. Progress. Thank you so much for your help.

    Also Thanks to Kurt. Charging ahead now :-)

    BR Pete Dobson.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •