aboutsummaryrefslogtreecommitdiffstats
path: root/Lib/defconQt/util/glyphList.py
blob: ee97d78df169ac0d3adafae5a43fc6a7fa336b0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import re

_parseGL_RE = re.compile("([A-Za-z_0-9.]+);([0-9A-F]{4})")


def parseGlyphList(path):
    GL2UV = {}
    with open(path) as file:
        for line in file:
            if not line or line[:1] == '#':
                continue
            m = _parseGL_RE.match(line)
            if not m:
                raise SyntaxError("syntax error in glyphlist: %s"
                                  .format(repr(line[:20])))
            glyphName = m.group(1)
            if glyphName in GL2UV:
                print("warning: glyphName redefined in glyphList: {}".format(
                    glyphName))
            GL2UV[glyphName] = int(m.group(2), 16)
    return GL2UV