Skip to content

Latest commit

 

History

History
73 lines (50 loc) · 3.44 KB

add-font-face.md

File metadata and controls

73 lines (50 loc) · 3.44 KB

Adding Font-Face for for PicoTerm

This following roadmap explains the various steps used to add a new font-face into PicoTerm (like we do for "Olivetti Thin" font. Click the link fpr credit.)

1) Getting the font

The first operation is to get the TTF font.

Font must have 15 pixels high at the most. The selected font will have 14 lines height (as we will see in the .line_height property of the generated c file).

As already stated, we will download the Ac437_OlivettiThin_8x16.tff (see direct link https://int10h.org/oldschool-pc-fonts/fontlist/?2#olivetti ).

2) Convert TTF to C file

Now we will use the LVGL online fontconverter to convert the TTF file to C https://lvgl.io/tools/fontconverter .

Convert TTF to C

Here the parameter used:

  • name: olivetti_thin (will be the C filename and lv_font_t object name)
  • size: 16px as stated in ttf font name.
  • Bpp : 4 bit per pixels
  • TTF/WOFF : select the downloaded Ac437_OlivettiThin_8x16.tff font.
  • Range : only keeps the chars 0x20 to 0x7E (like in the original picoterm font8.c)

Click the [Convert] button.

  • That will generates and download the olivetti_thin.c
  • DO NOT SAVE this olivetti_thin.c in the source code BUT open it into a text editor (we will use it as a refence).

3) Prepare the furur c file

copy the /font-suite/font8.c and name it /font-suite/olivetti_thin.c.

Open this new /font-suite/olivetti_thin.c in your code editor.

4) Merging files

We will now merge the downloaded olivetti_thin.c into the created font-suite/olivetti_thin.c.

As type declaration are not identical between the file, we will merge the content manually.

Carefully replace the following sections of font-suite/olivetti_thin.c with the definition of the downloaded olivetti_thin.c:

  • Update the #define statements with the appropriate OLIVETTI_THIN
  • Replace the data (only the data) in the BITMAP section
  • Replace the data in the the GLYPH DESCRIPTION section
  • Update the data in the CHARACTER MAPPING section
  • Update the data in the ALL CUSTOM DATA section
  • Update the data in the PUBLIC FONT
  • set the lv_font_t structure name to olivetti_thin
  • update the .font_height accordinly
  • update the .baseline accordingly

5) Compile_font.py : merging font + charset

Open the font-suite/compile_font.py .

In the "__ __ main __ __" section of the script, add the required intructions to combine font-suite/olivetti_thin.c with the available charsets (actually cp437.data and nupetscii.data).

This will creates the files font-suite/olivetti_thin_cp437.c and font-suite/olivetti_thin_nupetscii.c.

6) Compiling the new font in picoterm

  • Update CMakeLists.txt:
  • copy the olivetti_thin_*.c files to sources directory.
  • append the olivetti_thin_*.c files to the source to be compiled (look for list( APPEND sources).
  • update main.c to add extern declararation the extern const lv_font_t nupetscii_olivetti_thin; and cp437_olivetti_thin too.
  • update common/picoterm_stddef.h and .c files to add the new font.
  • update the various sources files follow the FONT_NUPETSCII_MONO8 to identifies the place to update the code. Following files may be touched:
  • main.c
  • picoterm_conio.c (print_nupet())
  • picoterm_screen.c (configuration screen)
  • common/picoterm_cursor.c
  • common/picoterm_dec.c (DEC line drawing)