Bascom Proportional Fonts: Unterschied zwischen den Versionen

Aus ProjectWiki
Wechseln zu:Navigation, Suche
K (Download)
K
Zeile 5: Zeile 5:
 
[[File:ProportionalFonts-Screenshot.JPG|frameless|"Screenshot"]]
 
[[File:ProportionalFonts-Screenshot.JPG|frameless|"Screenshot"]]
  
== Functions ==
+
== Features ==
 
=== Font Converter ===
 
=== Font Converter ===
 
* Exports installed TrueType fonts
 
* Exports installed TrueType fonts

Version vom 6. November 2014, 22:19 Uhr

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.

"Screenshot"

Features

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 Graphlcd = ...

$include "ProportionalFont.inc"

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

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_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 (ProportionalFont.inc, lines 115-119).

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

Download