fonttools: try to draw emoji image with windows seguiemj.ttf font failed
I am trying to extract high resolution windows color emoji image from seguiemj.ttf .
What I have already know:
- the font stores emoji in svg format (layered vector drawings in COLR/CPAL)
- the font also has a
glyph
table
My roadmap:
use fonttools load seguiemj.ttf --> use fonttools draw high resolution png image --> save to file
for example, I am trying to try 😀 with glyph name u1F600:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
if __name__=="__main__":
import sys
from fontTools.ttLib import TTFont
from reportlab.lib import colors
from fontTools.pens.reportLabPen import ReportLabPen, Path
glyphName = 'u1F600'
imageFile = "%s.png" % glyphName
font = TTFont('seguiemj.ttf')
gs = font.getGlyphSet()
pen = ReportLabPen(gs, Path(fillColor=colors.red, strokeWidth=5))
g = gs[glyphName]
g.draw(pen)
w, h = g.width, 1000
from reportlab.graphics import renderPM
from reportlab.graphics.shapes import Group, Drawing, scale
# Everything is wrapped in a group to allow transformations.
g = Group(pen.path)
g.translate(0, 200)
g.scale(0.3, 0.3)
d = Drawing(w, h)
d.add(g)
renderPM.drawToFile(d, imageFile, fmt="PNG")
I only get image with emji ontline filled with red color.
What I have missed? Or am I totally on the wrong direction?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (7 by maintainers)
Besides the fact that the Segoe UI Emoji font does not use SVG (the COLR table references glyph IDs that are assumed to refer to glyphs in a glyf, CFF or CFF2 table)…
I have a suspicion that what you are trying to do may be in violation of the license agreement associated with that font.