Text

The Little Vector Library works with True Type Fonts. First a little introduction. A "font family" is a collection fonts such as "Arial bold 24pt", "Arial regular 32pt" and so on. A "font" is a particular instance of this such as "Arial bold 32pt".


You can give the library more fonts to work with by sending it the bytes from a TTF file. We have created the function createFromBytes(..) to make this easy. For example to add the "Impact" font:


//first get bytes from impact.tff file or resource

LVL.Fontfamily impactFont = LVL.Fontfamily.createFromBytes("impact", bytes);
LVL.Font impact25 = new LVL.Font(impactFont, 25.0f);
LVL.Brush brush = new LVL.SolidBrush(LVL.Color.Blue);
graphics.DrawString("Hello world!", brush, impact25, ....)

There is also an additional StrokeString(..) to draw text outlines with a given pen.

You can also set the default "sans", "sans serif" and "monospace" fonts to your newly created font familes:

LVL.Fontfamily.genericSansSerif = myFontFamily1;
LVL.Fontfamily.genericSerif = myFontFamily2;
LVL.Fontfamily.genericMonospace = myFontFamily3;

Since the Little Vector Library doesn't contain any fonts itself, you must supply at least one font in order to display text.

1 comment: