Results 1 to 32 of 32

Thread: Bitmap font editor for graphic LCD

  1. #1
    Join Date
    2003/11
    Location
    Western WA, USA
    Posts
    1,148

    Bitmap font editor, C code, for graphic LCD

    I reinvented this wheel several years ago, since I couldn't find anything online, and I keep tweaking it for new projects. This editor will create/edit fonts that are 8 or 16 pixels high, up to 16 pixels wide (variable). The bitmaps are compatible with common graphic LCD controllers that use 8 pixel high "pages". The output can include a "C" or "asm" style text file, to use in your programs.

    Since I see people asking about where to find font tables, I decided to make this available. If you have complaints, bug reports or suggestions, PM or email me.

    NOTICE: The ancient program attached here has been superceeded by a much slicker version. If you have downloaded this old version, you should switch to the newest CFE_64 version (as of 02/13/2014) here:
    https://forum.crystalfontz.com/showt...8164#post28164
    Attached Files Attached Files
    Last edited by cosmicvoid; August 10, 2007 at 08:29 PM.
    Infinity or Bust

  2. #2
    Join Date
    2003/11
    Location
    Western WA, USA
    Posts
    1,148

    C code text driver for graphic LCD

    This C driver is designed to put text strings on a graphic LCD. It will handle small (8 pixel high) and large (16 pixel high) fonts. There are several justification modes (left, right, centered at different locations) and display options.

    The initialization section is designed for use with Epson SED1565 controllers (as used in several Optrex displays) and Samsung KS0713/1713 controllers (as used in Crystalfontz CFAX type displays), but can probably be modified for others.

    Note: this C code is a translation of my assembler source, which has been thoroughly tested, and is in use in commercial products. Since I don't currently use C for embedded projects, I have not actually tested this version. It compiles without error, but since it needs to be customized for your target processor and environment anyway, you will have to do the real testing.

    If you have questions or suggestions, PM or email me.
    Attached Files Attached Files
    Last edited by cosmicvoid; March 14, 2005 at 03:27 PM.
    Infinity or Bust

  3. #3
    Join Date
    2003/11
    Location
    Western WA, USA
    Posts
    1,148
    BTW, I notice that my C code init routine, RESET got inverted in the translation, here is the corrected version of the hardware reset portion:

    Code:
        LCD_CTRL(RESET, 0);     // assert hardware reset
        Sleep(1);
        LCD_CTRL(RESET, 1);     // de-assert reset
    sorry about that.
    Infinity or Bust

  4. #4
    Join Date
    2005/05
    Location
    new zealand
    Posts
    3

    more fonts

    are you able to post a few more fonts of say 12x12 and 10x10 also inthis thread ?

  5. #5
    Join Date
    2003/11
    Location
    Western WA, USA
    Posts
    1,148
    I don't have any fonts other than the 8x? and the 16x?. Note that the fonts are actually shorter than 8/16 because the inter-row spacing is included in the character cells (which makes for simple display writes). The whole point of the editor is that you can make the fonts whatever size you want within the limits of the editor array sizes. The height limit of 8x and 16x are purely for practical reasons of storing the result as byte lists and word lists. For graphic controllers with a 8 pixel page size, you'd also have to do a lot of byte shifts/rotates to accomodate odd font row heights, and I didn't want to go there.

    So if you want 10 or 12 pixel high fonts, just use the 16 pixel editor and leave blank rows at the top or bottom.
    Infinity or Bust

  6. #6
    Join Date
    2005/05
    Location
    Argentina
    Posts
    9

    Question regarding sed1565

    When you wrote grlcd_code.zip, what microprocessor speed were you using?
    Thanks.
    JuanWor

  7. #7
    Join Date
    2003/11
    Location
    Western WA, USA
    Posts
    1,148
    The assembler version of that code currently runs on two processors: a HC12B32 @ 8MHz, and a HC12C32 @ 24MHz.

    Of course the assembler code has some time-wasting added to meet minimum display timing requirements, which is not shown in the "C" code. For example:
    Code:
    gr_cmd	bclr LCD_CTRL LCD_A0	;select = cmd
    		LCD_OUT
    		bset LCD_CTRL LCD_E
    		nop
    #ifdef BUS24MHZ
    		nop
    #endif
    #ifdef KS1713
    		nop
    #endif
    		bclr LCD_CTRL LCD_E
    		rts
    So if your C complier does not produce bloated code, you may have to add some NOPs.
    Infinity or Bust

  8. #8
    Join Date
    2005/05
    Location
    Argentina
    Posts
    9

    Thanks, one more ...

    This is my write routine for controller sed1565 (PIC16f877), ccs compiler:
    Code:
    void Write_Display(UINT8 command, UINT8 datax)
    {
        UINT8 status = 0;
    
        /*Start BUS_RELEASE*/
        output_high(DISPLAY_WRITE);/*WR line*/
        output_high(DISPLAY_READ);/*RD line*/
        output_high(DISPLAY_A0);/*Command line*/
        /*End BUS_RELEASE*/
    
        /*LCD busy or reset?*/
        DIRECTION_8(INPUT_BUS);/*set port D as inputs*/
        output_low(DISPLAY_A0);/*CMD*/
        do
        {
            output_low(DISPLAY_READ);/*put RD to low*/
            NOP_CCS; /*asm NOP*/
            NOP_CCS;
            NOP_CCS;
            status = DATA_8;
            NOP_CCS;
            output_high(DISPLAY_READ);
        }while(status&BUSY_F);/*0x80?*/
    
        /*LCD ready to write*/
        DIRECTION_8(OUTPUT_BUS);
    
        /* Load the control signals and data for a particular command. */
        if(command == CMD)
            output_low(DISPLAY_A0);
        else
            output_high(DISPLAY_A0);
        /* Place the data on the bus. */
        DATA_8 = datax;
        NOP_CCS;
        output_high(DISPLAY_READ);
        output_low(DISPLAY_WRITE);
        NOP_CCS;
        output_high(DISPLAY_WRITE);
        NOP_CCS;
        /* After the microcontroller is finished, it will always release the bus to the display. */
        DIRECTION_8(INPUT_BUS);
        /*BUS_RELEASE*/
        output_high(DISPLAY_WRITE);
        output_high(DISPLAY_READ);
        output_high(DISPLAY_A0);
        /*End BUS_RELEASE*/
    }
    Im getting -9.5 V as LCD voltage reference level, it looks like the power ctrl command was taken by the LCD, however it never showed me any data. The write command to send data or commands is the same that I showed you above !!!
    Any advice or suggestion?
    JuanWor

  9. #9
    Join Date
    2005/05
    Location
    new zealand
    Posts
    3

    Display not showing any data

    You did not say if you actually turned ON the display... most LCD Display controllers require that you send a "Display ON" command before thay actually begin driving the display...

    eg: for the TL0313, i use:
    Code:
    (0xAE) Display Off                
    (0xC0) SHL Select                 
    (0xA0) ADC Select                 
    (0xA3) LCD Bias Select            
    (0x2C) Power Control              
    (0x2E)                            
    (0x2F)                            
    (0x27) Regulator Resistor Select  
    (0x81) Set Reference Voltage Mode
    (0x0C) Set Reference Resistor     
    (0xA6) Reverse Display On/Off     
    (0x40) Initial Display Line       
    (0xAF) Display On
    and for the PCF8548:
    Code:
    (0x00) many command bytes follow - see pcf8548 data sheet
    (0x29) Function Set => MX=0, MY=1 (Vertical Mirror), PD=0 (Chip Active), V=0 (Horizontal Addressing), H=1 (extended set command)
    (0x04) Temperature Coefficient 0
    (0x15) bias = 5
    (0x80) Vop  (Unused)
    (0x0C) DO=1 (LSB on Top), TRS=0 (top rows are not mirrored), BRS=0 (bottom rows are not mirrored)
    (0x28) Function Set => MX=0, MY=1 (Vertical Mirror), V=0 (Horizontal Addressing), H=0 (normal command set)
    (0x0C) Display control => D and E = 10 (normal lcd mode)  (01=all display segments on)  (11=inverse video mode)
    as you can see, Both LCDs require the LCD to be turned ON...
    --->>> check to see if your one does....

  10. #10
    Join Date
    2003/11
    Location
    Western WA, USA
    Posts
    1,148

    Re: Thanks, one more ...

    This thread is not really about helping folks with their code. This post should have gone into the general tech support forum.

    I will make a few suggestions, however.
    void Write_Display(UINT8 command, UINT8 datax)
    {
    .....
    /*Start BUS_RELEASE*/
    output_high(DISPLAY_WRITE);/*WR line*/
    output_high(DISPLAY_READ);/*RD line*/
    output_high(DISPLAY_A0);/*Command line*/
    /*End BUS_RELEASE*/
    It's not necessary to do this "bus release" here.
    /*LCD busy or reset?*/
    DIRECTION_8(INPUT_BUS);/*set port D as inputs*/
    output_low(DISPLAY_A0);/*CMD*/
    do
    {
    output_low(DISPLAY_READ);/*put RD to low*/
    NOP_CCS; /*asm NOP*/
    NOP_CCS;
    NOP_CCS;
    status = DATA_8;
    NOP_CCS;
    output_high(DISPLAY_READ);
    }while(status&BUSY_F);/*0x80?*/
    You could simplify this by putting the strobe outside the loop, like this:
    Code:
    DIRECTION_8(INPUT_BUS);/*set port D as inputs*/
    output_low(DISPLAY_A0);/*CMD*/
    output_low(DISPLAY_READ);/*put RD to low*/
    
    do
    {
         status = DATA_8;
    } while(status&BUSY_F);/*0x80?*/
    
    output_high(DISPLAY_READ);
    DIRECTION_8(OUTPUT_BUS);
    /* After the microcontroller is finished, it will always release the bus to the display. */
    DIRECTION_8(INPUT_BUS);
    /*BUS_RELEASE*/
    output_high(DISPLAY_WRITE);
    output_high(DISPLAY_READ);
    output_high(DISPLAY_A0);
    /*End BUS_RELEASE*/
    Why bother? The display is a slave and setting the bus to inputs will leave a high impedance state, which is not a good idea for CMOS inputs. Toss that section out.
    Im getting -9.5 V as LCD voltage reference level, it looks like the power ctrl command was taken by the LCD, however it never showed me any data. The write command to send data or commands is the same that I showed you above !!!
    Any advice or suggestion?
    You will need to post your init parameters in order to answer this.
    Infinity or Bust

  11. #11
    Join Date
    2005/05
    Location
    Argentina
    Posts
    9

    sed1565 initialization code

    Well, as it is code related Im putting my question on the general tech support forum. Please read it. Thanks and regards.
    JuanWor

  12. #12
    Join Date
    2005/11
    Location
    Bangalore, India
    Posts
    2

    Font Set

    Hi,

    Is there any script/tool, by which I coudl generate bitmap font sets. i.e., I'm looking for fonts for a LCD display device.

    I need to try out various bitmap fonts.
    Could you guide me on the same.

    Thanks & rgds
    nagaraj

  13. #13
    Join Date
    2003/11
    Location
    Western WA, USA
    Posts
    1,148
    The only suggestion I have is to download the file in the first post in this thread, and see if it does what you need. You will need a Windows PC to run it.
    Infinity or Bust

  14. #14
    Join Date
    2006/07
    Location
    ID
    Posts
    1

    SED1565 assembler code

    Would you be willing to provide the assembler source code (versus the C code) for your SED 1565 initialization, read/write routines? This is my first time working with an LCD, and I would prefer to stick with assembly language.

  15. #15
    Join Date
    2007/02
    Posts
    1

    Font Editor

    I'm having problems downloading your files. I cannot unzip them with Winzip. The program says that they are corrupted.

    Anyone else experiencing this?

    Thanks

  16. #16
    Join Date
    2001/03
    Location
    Spokane, Washington
    Posts
    4,092
    I just tested under FireFox 2 . . . seems to work fine.

  17. #17
    Join Date
    2005/05
    Location
    new zealand
    Posts
    3
    i just tested under IE7 with winzip 11 and it worked fine...

  18. #18
    Join Date
    2007/02
    Posts
    12
    I'm getting the "file corrupted" message also.

    IE6 and Winzip11.

  19. #19
    Join Date
    2001/03
    Location
    Spokane, Washington
    Posts
    4,092
    Sorry, it seems to be some IE vs Vb thing. Please just download FireFox:

    http://www.mozilla.com/en-US/firefox/

    it works fine then.

  20. #20
    Join Date
    2010/02
    Posts
    1

    Thanks!

    First, thanks for a great tool. It's saved me so much development time when making a character set for my graphical LCD project. Its so good I thought I'd try to give back...

    I've made a smaller font set based on your original font8 (I wanted enough room to put a box around the text in a 8 pixel high row for buttons). I also made a small C converter to PIC assembly tables as I don't use C in my microprocessor devices.

    The source file for the smaller font is here and a snapshot is available here.

    Once again thanks for a great tool.

  21. #21
    Join Date
    2010/02
    Posts
    3

    font editor and C code

    Nice simple looking product - but I'd like to also manage fonts over 16 pixels hi.

    Is a special version needed for this, or is the XY cell size somehow contained in the Binary Font File ?

    I can find no docs on the binary file, and it seems to have a simple preamble ?

    We want to do around 24x10 and 30x12, for printing, and larger titles.

    tia

  22. #22
    Join Date
    2003/11
    Location
    Western WA, USA
    Posts
    1,148
    The binary file is not documented explicitely, although I do remember that ages ago I posted the meaning of the preamble values somewhere. I will provide that info for you: (all 32 bit little endian)
    format indicator (to differentiate from an earlier version)
    number of chars (i.e. total array size)
    number of rows (either 8 or 16)
    number of columns (up to 16)
    ascii value of first char

    Yup, the program is simple, especially because the character cell size is limited to 16 x 16. This makes it easy to do everything as bytes and (short)words, especially in the output text file formatting. To handle larger cell sizes would require a bit of work, which I would not have any motivation to do for free.

    Maybe you can use this program:
    https://forum.crystalfontz.com/showthread.php?t=6382

    or google "bitmap font"
    Infinity or Bust

  23. #23
    Join Date
    2010/02
    Posts
    3
    Thanks for the format details.

    I've tried the DotFactory, useful, but it only masters from a Windows Font.

    I did find FontForge.MinGW worked OK on Windows, and that has good range of file
    supports, so I may use that, and do a .BDF massage-script to re-scramble the font into compilable form.

  24. #24
    mikelangelo11 Guest
    BitFontCreator is a professional Bitmap font creator tool for Windows, which allows you create and modify monochrome bitmap fonts that can be used in Windows and electronic devices (Mobil, phone, DVD player and any other LCDs). Also it can export bitmap data in various formats (Big/Little Endian, Row/Column based, Row/Column preferred, Packed or not, etc.) BitFontCreator Key Features: 1. Import fonts: Support all kinds of fonts installed on your Windows PC (True Type, Open Type, Adobe Type 1 and Raster fonts). 2. Edit Tools: Pencil, eraser, line, rectangle, Shifting tools, Invert, flip, and marquee selection.

  25. #25
    Join Date
    2010/02
    Posts
    3
    Thanks - interesting link.
    I like this idea
    ["Attention: Trial copy can only correctly generates data from 'A' to 'N',
    'a' to 'g' and '0' to '8'. To get all the correct data,
    please order and register BitFontCreator Pro first! "]

    So you can actually generate all the frameworks, in order to test the fonts.
    Price says $98 in some places, and $128 in others ?

  26. #26
    Join Date
    2003/11
    Location
    Western WA, USA
    Posts
    1,148
    NOTICE: The program attached in the first post of this thread has been superceeded by a much slicker version. If you have downloaded this version, you should switch to the new version here:
    https://forum.crystalfontz.com/showt...8164#post28164
    Infinity or Bust

  27. #27
    Join Date
    2011/05
    Posts
    1
    How does it work with asm. codes? MPLAB can't build the code. It gives this error message for both 16f887 and 18f2550 projects
    Illegal opcode (dc)

  28. #28
    Join Date
    2003/11
    Location
    Western WA, USA
    Posts
    1,148
    The assembler output is in Motorola hex format, and may not be compatible with Microchip software tools. As for the declaration of the font data, it might do you some good to read the CFE64 help file (which I spent a lot of time composing), because it contains the info you need to deal with your problem. I am assuming that the MPLAB assembler wants "db" for byte declarations, and "dw" for word declarations. If you look at the help file, from the "Code File Format" dialog, you will see the explanation about clicking on the double down-arrow button at the bottom of the Code File dialog. There, you are free to change the asm declarations from "dc" to "db", and "dc.w" to "dw" (or to whatever you want), and check the box to use those settings as the new default.
    Infinity or Bust

  29. #29
    Join Date
    2012/01
    Posts
    2
    Excellent program you made Cosmicvoid! I've been experimenting with it, and have succesfully made a character bitmap text file I can easily paste into my assembly. Now I want more, heh, sorry.

    Is there any way to have it load or import a .tga file? There is a free program out there called BM Font that can work with TrueType fonts, but it outputs files in .fnt or .tga type file.

    I'm trying to use the Courier New TrueType font in a project of mine.

    Anyway, thanks for the great program!

  30. #30
    Join Date
    2003/11
    Location
    Western WA, USA
    Posts
    1,148
    I'm assuming you've followed the links to the newest version, with the SFP font files I've bundled with it.

    I see that there are ways to convert .tga to other formats (like using zamzar), and many editors can handle it (like GIMP) and save in another format. But the bottom line is that my program is not designed to import any of those complex filetypes. Since I am not doing any development work that uses fonts these days, I have no motivation to add features to do those kinds of imports. Besides, I'm sure the TT fonts would exceed a 64x64 pixel size for all but the smallest point sizes; that would be too big for my editor.

    I'm guessing what you ultimately need is a way to convert the TT font into a bitmap format assembly declaration for a given point size. I can't help you there either, but I think I've seen some utilities that can load a Windoze font and dump off hex listings of the characters, maybe even referred to here on the CFA site, I just don't remember at the moment, sorry.
    Infinity or Bust

  31. #31
    Join Date
    2012/01
    Posts
    2
    I found eGUI from Freescale works great for bitmaps and fonts and it's free... Just thought I'd share what I've found.

  32. #32
    Join Date
    2012/11
    Posts
    2
    Gimp and XBM format do the trick for me

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •