如何将 .svg 文件转换为字体? [英] How can I convert .svg files to a font?

查看:237
本文介绍了如何将 .svg 文件转换为字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 .svg 文件转换为字体?是否有任何 API 或可编程方法?

How can I convert .svg files into a font? Is there any API or programmable method?

推荐答案

我在 Stack Overflow 上找到了两个相关的答案:

I found two relevant answers here on Stack Overflow:

  1. 使用矢量软件(即inkscape)和 fontforge 创建图标字体?
  2. 将 svg 转换为 ttf 的工具 [关闭](存档自此已删除的 SO 问题)
  1. Creating icon fonts with vector software (i.e. inkscape) and fontforge?
  2. Tools to convert svg to ttf [closed] (archived from this deleted SO question)

不幸的是,这两者都不是真正的编码答案,这正是我真正希望的(用于脚本转换的命令行实用程序,或者可能是有人可以编写此类内容的 API).

Unfortunately, neither is really a coding answer, which is what I had really hoped for (a command line utility for scripted conversion or perhaps an API with which somebody could write such a thing).

不过,通过结合这两个答案,我得到了我想要的东西.

Still, I got what I was looking for by combining those two answers.

(此步骤可能是可选的.) 在免费软件程序中打开您的 SVG InkScape.复制现有的 SVG 并从 FontForge Glyph 模板创建一个新项目.粘贴到该模板中,标准化外观、大小和位置,然后另存为 PLAIN SVG,每个字符一个文件(字形").

(This step might be optional.) Open up your SVG in the free software program InkScape. Copy the existing SVG and create a new project from the FontForge Glyph template. Paste into that template, standardize the look, size, and position, and save as PLAIN SVG, one file per character ("glyph").

然后,要么直接使用免费软件程序 FontForge(按照第一个答案中的指示), 使用矢量软件创建图标字体)或者使用免费的 IcoMoon 在线服务(如第二个答案中所述,将 svg 转换为 ttf 的工具).我做了后者.

Then, either use the free software program FontForge directly (as directed in the first answer, creating icon fonts with vector software) or else use the free IcoMoon online service (as directed in the second answer, tools to convert svg to ttf). I did the latter.

IcoMoon 是一个相当简单的工具.单击页面顶部的紫色导入图标按钮以导入您的每个自定义 SVG 字形.然后点击获取信息"在集合的首选项上,因此您可以命名集合并为其提供一些元数据.使用编辑"工具(铅笔图标)并点击每个字形以调整大小和间距.

IcoMoon is a rather straightforward tool. Click the purple Import Icons button on the top of the page to import each of your custom SVG glyphs. Then click "Get Info" on the set's preferences so you can name the set and give it some metadata. Use the "Edit" tool (the pencil icon) and click on each glyph to get the sizing and spacing just right.

完成后,选择字体中所需的所有字形,然后按生成字体"按钮.页面底部的按钮.在生成的屏幕上,您可以将每个字形映射到一个 unicode 字符.在右侧,您可以键入或粘贴一个字符,或者在左侧,您可以输入其十六进制代码.像 GNOME Character Map(适用于 Linux)或 Windows 字符映射Mac OS Character Palette 可以帮助您为您的字形找到合适的代码.

When you're done, select all of the glyphs you want in the font and then press the "Generate Font" button at the bottom of the page. On the resulting screen, you can then map each glyph to a unicode character. On the right side, you can type or paste a character, or on the left side, you can enter its hexadecimal code. A program like GNOME Character Map (for Linux) or Windows Character Map or Mac OS Character Palette may help you find appropriate codes for your glyphs.

现在按首选项"按钮(或右下角的齿轮)并完成新字体的名称和元数据,然后按下载"在右下角.您将获得一个 Fontname.zip 文件,其中包含大量使用建议以及字体文件本身.

Now press the "Preferences" button at the top of the screen (or the gear at the bottom right) and finalize the name and metadata of your new font and press the "Download" at the lower right. You'll get a Fontname.zip file that contains a bunch of usage suggestions as well as the font files themselves.

我发现尺寸和间距真的很难正确(我正在制作字母).我一直在 IcoMoon 上迭代,安装字体,并将我的字母与类似字体的字母进行比较(使用文字处理器).调整大小很容易,但间距并不那么容易(我什至没有搞乱 连字a> 或 字距调整!).不要忘记,有些系统需要在安装新字体后刷新字体缓存(在 Linux 上,这是 字体配置)

I found the sizing and spacing was really hard to get right (I was making letters). I kept iterating on IcoMoon, installing the font, and comparing my letters to letters in a similar font (using a word processor). Sizing was easy to get right, but spacing was not so easy (and I wasn't even messing with ligatures or kerning!). Don't forget that some systems require flushing the font cache after installing a new font (on Linux, that's fc-cache from Fontconfig)

您可能还想验证您的字体.Font Squirrel 是一项在线服务,可让您做到这一点,提供更正和使用技巧.我认为 IcoMoon 已经这样做了,所以也许这仅用于 FontForge 创作.

You may also want to validate your font. Font Squirrel is an online service that lets you do that, offering corrections as well as usage tips. I think IcoMoon already does this, so perhaps that's only of use for FontForge creations.

这篇关于如何将 .svg 文件转换为字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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