Page 1 of 1

additional font types for openvg C/C++ ?

Posted: Sun Nov 01, 2015 10:37 pm
by davenull
hey,
are there additional font types for openvg C/C++ available ?
e.g.,
Zapfdingbats / Windings,
Symbol,
Greek alphabet,
EnglandHand or either handwriting font type,
7-segment LED,
:?:

Re: additional font types for openvg C/C++ ?

Posted: Thu Nov 05, 2015 8:53 am
by davenull
not possible to have additional fonts except Sans, Serife, and Monospace?

instead, how can one integrate / import more fonts from external sources?

Re: additional font types for openvg C/C++ ?

Posted: Thu Nov 05, 2015 9:01 am
by AndyD
Hi @davenull. As you are using ajstarks' library (or Paeryn's version of it) there is information about using other fonts in the documentation. It appears that you can use any TTF font.

Re: additional font types for openvg C/C++ ?

Posted: Thu Nov 05, 2015 9:15 am
by davenull
are these the same fonts like I am already using for Windows?

Re: additional font types for openvg C/C++ ?

Posted: Thu Nov 05, 2015 9:19 am
by AndyD
Yes they usually have the extension ttf. Google has a large collection.

Re: additional font types for openvg C/C++ ?

Posted: Thu Nov 05, 2015 9:41 am
by davenull
I have a lot of fonts on my Windows PCs :)

so given I wish to import
symbol.ttf
- I really don't understand what to do for openvg nevertheless. (Sorry, my English is too poor and Google translate is messing everything up.)

copy symbol.ttf into which Raspi directory ?

then how to include it into openvg font libs together with the 3 existing by which command,
so that it can be accessed from proprietary programs by the same way as the 3 existing ones?

these instructions as much to sink a ship tell me nothing, unfortunately... :-/
./font2openvg /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf DejaVuSans.inc DejaVuSans
and include the generated code in your program:
#include "DejaVuSans.inc"
Fontinfo DejaFont
The loadfont function creates OpenVG paths from the font data:
loadfont(DejaVuSans_glyphPoints,
DejaVuSans_glyphPointIndices,
DejaVuSans_glyphInstructions,
DejaVuSans_glyphInstructionIndices,
DejaVuSans_glyphInstructionCounts,
DejaVuSans_glyphAdvances,
DejaVuSans_characterMap,
DejaVuSans_glyphCount);

Re: additional font types for openvg C/C++ ?

Posted: Thu Nov 05, 2015 9:46 am
by AndyD
OK sorry I really don't know. I haven't used OpenVG much. I would assume once you loaded the Font you text will use that font until you load another.

Re: additional font types for openvg C/C++ ?

Posted: Thu Nov 05, 2015 5:29 pm
by Paeryn
davenull wrote:I have a lot of fonts on my Windows PCs :)

so given I wish to import
symbol.ttf
- I really don't understand what to do for openvg nevertheless. (Sorry, my English is too poor and Google translate is messing everything up.)

copy symbol.ttf into which Raspi directory ?

then how to include it into openvg font libs together with the 3 existing by which command,
so that it can be accessed from proprietary programs by the same way as the 3 existing ones?

these instructions as much to sink a ship tell me nothing, unfortunately... :-/
./font2openvg /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf DejaVuSans.inc DejaVuSans
and include the generated code in your program:
#include "DejaVuSans.inc"
Fontinfo DejaFont
The loadfont function creates OpenVG paths from the font data:
loadfont(DejaVuSans_glyphPoints,
DejaVuSans_glyphPointIndices,
DejaVuSans_glyphInstructions,
DejaVuSans_glyphInstructionIndices,
DejaVuSans_glyphInstructionCounts,
DejaVuSans_glyphAdvances,
DejaVuSans_characterMap,
DejaVuSans_glyphCount);
There is a program that is compiled in the openvg (or openvg-master whichever was created when you unzipped the library) directory of libshapes called font2openvg this is the program that converts the .ttf file into an .inc file.
Let's say libshapes directory is ~/openvg, your program sourcecode is in ~/myprog, the font you want is called MyFont.ttf and is in ~/myfonts and you are currently in ~/myprog

Code: Select all

pi@raspberrypi ~/myprog $ ~/openvg/font2openvg ~/myfonts/MyFont.fft MyFont.inc MyFont
Should create a file called MyFont.inc that can be included in your program and loaded with

Code: Select all

#include "MyFont.inc"

FontInfo myfont;

myfont = loadfont(MyFont_glyphPoints, 
        MyFont_glyphPointIndices, 
        MyFont_glyphInstructions,                
        MyFont_glyphInstructionIndices, 
        MyFont_glyphInstructionCounts, 
        MyFont_glyphAdvances,
        MyFont_characterMap, 
        MyFont_glyphCount);
Use it just like the DejaVu fonts.

Re: additional font types for openvg C/C++ ?

Posted: Thu Nov 05, 2015 5:40 pm
by davenull
mhm, does that mean I do have to write all the stuff always in my program?

#include "MyFont.inc"

FontInfo myfont;

myfont = loadfont(MyFont_glyphPoints,
MyFont_glyphPointIndices,
MyFont_glyphInstructions,
MyFont_glyphInstructionIndices,
MyFont_glyphInstructionCounts,
MyFont_glyphAdvances,
MyFont_characterMap,
MyFont_glyphCount);

is it not possible to install the fonts once and for all?
To have the new fonts (e.g., symbol.ttf or Windings.ttf) always available for my programs, from the start, out of the box, as if I wanted to use e.g., MonoTypeface , just by
Text(x, y, buf, MonoTypeface, 20);
Text(x, y, buf, symbol, 20);
Text(x, y, buf, SansTypeface, 20);
Text(x, y, buf, Windings, 20);
Text(x, y, buf, SerifeTypeface, 20);
simply as I always may use different ttf fonts in Windows when they once have been istalled :?:
either in which working folder my .c file is in, always having all fonts at 1 place like the preinstalled ones :?:

Re: additional font types for openvg C/C++ ?

Posted: Thu Nov 05, 2015 7:22 pm
by Paeryn
You could write a modified version of font2openvg into your program so that instead of writing out C code it generates the arrays directly and passes them to loadfont().

Re: additional font types for openvg C/C++ ?

Posted: Fri Nov 06, 2015 8:19 am
by davenull
no, sorry, I don't even understand what all the current functions and all the libs are actually doing ... :oops:
I'm just using the C functions like I use Microsoft Word to write and format a text, of course no clue about how Word or Windows are working underneath... :roll:

Re: additional font types for openvg C/C++ ?

Posted: Fri Nov 06, 2015 11:07 am
by Paeryn
No promises as to when but I might have a go at putting it in myself since it could be useful to dynamically load fonts as needed.

Re: additional font types for openvg C/C++ ?

Posted: Fri Nov 06, 2015 12:11 pm
by davenull
+1
(y)

Re: additional font types for openvg C/C++ ?

Posted: Sun Nov 08, 2015 1:28 am
by jannewmarch
See the chapter "Text processing in OpenVG" at https://jan.newmarch.name/RPi/OpenVG/Text/ in my "RPi GPU" ebook at https://jan.newmarch.name/RPi/

Re: additional font types for openvg C/C++ ?

Posted: Sun Nov 08, 2015 8:22 am
by davenull
could you pleasee be a more specific and detailed about your references?