Skip to content

Commit

Permalink
Strip away svg units, if present
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSignPainter98 committed Aug 9, 2020
1 parent b980dcf commit ab64aa5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions glyphinf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
# Copyright (C) Edward Jones

from os.path import basename
from re import search
from xml.dom.minidom import Document, parse

numRegex:str = r'([0-9]*\.[0-9]+|[0-9]+)'

def glyph_inf(gpath: str) -> dict:
gname: str = glyph_name(gpath)
gfile: Document = parse(gpath).documentElement
svg_width: float = float(gfile.attributes['width'].value)
svg_height: float = float(gfile.attributes['height'].value)
rawWidth:str = search(numRegex, gfile.attributes['width'].value).group(0)
rawHeight:str = search(numRegex, gfile.attributes['height'].value).group(0)
svg_width: float = float(rawWidth)
svg_height: float = float(rawHeight)
return {
'glyph': gname,
'glyph-src-width': float(svg_width),
Expand Down

0 comments on commit ab64aa5

Please sign in to comment.