Skip to content

Commit

Permalink
Remove ufoLib dependency
Browse files Browse the repository at this point in the history
Fixes #666
  • Loading branch information
miguelsousa committed Dec 5, 2018
1 parent 7820ad7 commit 55d04fb
Show file tree
Hide file tree
Showing 86 changed files with 120 additions and 122 deletions.
4 changes: 2 additions & 2 deletions python/afdko/checkoutlinesufo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from __future__ import print_function, absolute_import

__version__ = '2.2.1'
__version__ = '2.2.2'

import argparse
from functools import cmp_to_key
Expand All @@ -20,8 +20,8 @@

import booleanOperations.booleanGlyph
import defcon
import ufoLib
from fontPens.digestPointPen import DigestPointPen
from fontTools import ufoLib

from afdko import ufotools
from afdko.ufotools import kProcessedGlyphsLayer as PROCD_GLYPHS_LAYER
Expand Down
6 changes: 3 additions & 3 deletions python/afdko/ttfcomponentizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import os
import sys

from fontTools.ttLib import TTFont, getTableModule
from fontTools.misc.py23 import open
from fontTools.ttLib import TTFont, getTableModule
from fontTools.ufoLib.errors import UFOLibError
from defcon import Font
from ufoLib import UFOLibError


__version__ = '0.1.0'
__version__ = '0.1.1'


PUBLIC_PSNAMES = "public.postscriptNames"
Expand Down
32 changes: 18 additions & 14 deletions python/afdko/ufotools.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Copyright 2017 Adobe. All rights reserved.

from __future__ import print_function, absolute_import
from __future__ import print_function, absolute_import, unicode_literals

import ast
import hashlib
import os
import plistlib
Expand All @@ -12,12 +13,12 @@
except ImportError:
import xml.etree.ElementTree as ET

from fontTools.misc.py23 import open, tobytes, tounicode
from fontTools.misc.py23 import open, tobytes, tounicode, tostr

from afdko import convertfonttocid, fdkutils

__doc__ = """
ufotools.py v1.32.0 Nov 1 2018
ufotools.py v1.32.1 Nov 2 2018
This module supports using the Adobe FDK tools which operate on 'bez'
files with UFO fonts. It provides low level utilities to manipulate UFO
Expand Down Expand Up @@ -329,14 +330,14 @@ def debugMsg(*args):
kDefaultGlyphsLayerName = "public.default"
kDefaultGlyphsLayer = "glyphs"
kProcessedGlyphsLayerName = "com.adobe.type.processedglyphs"
kProcessedGlyphsLayer = "glyphs." + kProcessedGlyphsLayerName
kProcessedGlyphsLayer = "glyphs.%s" % kProcessedGlyphsLayerName
kFontInfoName = "fontinfo.plist"
kContentsName = "contents.plist"
kLibName = "lib.plist"
kPublicGlyphOrderKey = "public.glyphOrder"

kAdobeDomainPrefix = "com.adobe.type"
kAdobHashMapName = "%s.processedHashMap" % (kAdobeDomainPrefix)
kAdobHashMapName = "%s.processedHashMap" % kAdobeDomainPrefix
kAdobHashMapVersionName = "hashMapVersion"
kAdobHashMapVersion = (1, 0) # If major version differs, do not use.
kAutohintName = "autohint"
Expand Down Expand Up @@ -379,7 +380,7 @@ class BezParseError(Exception):

class UFOFontData(object):
def __init__(self, parentPath, useHashMap, programName):
self.parentPath = parentPath
self.parentPath = tounicode(parentPath, encoding='utf-8')
self.glyphMap = {}
self.processedLayerGlyphMap = {}
self.newGlyphMap = {}
Expand All @@ -395,11 +396,12 @@ def __init__(self, parentPath, useHashMap, programName):
# hash matches hash of current glyph data.
self.hashMap = {}
self.fontDict = None
self.programName = programName
self.programName = tostr(programName)
self.curSrcDir = None
self.hashMapChanged = 0
self.glyphDefaultDir = os.path.join(parentPath, "glyphs")
self.glyphLayerDir = os.path.join(parentPath, kProcessedGlyphsLayer)
self.glyphDefaultDir = os.path.join(self.parentPath, "glyphs")
self.glyphLayerDir = os.path.join(self.parentPath,
kProcessedGlyphsLayer)
self.glyphWriteDir = self.glyphLayerDir
self.historyList = []
self.requiredHistory = [] # See documentation above.
Expand Down Expand Up @@ -509,7 +511,7 @@ def readHashMap(self):
if os.path.exists(hashPath):
with open(hashPath, "r", encoding='utf-8') as fp:
data = fp.read()
newMap = eval(data)
newMap = ast.literal_eval(data)
else:
newMap = {kAdobHashMapVersionName: kAdobHashMapVersion}

Expand Down Expand Up @@ -614,7 +616,7 @@ def updateHashEntry(self, glyphName, changed):
# and we have just created a new glyph in the processed layer,
# then reset the history.
if (not self.useProcessedLayer) and changed:
self.hashMap[glyphName] = [srcHash, [self.programName]]
self.hashMap[glyphName] = [tostr(srcHash), [self.programName]]
return
# If the program is not in the history list, add it.
elif self.programName not in historyList:
Expand Down Expand Up @@ -654,7 +656,8 @@ def checkSkipGlyph(self, glyphName, newSrcHash, doAll):
# case for Checkoutlines
if not self.useProcessedLayer:
self.hashMapChanged = 1
self.hashMap[glyphName] = [newSrcHash, [self.programName]]
self.hashMap[glyphName] = [tostr(newSrcHash),
[self.programName]]
glyphPath = self.getGlyphProcessedPath(glyphName)
if glyphPath and os.path.exists(glyphPath):
os.remove(glyphPath)
Expand Down Expand Up @@ -682,7 +685,7 @@ def checkSkipGlyph(self, glyphName, newSrcHash, doAll):
# If the source hash has changed, we need to
# delete the processed layer glyph.
self.hashMapChanged = 1
self.hashMap[glyphName] = [newSrcHash, [self.programName]]
self.hashMap[glyphName] = [tostr(newSrcHash), [self.programName]]
glyphPath = self.getGlyphProcessedPath(glyphName)
if glyphPath and os.path.exists(glyphPath):
os.remove(glyphPath)
Expand Down Expand Up @@ -2483,7 +2486,8 @@ def validateLayers(ufoFontPath, doWarning=True):


def makeUFOFMNDB(srcFontPath):
fontInfoPath = os.path.join(srcFontPath, kFontInfoName) # default
fontInfoPath = os.path.join(tounicode(srcFontPath, encoding='utf-8'),
kFontInfoName) # default
fiMap, fiList = parsePList(fontInfoPath)
psName = "NoFamilyName-Regular"
familyName = "NoFamilyName"
Expand Down
17 changes: 8 additions & 9 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
booleanOperations~=0.8.1
cu2qu[cli]~=1.6.5
defcon[lxml,pens]~=0.6.0
fontMath~=0.4.8
fontTools[ufo,unicode,lxml]~=3.32.0
mutatorMath~=2.1.2
booleanOperations==0.8.1
cu2qu[cli]==1.6.5
defcon[lxml,pens]==0.6.0
fontMath==0.4.8
fontTools[ufo,unicode,lxml]==3.32.0
mutatorMath==2.1.2
psautohint==1.8.1
ufoLib[lxml]==2.3.2
ufonormalizer~=0.3.5
ufoProcessor~=1.0.1
ufonormalizer==0.3.5
ufoProcessor==1.0.2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="B" format="1">
<advance width="628"/>
<unicode hex="0042"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Ccaron" format="1">
<advance width="632"/>
<unicode hex="010C"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Ccedilla" format="1">
<advance width="632"/>
<unicode hex="00C7"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="H" format="1">
<advance width="790"/>
<unicode hex="0048"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Hbar" format="1">
<advance width="790"/>
<unicode hex="0126"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Icircumflex" format="1">
<advance width="370"/>
<unicode hex="00CE"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="L" format="1">
<advance width="597"/>
<unicode hex="004C"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Lcommaaccent" format="1">
<advance width="597"/>
<unicode hex="013B"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Ldot" format="1">
<advance width="597"/>
<unicode hex="013F"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Lslash" format="1">
<advance width="597"/>
<unicode hex="0141"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Ncommaaccent" format="1">
<advance width="735"/>
<unicode hex="0145"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Ngrave" format="1">
<advance width="735"/>
<unicode hex="01F8"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Oslash" format="1">
<advance width="707"/>
<unicode hex="00D8"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Oslashmacron" format="1">
<advance width="707"/>
<outline>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="S" format="1">
<advance width="510"/>
<unicode hex="0053"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Sacute" format="1">
<advance width="510"/>
<unicode hex="015A"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Scaron" format="1">
<advance width="510"/>
<unicode hex="0160"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Scedilla" format="1">
<advance width="510"/>
<unicode hex="015E"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="caroncmb.cap" format="1">
<outline>
<contour>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="ccedilla" format="1">
<advance width="486"/>
<unicode hex="00E7"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="cedillacmb.cap" format="1">
<outline>
<contour>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="commabelowcmb" format="1">
<unicode hex="0326"/>
<outline>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="s" format="1">
<advance width="433"/>
<unicode hex="0073"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="sacute" format="1">
<advance width="433"/>
<unicode hex="015B"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="scaron" format="1">
<advance width="433"/>
<unicode hex="0161"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="scedilla" format="1">
<advance width="433"/>
<unicode hex="015F"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>creator</key>
<string>org.robofab.ufoLib</string>
<string>com.github.fonttools.ufoLib</string>
<key>formatVersion</key>
<integer>2</integer>
</dict>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="B" format="2">
<advance width="628"/>
<unicode hex="0042"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Ccaron" format="2">
<advance width="632"/>
<unicode hex="010C"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Ccedilla" format="2">
<advance width="632"/>
<unicode hex="00C7"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="H" format="2">
<advance width="790"/>
<unicode hex="0048"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Hbar" format="2">
<advance width="790"/>
<unicode hex="0126"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Icircumflex" format="2">
<advance width="370"/>
<unicode hex="00CE"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="L" format="2">
<advance width="597"/>
<unicode hex="004C"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version='1.0' encoding='UTF-8'?>
<glyph name="Lcommaaccent" format="2">
<advance width="597"/>
<unicode hex="013B"/>
Expand Down
Loading

0 comments on commit 55d04fb

Please sign in to comment.