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

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

问题描述

任何人都可以帮助我将.svg文件转换为字体文件?或有没有办法做到这一点?

解决方案

我在堆栈溢出发现两个相关的答案:


  1. 使用矢量软件(例如inkscape)和fontforge创建图标字体? 将svg转换为ttf的工具[关闭]

不幸的是,这两个答案都不是真正的答案,这正是我所希望的(一个用于脚本化转换的命令行实用程序,或者是一个有人可以写这样的东西的API)。



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

清理SVG



(这一步可能是可选的)。 在自由软件程序 InkScape 。复制现有的SVG,并从FontForge字形模板创建一个新的项目。粘贴到该模板中,标准化外观,大小和位置,并保存为PLAIN SVG,每个字符一个文件(glyph)。
$ b

将SVG转换为字体



然后,使用免费软件程序 FontForge (直接在第一个答案,使用矢量软件创建图标字体),或者使用免费的 IcoMoon 在线服务(按照第二个答案,将工具转换成ttf )。我做了后者。

使用IcoMoon



IcoMoon是一个相当简单的工具。点击页面顶部的紫色导入图标按钮导入您的每个自定义SVG字形。然后单击该设置的首选项上的获取信息,以便您可以命名该设置并给它一些元数据。使用编辑工具(铅笔图标),然后单击每个字形以获得大小和间距。



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

屏幕顶部的首选项按钮(或右下角的设备),并确定新字体的名称和元数据,然后按下右下方的下载。你将得到一个Fontname.zip文件,其中包含一些使用建议以及字体文件。


$ b

迭代



我发现大小和间距确实很难找到正确的(我正在写信)。我一直在IcoMoon上进行迭代,安装字体,并将我的字母与类似字体的字母(使用文字处理器)进行比较。尺寸很容易找到正确的,但间距不是那么容易(我甚至没有搞乱连字

a>或 kerning !)。不要忘记,一些系统需要在安装新字体(在Linux上,来自 fc-cache wikipedia.org/wiki/Fontconfigrel =noreferrer> Fontconfig

验证字体



你也可能想验证你的字体。 字体松鼠是一个在线服务,可以让您这样做,提供更正以及使用提示。我认为IcoMoon已经这样做了,所以也许这只是用于FontForge创作。


Can anybody help me to convert .svg files to a font file? or is there a way to do it on the fly?

解决方案

I found two relevant answers here on Stack Overflow:

  1. Creating icon fonts with vector software (i.e. inkscape) and fontforge?
  2. Tools to convert svg to ttf [closed]

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.

Clean up 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").

Convert SVG to font

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.

Using IcoMoon

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.

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.

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.

Iterate

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)

Validate the font

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天全站免登陆