Bascom Proportional Fonts

Aus ProjectWiki
Wechseln zu:Navigation, Suche


This proportional font system for graphic-LCDs consists of a Bascom-Library, which interprets the font data and draws the characters on the screen. The font data comes in an proprietary format, the font files could be generated with the included TrueType Font Converter.


Forum thread


Font Converter

  • Exports installed TrueType fonts
  • Set size, character spacing, text styles, reduced charsets
  • Edit generated pixel font
  • Automatically uses RLE-compression if beneficial
  • Automatic updates, Stand-alone application

Font Library

  • Loads font data
  • Draws strings with selected font (colored)
  • Width of text with selected font

How to use

Font Converter

Bascom TrueType Font Converter

(Controls from left to right, top to bottom) Font properties: Select Font Family, Font size in point (the resulting height in pixels is calculated and displayed at the bottom of the window), font spacing in pixels between each character (ranging from -15 to +15, not visible in the preview) and text styles (bold, italic, underline). Below, single ASCII values and/or ranges of values (separated by , range indicated by -, ex. 32, 33, 65-90) could be entered or select one of the predefined charset ranges. Threshold could be a value from 1 to 254. The charset and preview text is editable as well, the arrow-up button sets the charset needed to draw the preview text, the arrow-down button sets the charset as preview text. Font editor: Choose the character to edit from the list. The conversion threshold could be set for each character individually. In the character drawing area, the left mouse button sets a pixel and the right button clears it. Export library exports the font library in a choosen folder. Open loads a Bascom-include font file, Save exports the font to a include file or a binary file. When launching the stand-alone application, it searches for updates, if available, the application gets replaced by the new version, no installation needed.

Font Library

At least two files need to be included in your application: containing the font engine and one or more font files (below the End-statement).

Config Graphlcd = ...

$include ""

' Your application
Restore Timesnewroman_10pt
Lcd_tt_text "Hello World!", 0, 0, &HFFFF



$include ""

To use the font and draw strings, you first have to load the desired font data:

Restore Timesnewroman_10pt      ' the label name for the font is the same as the file name

Draw a string using the selected font:

Lcd_tt_text "Your Text" , [X-Pos] , [Y-Pos] , [16-Bit Color value]

The previously selected font will be used until another one is loaded, no need to reload the font data every time before drawing a string.

Get the width for a specific string using the selected font and spacing:

Dim Width As Word
Width = Lcd_tt_textwidth("Your Text")

Change the font spacing during runtime:

Lcd_tt_fontspacing = [Spacing from -15 to +15 + 15]                 ' ex. -1px: set to 14, +1px: 16

Height of selected font in pixels:

Dim Height As Byte
Height = Lcd_tt_fontheight

By changing the pixel draw function, other displays could be used as well (, lines 183-195):

!push R10
!push R11
!push R12
!push R13

Pset Xpos , Y , 1

!pop R13
!pop R12
!pop R11
!pop R10
' ######################

The pushed registers are used by the font routine, to support unknown Set-Pixel functions, they are saved as a precaution. If the registers are not used by the Set-Pixel function, the stack-saving could be omitted for speed reasons.




  • fixed RAMPZ getting corrupted when not using XRAM, printing only the first character.



  • Added a character editor to modify the generated pixel font
  • Added .inc font import
  • Added pixel conversion threshold for font generation
  • Fixed wrong arranged GUI elements when minizing
  • Proper handling of underlined fonts
  • Removed "Set charset" button
  • minor bug fixes


  • updated for Bascom
  • Lcd_tt_text(): fixed R0 could contain wrong values when the font uses RLE compression, leading to corrupted text after the first character
  • Lcd_tt_textwidth(): proper local variable initialisation



  • Export corresponding Bascom Library
  • Save font in binary file


  • Lcd_tt_loadfont(): removed bylabel call, use Restore [Fontlabel] before calling Lcd_tt_loadfont()
  • Proper handling of RAMPZ register for devices with more than 64K flash memory
  • ~30% speed increase


Old versions: