Skip to content

How to find out if an font support an character? #2997

Answered by moi15moi
moi15moi asked this question in Q&A
Discussion options

You must be logged in to vote

Ok, I did not understood that the codepoints were already good, but it was only the name that wasn't.

I should have verified earlier that the glyph were already by creating an svg for each glyph and verify them:

from fontTools.ttLib.ttFont import TTFont
from fontTools.pens.svgPathPen import SVGPathPen
from fontTools.pens.transformPen import TransformPen

font = TTFont("test.ttf")

glyphSet = font.getGlyphSet()

for table in font["cmap"].tables:
    for codepoint, name in table.cmap.items():

        svgpen = SVGPathPen(glyphSet)
        pen= TransformPen(svgpen , (1, 0, 0, -1, 0, 750))
        glyphSet[name].draw(pen)
        path = svgpen.getCommands()

        with open(f"{hex(codepoint)}

Replies: 1 comment 27 replies

Comment options

You must be logged in to vote
27 replies
@justvanrossum
Comment options

@justvanrossum
Comment options

@anthrotype
Comment options

@moi15moi
Comment options

Answer selected by moi15moi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants