Bascom Proportional Fonts: Unterschied zwischen den Versionen

Aus ProjectWiki
Wechseln zu:Navigation, Suche
K (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 ...")
 
K
 
(21 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 ===
 
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).
 
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).
 
<pre>' GLCD
 
<pre>' GLCD
Config Lcd = ...
+
Config Graphlcd = ...
  
 
$include "ProportionalFont.inc"
 
$include "ProportionalFont.inc"
  
 
' Your application
 
' Your application
 +
Restore Timesnewroman_10pt
 +
Lcd_tt_loadfont
 +
Lcd_tt_text "Hello World!", 0, 0, &HFFFF
 +
 
Do
 
Do
  
Zeile 43: 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:
 
<pre>Dim Width As Word
 
<pre>Dim Width As Word
Width = Lcd_tt_text_width("Your Text")</pre>
+
Width = Lcd_tt_textwidth("Your Text")</pre>
 +
 
 +
The font engine only draws set pixels, leaving out background pixels.
 +
To overwrite text, the background must be cleared manually, for example:
 +
<pre>Dim Width As Word
 +
Do
 +
  ...
 +
  ' draw filled rectangle over previous text
 +
  Lcd_fill_rect [X], [Y], [X + Width], [Y + Lcd_tt_fontheight], [BackColor]
 +
  ' write new text
 +
  Lcd_tt_text [X], [Y], [Text], [Color]
 +
  ' remember text width
 +
  Width = Lcd_tt_textwidth([Text])
 +
  ...
 +
Loop</pre>
 +
 
  
 
Change the font spacing during runtime:
 
Change the font spacing during runtime:
<pre> Lcd_tt_font_spacing = [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:
 +
<pre>Dim Height As Byte
 +
Height = Lcd_tt_fontheight</pre>
 +
 
 +
By changing the pixel draw function, other displays could be used as well (''ProportionalFont.inc'', lines 192-204):
 +
<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.4 (2019-06-01) ===
 +
Library/FontConverter:
 +
 
 +
* Added support for big character fonts (character data size > 256)
 +
* Small performance improvements
 +
 
 +
=== 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.4]
 +
 
  
== 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.3]
* [http://www.braunecker.at/downloads/fontconverter/ProportionalFont.zip Proportional Fonts for Bascom 1.0]
+
* [http://www.braunecker.at/downloads/fontconverter/ProportionalFonts-1-2.zip Proportional Fonts for Bascom 1.2]
 +
* [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]

Aktuelle Version vom 1. Juni 2019, 22:22 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")

The font engine only draws set pixels, leaving out background pixels. To overwrite text, the background must be cleared manually, for example:

Dim Width As Word
Do
   ...
   ' draw filled rectangle over previous text
   Lcd_fill_rect [X], [Y], [X + Width], [Y + Lcd_tt_fontheight], [BackColor]
   ' write new text
   Lcd_tt_text [X], [Y], [Text], [Color]
   ' remember text width
   Width = Lcd_tt_textwidth([Text])
   ...
Loop


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 192-204):

' ### 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.4 (2019-06-01)

Library/FontConverter:

  • Added support for big character fonts (character data size > 256)
  • Small performance improvements

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: