如何使用bin2h?

编程入门 行业动态 更新时间:2024-10-23 01:55:51
本文介绍了如何使用bin2h?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图使用 bin2h 转换字体文件(font.ttf)成C文件,但它不会工作。

I'm trying to use bin2h to convert a font file (font.ttf) into a C file but it won't work.

有人可以告诉我的语法将输出保存到文本文件?

Can someone please tell me the syntax to save the output to a text file?

我一直在试图找出这一点,但没有什么工作,它的驾驶我疯了。我真的很沮丧,因为我知道这个工具也是工作(我得到了它像一年前的工作),但我不记得我是如何使用的。

I've been trying to figure this out but nothing is working, and it's driving me insane. I'm really frustrated because I know the tool is working (I got it to work like a year ago) but I can't remember how I used it.

在该网站上的例子语法并不能真正帮助...

The example syntax on that site doesn't really help...

由于亮度种族在轨道的评论下面我终于得到了语法正确的!

Thanks to Lightness Races in Orbit's comment below I finally got the syntax right!

bin2h -CZ字体< font.ttf> output.h

bin2h -cz font < font.ttf > output.h

这是工作,谢谢

推荐答案

也许你正在寻找在网站上使用的例子,并没意识到这是你的shell执行程序?这不是C code的一条线。

Perhaps you are looking at the usage example on the website and not realising that it is a program that you execute from shell? It is not a line of C code.

所以,如果你想使用这个从C程序,你需要通过函数如系统能够执行或 EXEC 。然而,由于其输出是C code的一条线,你会更好,从构建脚本中运行它的 的创建C脚本,你会再链接到其余的程序的。

So if you want to use this from a C program, you will need to execute it through a function like system or exec. However, since its output is a line of C code, you'd be better off running it from within your build script to create a C script, that you'd then link in to the rest of your program.

#include <iostream> #include "eula.h" int main() { std::cout << std::string(eula, eula_size) << std::endl; }

构建命令

$ bin2h -cz eula < eula.txt > eula.h $ g++ main.cpp -o myProgram

执行命令

$ ./myProgram

更多推荐

如何使用bin2h?

本文发布于:2023-10-09 06:16:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1474929.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   bin2h

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!