davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

additional font types for openvg C/C++ ?

Sun Nov 01, 2015 10:37 pm

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,
:?:
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

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

Thu Nov 05, 2015 8:53 am

not possible to have additional fonts except Sans, Serife, and Monospace?

instead, how can one integrate / import more fonts from external sources?
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
AndyD
Posts: 2334
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

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

Thu Nov 05, 2015 9:01 am

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.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

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

Thu Nov 05, 2015 9:15 am

are these the same fonts like I am already using for Windows?
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
AndyD
Posts: 2334
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

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

Thu Nov 05, 2015 9:19 am

Yes they usually have the extension ttf. Google has a large collection.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

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

Thu Nov 05, 2015 9:41 am

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);
Last edited by davenull on Thu Nov 05, 2015 9:48 am, edited 1 time in total.
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
AndyD
Posts: 2334
Joined: Sat Jan 21, 2012 8:13 am
Location: Melbourne, Australia
Contact: Website

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

Thu Nov 05, 2015 9:46 am

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.

User avatar
Paeryn
Posts: 2952
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

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

Thu Nov 05, 2015 5:29 pm

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.
She who travels light — forgot something.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

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

Thu Nov 05, 2015 5:40 pm

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 :?:
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
Paeryn
Posts: 2952
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

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

Thu Nov 05, 2015 7:22 pm

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().
She who travels light — forgot something.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

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

Fri Nov 06, 2015 8:19 am

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:
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

User avatar
Paeryn
Posts: 2952
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

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

Fri Nov 06, 2015 11:07 am

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.
She who travels light — forgot something.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

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

Fri Nov 06, 2015 12:11 pm

+1
(y)
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

jannewmarch
Posts: 40
Joined: Thu Jan 17, 2013 12:45 am

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

Sun Nov 08, 2015 1:28 am

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/

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

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

Sun Nov 08, 2015 8:22 am

could you pleasee be a more specific and detailed about your references?
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

Return to “OpenVG”