Frage

I'm trying to write some piece of software that uses freetype2 to render some text.

However, the conditions under which I currently develop make it really difficult to supply the ttf fonts with my program. I was in a dead-end, but then I saw that freetype2 provides us with a FT_New_Memory_Face function, which loads a new face from memory.

The documentation of freetype2 states that I have to open a file, and load its contents somewhere in memory to use this. But again, that does not solve my problem. Is it possible to have something like a static buffer that will keep the data of a ttf file, and which I will be able to pass to FT_New_Memory_Face??? I'm thinking of sothing similar to how GIMP exports images as C source code.

I found 'font2c', which claims to do this (??), but whenever I try to load my TTF font file I get an error like this:

$ font2c Arial arial.c

Converting Arial font.
FontName is /Arial.
Error: /invalidfileaccess in --file--
Operand stack:
   --nostringval--   cfile   (arial.c)   (w)
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1910   1   3   %oparray_pop   1909   1   3   %oparray_pop   1893   1   3   %oparray_pop   1787   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1166/1684(G)--   --dict:0/20(G)--   --dict:84/200(L)--   --dict:52/100(L)--
Current allocation mode is local
Current file position is 20084
GPL Ghostscript 9.06: Unrecoverable error, exit code 1

What can I do???? Thanks in advance!

PS. Sorry for bad english, I'm not a native speaker

War es hilfreich?

Lösung

You can use the utility xxd (which is distributed as part of vim) with the -i option to convert a binary file into C source that will create an array containing the contents of that file.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top