如何使用bin2h? [英] How to use bin2h?

查看:301
本文介绍了如何使用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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆