barons2015 / glcd-arduino

Automatically exported from code.google.com/p/glcd-arduino
0 stars 0 forks source link

Provide info about the font height #34

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Please provide a procedure 

void gText::GetFontHeight(void)

{
    if(this->Font == 0)

        return 0; // no font selected

 return (FontRead(this->Font+FONT_HEIGHT)+1);
}

And maybe also a corresponding GetFontWidth() procedure

Original issue reported on code.google.com by olikr...@gmail.com on 20 Jun 2011 at 8:40

GoogleCodeExporter commented 8 years ago
it is more an enhancement request...

Original comment by olikr...@gmail.com on 20 Jun 2011 at 8:41

GoogleCodeExporter commented 8 years ago
Not sure yet how to best provide font width/height functions.
There is also a potential need for something like CharHeight() function
as well.

To be consistent with the current CharWidth() function, these functions
will more than likely include any inter row/character pad pixels so that
they indicate the size of the character when rendered on the display.

Original comment by bperry...@gmail.com on 30 Jun 2011 at 10:20

GoogleCodeExporter commented 8 years ago
at the moment i had to hard-code the font height (see 
http://code.google.com/p/m2tklib/source/browse/dev/glcd/m2ghglcdutil.cpp)

to my investigation the system5x7 has 8 pixel height and the arial14 is 16 
pixel height.

It would be nice to have a procedure for this.

Original comment by olikr...@gmail.com on 30 Jun 2011 at 3:28

GoogleCodeExporter commented 8 years ago
I saw your library and saw the hard coded functions for font sizes and was 
about to add an enhancement issue for the glcd library as it is probably a 
useful function, when I saw your added issues.

Currently, the rendering adds 1 pixel to the bottom and 1 pixel to right of any 
character data. In the future it might be possible to configure this padding 
which would be useful for things like a code page 437 graphic font.

The arial14 font is actually rendered 15 pixels in height.

Something like GetFontWidth() is much trickier because it only really makes 
sense on fixed width
fonts. For variable width fonts there is no single width.
The DefineArea() functions uses the width of the widest character in its
calculations. Not great, but kind of works.

Currently, there is a function to return the width of a given character through.
CharWidth() and then there is StringWidth() which will return the width of the 
entire string.

Original comment by bperry...@gmail.com on 30 Jun 2011 at 6:03