Good to see you managed to load the font! I see you decided to go on with the user space renderer.
mrjbom wrote:Also, the position of the letter does not match the position specified during rendering
That's perfectly normal. Characters are drawn at their baseline, you have to take that into account. For example, pen_y is going to be the bottom most pixels for "A", but it is in the middle for "g".
Also you should pass a variable to "draw_glyph_lfb_mem", and then adjust that variable by glyph->adv_x to get the coordinate of the next character.
Read through the
SSFN API, it starts with explaining the font metrics. If something is not straigtforward in the doc, please let me know and I'll add more explanations. Glyphs are scaled to their natural sizes. To scale the full glyph's size, use SSFN_STYLE_ABS_SIZE to style parameter (stands for absolute size). Note that with absolute size you'll get odd sized glyphs for "A" and "g" relative to each other, as the overall bounding box will be scaled.
mrjbom wrote:What am I doing wrong?
Not entirely sure, I need more information to help you. I see you don't use the ALPHA rendering, which is the prefered way (you fill up a box with a desired color, then you simply copy the alpha channel from the glyph, and voilá, you have an anti-aliased pixel map which you can blit as any other image). Just a suggestion, using bitmap is fine too.
From the picture it looks like your font has incorrect height set (or just as well could be right for 64 pixels, as many fonts has "tails" going beneath the baseline, however looks a bit too high). I'd suggest to print out the glyph's width, height and baseline values to see if they're correct. Not sure what font you're using. Dumping the font is very helpful. It will also do some very through verification, and it will warn you if some metrics are incorrectly set by any chance (like baseline is bigger than height for example). You can tweak those properties using command line options to the converters. Also if you see any problem, then you can fix the font easily: use sfn2asc to convert it into a text file. Then you can edit the font with a plain text editor, and check if you have an extremely high glyph that makes the entire font that high. Then use bit2sfn that will convert the text version back into binary (or use the correct options when converting).
Take a look at the aforementioned sfntest directory, there are many examples there both for simple renderer and user space renderer, and also for bitmap and vector fonts too. The fonts directory has some
example fonts. First try those, and only use your own font once your code is working perfectly with the fonts in the repo. This way you can rule out if the problem is with your code or with the font itself.
For example, unifont.sfn.gz and u_vga16.sfn are a bitmap fonts, usable by ssfn_putc and ssfn_render both. FreeSans.sfn.gz is a vector font, converted from FreeSans.otf, known to have correct metrics. You can render this into a bitmap of a certain size using ssfn_render (but ssfn_putc can't use it as its not a bitmap font).
You can use
sfntest1.c to see how to use ssfn_putc.
sfntest2.c uses the user space renderer. Try to pass your FSfont.sfn font to these on the command line. If there's something wrong with your font metrics, you'll see.
Cheers,
bzt