Have you seen this:
I was looking at this project for ideas and I noticed he has a good explaination of the font format.
Have you seen this:
I was looking at this project for ideas and I noticed he has a good explaination of the font format.
@Bko Good find. There are some great tips in that article on Exporting fonts in GLCD format. Hopefully it helps @peekay123 out some
Sweet bko! I will absolutely look at that. Thanks!
@peekay123 I can also try the updated library on Arduinoās I just need to know where to put the code needed to switch over to the newly added fonts.
I assume that you define the font you want to use at the top of the program code but Iām not 100% sure. Once I know how Iām supposed to pick which font I want to use Iāll start testing it out on my side and see if I am getting the same results.
Really exited to see this working since it would allow me to make the screen look any way I could imagine it. I know how to make bitmap images and animations so the only thing left to figure out is how to use any font I have available on my computer. Iām ready to put these Sharp Memory Displays to good use
@RWB, using an arduino does not change anything. There are a few things to change to get things going:
const unsigned char yourfont[] PROGMEM = { arrary... };
#define GFXFONT_GLCD 0
#define GFXFONT_GLCD_ASCII 1
#define GFXFONT_FONTNAME 2 - ADD AN INDEX FOR EACH NEW FONT
extern const unsigned char glcdFont;
extern const unsigned char glcdFont_ascii;
extern const unsigned char fontname; - ADD DECLARATION FOR EACH NEW FONT
Finally, in Adafruit_GFX.cpp, you need to add a bit of code:
Adafruit_GFX::Adafruit_GFX(int16_t w, int16_t h):
WIDTH(w), HEIGHT(h)
{
_width = WIDTH;
_height = HEIGHT;
rotation = 0;
cursor_y = cursor_x = 0;
textsize = 1;
textcolor = textbgcolor = 0xFFFF;
wrap = true;
//setFont(GFXFONT_GLCD_ASCII); // THESE LINES SELECT THE DEFAULT FONT
//setFont(GFXFONT_GLCD);
setFont(GFXFONT_YOUFONT);
}
void Adafruit_GFX::setFont(uint8_t f) {
font = f;
switch(font) {
case GFXFONT_GLCD:
fontData = glcdFont;
fontKern = 1;
break;
case GFXFONT_GLCD_ASCII:
fontData = glcdFont_ascii;
fontKern = 1;
break;
case GFXFONT_YOURFONT: // ADD A CASE STATEMENT FOR EACH NEW FONT
fontData = yourfont;
fontKern = 1;
break;
default:
font = GFXFONT_GLCD;
fontData = glcdFont;
fontKern = 1;
break;
}
And that should do it! If I can get a darn font working, I'll post everything on my github.
@peekay123 Thank you very much! Iāll give it a shot and report back.
I spent alittle bit today trying to get it up and working but I donāt have a good understanding of how I should rig up the code to get it all work together. Iām short on time also with other work I have to going on but I really want to get this working.
I was trying to generate a GLCD font library by using http://www.mikroe.com/glcd-font-creator/
I was specifically trying to create a library out of the Agency FB Font in 11 Size. Iām just getting confused on where to put the font width and height numbers so the new code knows how to correctly display the new larger font.
If you can get it working Iāll give ya $200 and you pick out what you want and Iāll have it mailed to you. I which I had more time to try to figure it out but I donāt right now.
I also emailed the guy who wrote that Font Article that @BKO posted to see if he might be able to help out.
@BDub @BDub1 You still around? Can you make any sense of this?
RWB, if I get this working you can donate the $200 to a charity.
@RWB, so I got things working after realizing the code has major flaws! I even loaded your font but there are problems. Because the code assume fixed font sizes, the spacing on the fonts looks way to large. Normally, you would have per-character spacing data to do spacing properly but no such luck.
I found another (older) library for the Sharp Memory display that DOES uses font metrics. I may be able to adapt the code to the Adafruit_GFX library though it may take some time. Or I could simply port that library and use it instead. Your thoughts?
So very busy! Sorry buddy 12:30am time to sleep before I feel like crap again tomorrow for staying up til 1am last night.
@peekay123 Yea man you get this problem solved for me and I'll send the $200 where ever you want it to go
So it works except for the font spacing? Or it has more issues than that?
Yea I'm all for what ever works. Would we be able to use multiple fonts with this other option? I have plenty of memory to work with so thats not a problem.
Yup, you could use TheDotFactory to port any TrueType font
@RWB, I think I figured out a way to easily adapt the Adafruit library with an extra table per font to do it. I will try and work on it today and get back to you. I will test with your desired font.
@peekay123 Excellent!
@RWB, GOT IT WORKING!!! The original code was a mess and had to rewrite it. Before I post the code, can you tell me the following:
I am testing on a 320x240 color LCD. I loaded Agency_FB 11point and it loses details at the 11pt size.
@peekay123 Thatās Awesome! Iām excited!
The screen Iām using is 400 x 240 pixels. The smaller Memory LCD Iāll be using is 128 x128 Pixels if it matters.
Iām not 100% sure which fonts I will want to us just yet, I planned on just testing the ones I like until I find something that looks good with that Iām doing. The Agency FB is a good font though.
Do you think it will be easy to just download and convert different fonts at different sizes to test out or is it more complicated than that?
I have no idea what the 11pt font size would look like on this screen so I have no idea what size fonts Iāll be wanting to use until I can test them out.
Keep up the good work over there!
@RWB, the way the library works is you select the font to use. Then you can specify the size which essentially enlarges the font vertically and horizontally by the size. This is ok up to a point where it gets quite pixelated. The other problem is though AgencyFB looks good on a monitor, it doesnāt look so good when converted, especially on a lower resolution screen. On low res screen, smaller fonts look best, even when scaled a bit.
When I post the code, I will have a few fonts defined. Adding fonts is not too difficult but there are some tricks. I will post a how to soon as well.
So if I use the GLCD software to create a font that is sized 9x15 pixels will it display on the screen with the exact same pixel layout as seen in the GLCD font creator software screenshot below:
Or is it using a smaller sized font and then trying to expand up to the larger sizes? Kinda like how the stock Adafruit library increases font size by 1, 2, 3, ect⦠?
I plan on just storing a small and a large font array so no up or down sizing needs to happen and the fonts look like they should.
Finding the font that looks just right will probably be a full days work but well worth it to get something that looks cool.
So this is based on the Adafruit GFX library? So many other people will be able to also follow along? If so Iām sure many people will put this to use considering there are no other alternatives.
@RWB the GLCD software does not produce the correct files bot TheDotFactory does. However, it doesnāt allow you to edit the pixel. It only converts existing ttf fonts.
I checked out TheDotFactory and many people seem to like it. It hasnāt been updated in a few years but as long as it works who cares.
I like how it creates super slim font arrays and uses per character spacing.
Go Peekay Go!!!