倒置字形:位图> SVG通过autotrace>字形通过fontforge [英] Inverted glyph: bitmap > SVG via autotrace > glyph via fontforge

查看:281
本文介绍了倒置字形:位图> SVG通过autotrace>字形通过fontforge的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

  • 获取位图图像

  • >使用autotrace创建SVG(在Linux上)
  • 使用python-fontforge(glyph.importOutlines(svgfile))将轮廓导入为字形
>

这个效果很好,除了生成的字形倒转(见图片)。任何想法如何可以防止,如何SVG或字形可以颠倒,或类似的东西?



源位图:



自动跟踪SVG:

结果字体:

解决方案

只需使用 potrace 而不是autotrace来解决这个问题。

供参考,这些是步骤:

将位图转换为svg(linux命令行) p>

  potrace -s sourceimg.bmp 

使用svg作为字形(python):

  import fontforge 
font = fontforge.open ('blank.sfd')
glyph = font.createMappedChar('A')
glyph.importOutlines('sourceimg.svg')
font.generate('testfont.ttf')

就是这样,在网站上使用的结果如下:

$ c




$ font-family:testfont;
src:url('testfont.ttf');

$ / code>

html:

 < span style =font-family:testfont; font-weight:normal; color:green;> A< / span> 


I am trying to create a font/glyph by:

  • taking a bitmap image
  • creating an SVG with autotrace (on Linux)
  • importing the outline as a glyph with python-fontforge (glyph.importOutlines(svgfile) )

This works fine except that the resulting glyph in inverted (see images). Any idea how this can be prevented, how the SVG or glyph can be inverted, or anything like that?

Source bitmap:

Autotraced SVG:

Resulting font:

解决方案

solved this simply by using potrace instead of autotrace.

for reference, these are the steps:

convert bitmap to svg (linux command line):

potrace -s sourceimg.bmp

use svg as glyph (python):

import fontforge
font = fontforge.open('blank.sfd')
glyph = font.createMappedChar('A')
glyph.importOutlines('sourceimg.svg')
font.generate('testfont.ttf')

That's it, result below for use on a website:

css:

@font-face
{
font-family: testfont;
src: url('testfont.ttf');
}

html:

<span style="font-family:testfont; font-weight:normal; color:green;">A</span>
<span style="font-family:testfont; font-weight:bold; color:green;">A</span>

这篇关于倒置字形:位图&gt; SVG通过autotrace&gt;字形通过fontforge的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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