Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use otRound everywhere else it makes sense #263

Merged
merged 1 commit into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Lib/ufo2ft/featureWriters/kernFeatureWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
absolute_import,
unicode_literals,
)
from fontTools.misc.py23 import unichr, round, basestring, SimpleNamespace
from fontTools.misc.py23 import unichr, basestring, SimpleNamespace
from fontTools.misc.fixedTools import otRound

from fontTools import unicodedata

Expand Down Expand Up @@ -361,7 +362,7 @@ def _groupScriptsByTagAndDirection(feaScripts):
@staticmethod
def _makePairPosRule(pair, rtl=False):
enumerated = pair.firstIsClass ^ pair.secondIsClass
value = round(pair.value)
value = otRound(pair.value)
if rtl and "N" in pair.bidiTypes:
# numbers are always shaped LTR even in RTL scripts
rtl = False
Expand Down
9 changes: 5 additions & 4 deletions Lib/ufo2ft/featureWriters/markFeatureWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from collections import OrderedDict
from functools import partial
import itertools
from fontTools.misc.py23 import round, tostr, tounicode
from fontTools.misc.py23 import tostr, tounicode
from fontTools.misc.fixedTools import otRound
from ufo2ft.featureWriters import BaseFeatureWriter, ast
from ufo2ft.util import unicodeInScripts, classifyGlyphs

Expand All @@ -33,7 +34,7 @@ def _filterMarks(self, include):
def _marksAsAST(self):
return [
(
ast.Anchor(x=round(anchor.x), y=round(anchor.y)),
ast.Anchor(x=otRound(anchor.x), y=otRound(anchor.y)),
anchor.markClass,
)
for anchor in sorted(self.marks, key=lambda a: a.name)
Expand Down Expand Up @@ -75,7 +76,7 @@ def _marksAsAST(self):
return [
[
(
ast.Anchor(x=round(anchor.x), y=round(anchor.y)),
ast.Anchor(x=otRound(anchor.x), y=otRound(anchor.y)),
anchor.markClass,
)
for anchor in sorted(component, key=lambda a: a.name)
Expand Down Expand Up @@ -347,7 +348,7 @@ def _makeMarkClassDefinitions(self):
return newDefs

def _defineMarkClass(self, glyphName, x, y, className, markClasses):
anchor = ast.Anchor(x=round(x), y=round(y))
anchor = ast.Anchor(x=otRound(x), y=otRound(y))
markClass = markClasses.get(className)
if markClass is None:
markClass = ast.MarkClass(className)
Expand Down
5 changes: 3 additions & 2 deletions Lib/ufo2ft/filters/transformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from ufo2ft.filters import BaseFilter

from fontTools.misc.py23 import round
from fontTools.misc.fixedTools import otRound
from fontTools.misc.transform import Transform, Identity
from fontTools.pens.recordingPen import RecordingPen
from fontTools.pens.transformPen import TransformPen as _TransformPen
Expand Down Expand Up @@ -79,11 +80,11 @@ def get_origin_height(self, font, origin):
elif origin is self.Origin.CAP_HEIGHT:
return font.info.capHeight
elif origin is self.Origin.HALF_CAP_HEIGHT:
return round(font.info.capHeight/2)
return otRound(font.info.capHeight/2)
elif origin is self.Origin.X_HEIGHT:
return font.info.xHeight
elif origin is self.Origin.HALF_X_HEIGHT:
return round(font.info.xHeight/2)
return otRound(font.info.xHeight/2)
else:
raise AssertionError(origin)

Expand Down
7 changes: 4 additions & 3 deletions Lib/ufo2ft/fontInfoData.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import unicodedata
import os

from fontTools.misc.py23 import tobytes, tostr, tounicode, unichr, round
from fontTools.misc.py23 import tobytes, tostr, tounicode, unichr
from fontTools.misc.fixedTools import otRound
from fontTools.misc.textTools import binary2num
import ufoLib

Expand Down Expand Up @@ -88,7 +89,7 @@ def openTypeHheaCaretSlopeRiseFallback(info):
if (hasattr(info, "openTypeHheaCaretSlopeRun") and
info.openTypeHheaCaretSlopeRun is not None):
slopeRun = info.openTypeHheaCaretSlopeRun
return round(slopeRun / math.tan(math.radians(-italicAngle)))
return otRound(slopeRun / math.tan(math.radians(-italicAngle)))
else:
return 1000 # just an arbitrary non-zero reference point
return 1
Expand All @@ -102,7 +103,7 @@ def openTypeHheaCaretSlopeRunFallback(info):
italicAngle = getAttrWithFallback(info, "italicAngle")
if italicAngle != 0:
slopeRise = getAttrWithFallback(info, "openTypeHheaCaretSlopeRise")
return round(math.tan(math.radians(-italicAngle)) * slopeRise)
return otRound(math.tan(math.radians(-italicAngle)) * slopeRise)
return 0

# name
Expand Down
Loading