Bascom Proportional Fonts: Unterschied zwischen den Versionen

Aus ProjectWiki
Wechseln zu:Navigation, Suche
K (Font Library)
K
(16 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 3: Zeile 3:
 
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.
 
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.
  
 +
[[File:ProportionalFonts-Screenshot.JPG|frameless|Screenshot]]
  
== Functions ==
+
 
 +
[http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=12601 Forum thread]
 +
 
 +
== Features ==
 
=== Font Converter ===
 
=== Font Converter ===
 
* Exports installed TrueType fonts
 
* Exports installed TrueType fonts
 
* Set size, character spacing, text styles, reduced charsets
 
* Set size, character spacing, text styles, reduced charsets
 +
* Edit generated pixel font
 
* Automatically uses RLE-compression if beneficial
 
* Automatically uses RLE-compression if beneficial
 
* Automatic updates, Stand-alone application
 
* Automatic updates, Stand-alone application
Zeile 14: Zeile 19:
 
* Draws strings with selected font (colored)
 
* Draws strings with selected font (colored)
 
* Width of text with selected font
 
* Width of text with selected font
 
  
 
== How to use ==
 
== How to use ==
 
=== Font Converter ===
 
=== Font Converter ===
[[File:FontConverter-Screenshot.jpg|frameless|Bascom TrueType Font Converter]]
+
[[File:FontConverter-Screenshot.jpg|Bascom TrueType Font Converter]]
  
 
(Controls from left to right, top to bottom)
 
(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).
 
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.
 
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.
 
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.
+
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.
 
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 ===
 
=== Font Library ===
Zeile 35: Zeile 43:
  
 
' Your application
 
' Your application
Lcd_tt_loadfont Timesnewroman_10pt
+
Restore Timesnewroman_10pt
 +
Lcd_tt_loadfont
 
Lcd_tt_text "Hello World!", 0, 0, &HFFFF
 
Lcd_tt_text "Hello World!", 0, 0, &HFFFF
  
Zeile 46: Zeile 55:
  
 
To use the font and draw strings, you first have to load the desired font data:
 
To use the font and draw strings, you first have to load the desired font data:
<pre>Lcd_tt_loadfont Timesnewroman_10pt      ' the label name for the font is the same as the file name</pre>
+
<pre>Restore Timesnewroman_10pt      ' the label name for the font is the same as the file name
 +
Lcd_tt_loadfont</pre>
  
 
Draw a string using the selected font:
 
Draw a string using the selected font:
 
<pre>Lcd_tt_text "Your Text" , [X-Pos] , [Y-Pos] , [16-Bit Color value]</pre>
 
<pre>Lcd_tt_text "Your Text" , [X-Pos] , [Y-Pos] , [16-Bit Color value]</pre>
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.
+
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:
 
Get the width for a specific string using the selected font and spacing:
Zeile 57: Zeile 67:
  
 
Change the font spacing during runtime:
 
Change the font spacing during runtime:
<pre> Lcd_tt_fontspacing = [Spacing from -15 to +15 + 15]                ' ex. -1px: set to 14, +1px: 16</pre>
+
<pre>Lcd_tt_fontspacing = [Spacing from -15 to +15 + 15]                ' ex. -1px: set to 14, +1px: 16</pre>
  
 
Height of selected font in pixels:
 
Height of selected font in pixels:
<pre> Dim Height As Byte
+
<pre>Dim Height As Byte
 
Height = Lcd_tt_fontheight</pre>
 
Height = Lcd_tt_fontheight</pre>
  
By changing the pixel draw function, other displays could be used as well (''ProportionalFont.inc'', lines 115-119).
+
By changing the pixel draw function, other displays could be used as well (''ProportionalFont.inc'', lines 183-195):
 +
<pre>' ### OTHER DISPLAYS ###
 +
!push R10
 +
!push R11
 +
!push R12
 +
!push R13
 +
 
 +
Pset Xpos , Y , 1
 +
 
 +
!pop R13
 +
!pop R12
 +
!pop R11
 +
!pop R10
 +
' ######################</pre>
 +
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.
 +
 
 +
== Changelog ==
 +
=== 1.3 ===
 +
Library:
 +
 
 +
* fixed RAMPZ getting corrupted when not using XRAM, printing only the first character.
 +
 
 +
=== 1.2 ===
 +
FontConverter:
 +
 
 +
* 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
 +
 
 +
Library:
 +
 
 +
* updated for Bascom 2.0.8.0
 +
* 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
 +
 
 +
=== 1.1 ===
 +
FontConverter:
 +
 
 +
* Export corresponding Bascom Library
 +
* Save font in binary file
 +
 
 +
Library:
 +
 
 +
* 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
 +
 
 +
== Downloads ==
 +
* [http://www.braunecker.at/downloads/fontconverter/ProportionalFonts.zip Proportional Fonts for Bascom 1.3]
 +
 
  
== Donate ==
+
Old versions:
This Software is [http://en.wikipedia.org/wiki/Donationware Donationware].
 
<paypal>1</paypal>
 
[[About|See here]] for more informations
 
  
== Download ==
+
* [http://www.braunecker.at/downloads/fontconverter/ProportionalFonts-1-2.zip Proportional Fonts for Bascom 1.2]
* [http://www.braunecker.at/downloads/fontconverter/ProportionalFont.zip Proportional Fonts for Bascom 1.0]
+
* [http://www.braunecker.at/downloads/fontconverter/ProportionalFonts-1-1.zip Proportional Fonts for Bascom 1.1]
 +
* [http://www.braunecker.at/downloads/fontconverter/ProportionalFonts-1-0.zip Proportional Fonts for Bascom 1.0]

Version vom 17. Februar 2019, 12:03 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


Forum thread

Features

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: ProportionalFont.inc containing the font engine and one or more font files (below the End-statement).

' GLCD
Config Graphlcd = ...

$include "ProportionalFont.inc"

' Your application
Restore Timesnewroman_10pt
Lcd_tt_loadfont
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:

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

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 (ProportionalFont.inc, lines 183-195):

' ### OTHER DISPLAYS ###
!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.

Changelog

1.3

Library:

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

1.2

FontConverter:

  • 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

Library:

  • updated for Bascom 2.0.8.0
  • 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

1.1

FontConverter:

  • Export corresponding Bascom Library
  • Save font in binary file

Library:

  • 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

Downloads


Old versions: