c - 将 ttf 字体导出为 C 源代码

标签 c ghostscript truetype freetype

我正在尝试编写一些使用 freetype2 来呈现一些文本的软件。

但是,我目前的开发条件使得我的程序很难提供 ttf 字体。我陷入了困境,但后来我看到 freetype2 为我们提供了一个 FT_New_Memory_Face 函数,它可以从内存中加载一张新面孔。

freetype2 的文档指出我必须打开一个文件,并将其内容加载到内存中的某个位置才能使用它。但同样,这并不能解决我的问题。是否有可能有一个类似静态缓冲区的东西来保存 ttf 文件的数据,并且我可以将其传递给 FT_New_Memory_Face???我正在考虑类似于 GIMP 如何将图像导出为 C 源代码的事情。

我发现“font2c”,它声称可以做到这一点(??),但每当我尝试加载我的 TTF 字体文件时,我都会收到如下错误:


$ 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

我能做什么??? 提前致谢!

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

最佳答案

您可以使用实用程序 xxd(作为 vim 的一部分分发)和 -i 选项将二进制文件转换为 C 源代码,从而创建数组包含该文件的内容。

关于c - 将 ttf 字体导出为 C 源代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17189409/

相关文章:

image - OpenCV:如何将 HERSHEY 以外的其他字体与 cvPutText(如 Arial)一起使用

html - @font-face 正在上传不能应用于我的元素的字体

c - 如何设置最小和最大窗口大小

wolfram-mathematica - 如何在 Mathematica 中将 .eps 文件转换为 .pdf?

latex - Ghostscript 9.07 : Error: A pdfmark destimation . ..点超出最后一页

pdf - 如何将 PDF 转换为低分辨率(但质量良好)的 JPEG?

java - 性能: How are font files usually interacted with?

c - 我需要编写一个利用 ASCII 列出字母表的程序

javascript - 创建密码扰码器

无法打开包含文件 : 'arpa/inet.h' :