4
\$\begingroup\$

Friends,

How can I make a font for graphical LCD ? I saw some font library and loop ...but I don't know exactly how to use it ?

Anyone has experience and reference ? I mean, similar to this function, I must try to display from character first before I display one word or one sentence, enter image description here

Example of A in HEX :

uchar code AsciiLib[] = {
/* A */
    0x00,0x00,0x00,0x10,0x10,0x28,0x28,0x28,0x28,0x7C,0x44,0x44,0xEE,0x00,0x00,0x00,
}

I tried to create one function, please correct if it's not right :

#define uchar unsigned char 
#define uint unsigned int

void DrawSingleAscii(uint x, uint y, uchar *pAscii, uint LineColor,uint FillColor, uchar Mod)
    {
        uchar i, j;
        uchar str;
        uint OffSet;

        OffSet = (*pAscii - 32)*16;

        for (i=0;i<16;i++)
        {
            Set_ramaddr(x,y+i);
            send_command(0x22);
            str = *(AsciiLib + OffSet + i);  
            for (j=0;j<8;j++)
            {
                if ( str & (0x80>>j) )     //0x80>>j
                {
                    send_data((uint)(LineColor&0xffff));
                }
                else
                {
                    if (NORMAL == Mod) 
                        send_data((uint)(FillColor&0xffff));
                    else
                    {
                        Set_ramaddr(x+j+1,y+i);
                        send_command(0x22);  
                    }
                }               
            } 
        }
    }

Do you have example in function on how to display it ? I'm using C

Thanks a lot

\$\endgroup\$
1
  • \$\begingroup\$ I don't know, but once I had to fix some fonts that were meant to be used in an LDC graphical display, and they were bitmap fonts, not vector. \$\endgroup\$
    – clabacchio
    Commented Mar 30, 2012 at 6:09

1 Answer 1

9
\$\begingroup\$

If you are asking how to make a font, there are a number of utilities out there. Here are a few:

  • DotFactory is simple, free, and does a good job converting existing font files to C code.

  • BitFontCreator is a low cost tool with a graphical font editor, you can convert and edit existing fonts or draw your own fonts and symbols. Very versatile. I like it and I've used it a lot.

  • NXP offers a free version of the high end Segger GUI tools for use with their ARM processors. It includes a font editor. There is a download link on this page.

If you are asking how to use a font library, that is hard to answer without more details. In general terms, the font tools produces a big array that contains the pixel position for all the characters in the font. It also makes a jump table that tells you where each individual character starts within the big array and how wide it is. When you know the height of the font, it is fairly straightforward (depending on your experience) to pick out the data for individual characters and draw them on the display.

If you are new to this it is best to start out with working example code and spend some time understanding how it works.

EDIT: The microbuilder codebase has example code to get you started.

\$\endgroup\$
7
  • \$\begingroup\$ I have the array already, and wondering how to use it ? \$\endgroup\$
    – Rick Ant
    Commented Mar 30, 2012 at 7:42
  • \$\begingroup\$ do you have example code for displaying character "A" in hex using C ? \$\endgroup\$
    – Rick Ant
    Commented Mar 30, 2012 at 7:45
  • 1
    \$\begingroup\$ @Rick Ant - what has hex to do with it? "A" is a character. \$\endgroup\$
    – Martin
    Commented Mar 30, 2012 at 7:46
  • \$\begingroup\$ @RickAnt Added a pointer to example code. \$\endgroup\$
    – morten
    Commented Mar 30, 2012 at 10:43
  • \$\begingroup\$ Here's the hex of "A" : 0x00,0x00,0x00,0x10,0x10,0x28,0x28,0x28,0x28,0x7C,0x44,0x44,0xEE,0x00,0x00,0x00, how can I make a pointer of it ? do you have an example of function, on how to display it ? \$\endgroup\$
    – Rick Ant
    Commented Mar 31, 2012 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.