in my program I use Text() replacement for font kerning and outputting Unicode glyphs. Fonts are handled through diskfont.library/bullet.library routines. As the bullet.library doesn't seem to support underlining (and for other reasons) I need to find the baseline of font. The query seems to fail, while other type of query works ok. Here is VBCC/GCC compilable example:
Code: Select all
/* outline font baseline test */
/* gcc testolfont.c -o ram:test -lauto */
#include <stdio.h>
#include <proto/exec.h>
#include <proto/diskfont.h>
#include <diskfont/diskfonttag.h>
#include <diskfont/oterrors.h>
STRPTR fname = "Dejavu Sans Mono.font";
uint32 devdpi = 72<<16|72;
uint32 ptheight = 16;
//struct DiskfontIFace *IDiskfont;
int main()
{
struct OutlineFont *olfont;
olfont = IDiskfont->OpenOutlineFont(fname,NULL,OFF_OPEN);
if (olfont)
{
if (!IDiskfont->ESetInfo(&olfont->olf_EEngine,OT_DeviceDPI,devdpi,OT_PointHeight,ptheight << 16,TAG_END))
{
printf("Font %s point height %lu opened successfully!\n",fname,ptheight);
{
int Ascend, Descend;
ULONG BaseLine,NumGlyphs;
if (!IDiskfont->EObtainInfo(&olfont->olf_EEngine,OT_BaseLine, &BaseLine, TAG_END) && ((BaseLine & 0xffff0000) != 0))
{
Ascend = BaseLine >> 16;
Descend = BaseLine & 0xffff;
printf("Font ascend %d, descend %d\n",Ascend,Descend);
}
else
{
printf("Couldn't get font baseline data!\n");
}
if (!IDiskfont->EObtainInfo(&olfont->olf_EEngine, OT_NumGlyphs, &NumGlyphs, TAG_END))
printf("The font contains %lu glyphs\n", NumGlyphs);
else
printf("The font engine does not support OT_NumGlyphs\n");
}
IDiskfont->CloseOutlineFont(olfont,NULL);
}
}
return(1);
}
The OT_BaseLine seems to return always 0, but the font seems to have ascender/descender data as show by TypeManager. Why? The example is modified from diskfont/diskfonttag.h.
Marko