Bascom Proportional Fonts

Aus ProjectWiki
Version vom 6. November 2014, 20:20 Uhr von Mat (Diskussion | Beiträge) (Created page with "== Overview == 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 ...")
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu:Navigation, Suche

Overview

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.


Functions

Font Converter

  • Exports installed TrueType fonts
  • Set size, character spacing, text styles, reduced charsets
  • 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)

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. 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. Finally, the Save-Button exports the font to a Bascom-Include 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: ProportionalFont.inc containing the font engine and one or more font files (below the End-statement).

' GLCD
Config Lcd = ...

$include "ProportionalFont.inc"

' Your application
Do

Loop
End

$include "TimesNewRoman_10pt.inc"

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

 Lcd_tt_loadfont 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 as long as 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_text_width("Your Text")

Change the font spacing during runtime:

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

This Software is Donationware. <paypal>1</paypal> See here for more informations

Download