{"id":359,"date":"2007-09-30T15:42:37","date_gmt":"2007-09-30T14:42:37","guid":{"rendered":"http:\/\/www.evertdekker.com\/wp\/?p=359"},"modified":"2023-01-08T21:13:51","modified_gmt":"2023-01-08T20:13:51","slug":"graphic-fonts","status":"publish","type":"post","link":"https:\/\/evertdekker.com\/wp\/?p=359","title":{"rendered":"Graphic fonts"},"content":{"rendered":"<hr \/>\n<p>We know the Bascom font files from the graphic display with a KS108 controller. These controllers don\u2019t have a build in font set, so Bascom creates the font by software and writes the letters pixel by pixel on the screen. We can create or modifier those fonts with the Font generator that\u2019s build in Bascom. With this we have a limited flexibility .<\/p>\n<p>The displays with a T6963 have build in font generator for the size 6&#215;8 or 8&#215;8. Custom fonts like the Euro sign or Greek letters is not (easy) to implement, larger or smaller fonts are also not possible with the build in fonts.<\/p>\n<p>But now we have a routine that\u2019s using the Bascom font files and can be used with all the graphics display supported by Bascom.<\/p>\n<p>You can create your own font (share it with us please) or use one of the font\u2019s supplied with Bascom.<\/p>\n<p>All of the font\u2019s can be inverted and\/or rotated in 4 directions.<\/p>\n<p>With the Bascom Locate statement it was not possible to place the text anywhere on the screen. Locate uses an 8&#215;8 matrix to place the text. This routine uses a 1&#215;1 matrix, so you can place the text precise under you graphic image etc.<\/p>\n<p>&nbsp;<\/p>\n<h4>Syntax<\/h4>\n<p><span style=\"color: #3366ff;\">Lcdtext<\/span> string, x , y , fontset , inverse , rotation<\/p>\n<h4>Remarks<\/h4>\n<table class=\"alignleft\" style=\"border-color: #000000;\" border=\"2\" cellspacing=\"2\" cellpadding=\"2\">\n<tbody>\n<tr>\n<td>\u00a0String<\/td>\n<td>\u00a0String to be displayd<\/td>\n<\/tr>\n<tr>\n<td>\u00a0x<\/td>\n<td>\u00a0Constant or variable with x position.<\/td>\n<\/tr>\n<tr>\n<td>\u00a0y<\/td>\n<td>\u00a0Constant or variable with y position.<\/td>\n<\/tr>\n<tr>\n<td>\u00a0fontset<\/td>\n<td>\u00a0Fontset to be used to display the text<\/td>\n<\/tr>\n<tr>\n<td>\u00a0Inverse<\/td>\n<td>\u00a00= Normal 1= Inverted<\/td>\n<\/tr>\n<tr>\n<td>\u00a0Rotation<\/td>\n<td>\u00a00= Normal , 1=90 deg. 2=180 deg. 3=240 deg.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>To add or remove fontsets modify these lines in the subroutine;<\/p>\n<p><strong>If<\/strong> Fontset = 1 <strong>Then<\/strong> <strong>Restore<\/strong> Font8x8<br \/>\n<strong>If<\/strong> Fontset = 2 <strong>Then<\/strong> <strong>Restore<\/strong> Font16x16<br \/>\n<strong>If<\/strong> Fontset = 3 <strong>Then<\/strong> <strong>Restore<\/strong> Font6x8<br \/>\n<strong>If<\/strong> Fontset = 4 <strong>Then<\/strong> <strong>Restore<\/strong> Font5x5<br \/>\nSorry, but there was no better solution.<\/p>\n<p>These are the name\u2019s that you gave to the font, NOT the filename if you don\u2019t know the font name, open the font file in the font editor, and there it is, right on top.<\/p>\n<p>Don\u2019t forget to $Include your font files at the end of the program.<\/p>\n<p>&nbsp;<\/p>\n<p>Here are some sample\u2019s created with the demo program.<\/p>\n<div class=\"n2_ss_slider_publish__option_code\" dir=\"ltr\" data-mode=\"id\"><\/div>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/evertdekker.com\/Joomla\/images\/stories\/CodeVault\/Graphic%20font\/Graphicfont.zip\">Download it all here<\/a><\/p>\n<p>Note : Due a bug in Bascom 1.11.8.8\u00a0 it\u2019s not possible to use fonts 32&#215;32 or bigger.<\/p>\n<p><strong>Update 1:<br \/>\n<\/strong>Color version is now also available. Designed it for the popular Nokia 6100 displays, but it should work on every colordisplay supported by bascom.<\/p>\n<p><a href=\"http:\/\/evertdekker.com\/Joomla\/images\/stories\/CodeVault\/Graphic%20font\/ColorGraphicsFonts.zip\">Download the color version<\/a><\/p>\n<p><strong>Update 2:<\/strong><br \/>\nGot mail from <em>Mladen Bruck<\/em> how lifes in Mostar, Bosnia and Herzegowine.<br \/>\nHe optimized the graphicfont code and it should works now 10-15% faster.<br \/>\nThanks for your contribution Mladen !<br \/>\n<a href=\"http:\/\/evertdekker.com\/Joomla\/images\/stories\/CodeVault\/Graphic%20font\/GraphicfontMladen.rar\">Download the optimized version here<\/a><\/p>\n<p>&nbsp;<\/p>\n<pre class=\"brush: vb; gutter: true\">&#039;------------------------------------------------------------------\r\n&#039;                           GRAPHIC FONT\r\n&#039;     Use the Bascom font file&#039;s for all the graphic display&#039;s,\r\n&#039;              include inverted and\/or rotated text.\r\n&#039;        By Evert Dekker 2007 GraphicFont@Evertdekker dotje com\r\n&#039;                   Created with Bascom-Avr: 1.11.8.8\r\n&#039;------------------------------------------------------------------\r\n\r\n$regfile = &quot;m128def.DAT&quot;\r\n$crystal = 7372800\r\n$baud = 19200\r\n$hwstack = 100\r\n$swstack = 120\r\n$framesize = 100\r\n\r\nConfig Graphlcd = 240 * 128 , Dataport = Porta , Controlport = Portc , Ce = 3 , Cd = 0 , Wr = 2 , Rd = 1 , Reset = 4 , Fs = 5 , Mode = 6\r\nCursor Off\r\nCls\r\n\r\n\r\nDeclare Sub Lcdtext(byval S As String , Byval Xoffset As Byte , Byval Yoffset As Byte , Byval Fontset As Byte , Byval Inverse As Byte , Byval Rotation As Byte)\r\n&#039;SYNTAX  Lcdtest String , Xoffset , Yoffset , Fontset , Inverse , Rotation\r\n&#039;\r\n&#039;* Xoffset and Yoffset is in pixels, so you can place text on every spot on the display\r\n&#039;* You determin yourself in the subroutine witch font belongs to the fontset\r\n\r\n\r\n&#039;=== Your main prog here ====\r\nDo\r\nLcdtext &quot;5X5 Font&quot; , 10 , 2 , 4 , 0 , 0\r\nLcdtext &quot;8X8 Font&quot; , 2 , 120 , 2 , 1 , 3\r\nLcdtext &quot;6X8 Font&quot; , 10 , 20 , 3 , 0 , 0\r\nLcdtext &quot;16X16 font&quot; , 10 , 30 , 2 , 0 , 0\r\nLcdtext &quot;Inverted&quot; , 10 , 85 , 2 , 1 , 0\r\nLcdtext &quot;If you can&#039;t read this then incr. Swstack&quot; , 1 , 120 , 4 , 0 , 0\r\nWait 10\r\nCls\r\nLcdtext &quot;0 deg.Rotation&quot; , 10 , 10 , 1 , 0 , 0\r\nLcdtext &quot;90 deg.Rotation&quot; , 170 , 1 , 1 , 0 , 1\r\nLcdtext &quot;180 deg.Rotation&quot; , 120 , 20 , 1 , 0 , 2\r\nLcdtext &quot;270 deg.Rotation&quot; , 200 , 120 , 1 , 0 , 3\r\nLcdtext &quot;Also inverted&quot; , 150 , 80 , 1 , 1 , 2\r\nLcdtext &quot;Every font&quot; , 150 , 100 , 2 , 0 , 2\r\nWait 10\r\nCls\r\nLoop\r\nEnd\r\n\r\n\r\n\r\n&#039;=== Sub Routines ===\r\nSub Lcdtext(byval S As String , Xoffset As Byte , Yoffset As Byte , Fontset As Byte , Inverse As Byte , Rotation As Byte)\r\nLocal Tempstring As String * 1 , Temp As Byte               &#039;Dim local the variables\r\nLocal A As Byte , Pixels As Byte , Count As Byte , Carcount As Byte , Lus As Byte\r\nLocal Row As Byte , Byteseach As Byte , Blocksize As Byte , Dummy As Byte\r\nLocal Colums As Byte , Columcount As Byte , Rowcount As Byte , Stringsize As Byte\r\nLocal Xpos As Byte , Ypos As Byte , Pixel As Byte , Pixelcount As Byte\r\nIf Inverse &gt; 1 Then Inverse = 0                             &#039;Inverse can&#039;t be greater then 1\r\nIf Rotation &gt; 3 Then Rotation = 0                           &#039;There are only 4 rotation&#039;s\r\nStringsize = Len(s) - 1                                     &#039;Size of the text string -1 because we must start with 0\r\nFor Carcount = 0 To Stringsize                              &#039;Loop for the numbers of caracters that must be displayed\r\n\r\n If Fontset = 1 Then Restore Font8x8                        &#039;Add or remove here fontset&#039;s that you need or not,\r\n If Fontset = 2 Then Restore Font16x16                      &#039;this is the name that you gave to the font, NOT the filename\r\n If Fontset = 3 Then Restore Font6x8                        &#039;If you dont know the name, open the font file in wordpad, and there it is,\r\n If Fontset = 4 Then Restore Font5x5                        &#039;right on top.\r\n\r\n Temp = Carcount + 1                                        &#039;Cut the text string in seperate caracters\r\nTempstring = Mid(s , Temp , 1)\r\nRead Row : Read Byteseach : Read Blocksize : Read Dummy     &#039;Read the first 4 bytes from the font file\r\nTemp = Asc(tempstring) - 32                                 &#039;Font files start with caracter 32\r\nFor Lus = 1 To Temp                                         &#039;Do dummie read to point to the correct line in the fontfile\r\n   For Count = 1 To Blocksize\r\n    Read Pixels\r\n   Next Count\r\nNext Lus\r\nColums = Blocksize \/ Row                                    &#039;Calculate the numbers of colums\r\nRow = Row * 8                                               &#039;Row is always 8 pixels high = 1 byte, so working with row in steps of 8.\r\nRow = Row - 1                                               &#039;Want to start with row=0 instead of 1\r\nColums = Colums - 1                                         &#039;Same for the colums\r\nSelect Case Rotation\r\n    Case 0                                                  &#039;0 degrees rotation\r\n            For Rowcount = 0 To Row Step 8                  &#039;Loop for numbers of rows\r\n                  A = Rowcount + Yoffset\r\n                  For Columcount = 0 To Colums              &#039;Loop for numbers of Colums\r\n                      Read Pixels : If Inverse = 1 Then Toggle Pixels       &#039;Read the byte from the file and if inverse = true then invert de byte\r\n                      Xpos = Columcount                     &#039;Do some calculation to get the caracter on the correct Xposition\r\n                      Temp = Carcount * Byteseach\r\n                      Xpos = Xpos + Temp\r\n                      Xpos = Xpos + Xoffset\r\n                          For Pixelcount = 0 To 7           &#039;Loop for 8 pixels to be set or not\r\n                             Ypos = A + Pixelcount          &#039;Each pixel on his own spot\r\n                             Pixel = Pixels.0               &#039;Set the pixel (or not)\r\n                             Pset Xpos , Ypos , Pixel       &#039;Finaly we can set the pixel\r\n                             Shift Pixels , Right           &#039;Shift the byte 1 bit to the right so the next pixel comes availible\r\n                          Next Pixel\r\n                  Next Columcount\r\n            Next Rowcount\r\n    Case 1                                                  &#039;90 degrees rotation\r\n            For Rowcount = Row To 0 Step -8                 &#039;Loop is now counting down\r\n                  A = Rowcount + Xoffset\r\n                  A = A - 15                                &#039;Correction to set Xpos on Xoffset with rotation\r\n                  For Columcount = 0 To Colums\r\n                      Read Pixels : If Inverse = 1 Then Toggle Pixels\r\n                      Xpos = Columcount\r\n                      Temp = Carcount * Byteseach\r\n                      Xpos = Xpos + Temp\r\n                      Xpos = Xpos + Yoffset                 &#039;We want that Xoffset is still Xoffset, so we need here the change from x to y\r\n                             For Pixelcount = 7 To 0 Step -1\r\n                                Ypos = A + Pixelcount\r\n                                Pixel = Pixels.0\r\n                                Pset Ypos , Xpos , Pixel\r\n                                Shift Pixels , Right\r\n                             Next Pixel\r\n                  Next Columcount\r\n            Next Rowcount\r\n    Case 2                                                  &#039;180 degrees rotation\r\n            For Rowcount = Row To 0 Step -8\r\n                  A = Rowcount + Yoffset\r\n                  A = A - 7                                 &#039;Correction to set Xpos on Xoffset with rotation\r\n                  For Columcount = Colums To 0 Step -1\r\n                      Read Pixels : If Inverse = 1 Then Toggle Pixels\r\n                      Xpos = Columcount\r\n                      Temp = Carcount * Byteseach\r\n                      Xpos = Xpos - Temp\r\n                      Xpos = Xpos - 8                       &#039;Correction to set Xpos on Xoffset with rotation\r\n                      Xpos = Xpos + Xoffset\r\n                          For Pixelcount = 7 To 0 Step -1\r\n                             Ypos = A + Pixelcount\r\n                             Pixel = Pixels.0\r\n                             Pset Xpos , Ypos , Pixel\r\n                             Shift Pixels , Right\r\n                          Next Pixel\r\n                  Next Columcount\r\n            Next Rowcount\r\n    Case 3                                                  &#039;270 degrees rotation\r\n            For Rowcount = 0 To Row Step 8\r\n                  A = Rowcount + Xoffset\r\n                    For Columcount = Colums To 0 Step -1\r\n                      Read Pixels : If Inverse = 1 Then Toggle Pixels\r\n                      Xpos = Columcount\r\n                      Temp = Carcount * Byteseach\r\n                      Xpos = Xpos - Temp\r\n                      Xpos = Xpos - 8                       &#039;Correction to set Xpos on Xoffset with rotation\r\n                      Xpos = Xpos + Yoffset\r\n                             For Pixelcount = 0 To 7\r\n                                Ypos = A + Pixelcount\r\n                                Pixel = Pixels.0\r\n                                Pset Ypos , Xpos , Pixel\r\n                                Shift Pixels , Right\r\n                             Next Pixel\r\n                  Next Columcount\r\n            Next Rowcount\r\nEnd Select\r\nNext Carcount\r\nEnd Sub                                                     &#039;End of this amazing subroutine\r\n\r\n\r\n&#039;=== Includes ===\r\n$include &quot;Font8x8.font&quot;                       &#039;Includes here your font files\r\n$include &quot;Font16x16.font&quot;                     &#039;If you don&#039;t need the files in your program, don&#039;t include them,\r\n$include &quot;Font6x8.font&quot;                       &#039;these are flash memory eaters.\r\n$include &quot;Font5x5.font&quot;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>We know the Bascom font files from the graphic display with a KS108 controller. These controllers don\u2019t have a build in font set, so Bascom creates the font by software and writes the letters pixel by pixel on the screen. We can create or modifier those fonts with the Font generator that\u2019s build in Bascom. [&#8230;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[26,44,43],"class_list":["post-359","post","type-post","status-publish","format-standard","hentry","category-bascom","tag-bascom","tag-display","tag-graphic-fonts"],"_links":{"self":[{"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/359","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=359"}],"version-history":[{"count":6,"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/359\/revisions"}],"predecessor-version":[{"id":1924,"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/359\/revisions\/1924"}],"wp:attachment":[{"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=359"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=359"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/evertdekker.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=359"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}