Skip to content

Commit

Permalink
[makeotf] Fix calls to sfntedit
Browse files Browse the repository at this point in the history
Fixes #680
  • Loading branch information
miguelsousa committed Dec 7, 2018
1 parent 9d5eaa4 commit b4a7105
Show file tree
Hide file tree
Showing 1,602 changed files with 48,387 additions and 15 deletions.
15 changes: 14 additions & 1 deletion python/afdko/fdkutils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2016 Adobe. All rights reserved.

"""
fdkutils.py v1.2.7 Aug 28 2018
fdkutils.py v1.2.8 Dec 7 2018
A module of functions that are needed by several of the AFDKO scripts.
"""

Expand All @@ -24,6 +24,19 @@ def get_resources_dir():
return os.path.join(os.path.dirname(__file__), 'resources')


def run_shell_command(args):
"""
Runs a shell command.
Returns True if the command was successful, and False otherwise.
"""
try:
subprocess.check_call(args)
return True
except (subprocess.CalledProcessError, OSError) as err:
print(err)
return False


def runShellCmd(cmd):
try:
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
Expand Down
26 changes: 12 additions & 14 deletions python/afdko/makeotf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"""

__version__ = """\
makeotf.py v2.5.2 Sep 20 2018
makeotf.py v2.6.0 Dec 7 2018
"""

__methods__ = """
Expand Down Expand Up @@ -2200,28 +2200,26 @@ def copyTTFGlyphTables(inputFilePath, tempOutputPath, outputPath):
for tableTag in ["GDEF", "GSUB", "GPOS", "cmap", "name", "OS/2", "BASE"]:
if tableTag not in tableDump:
continue
command = "sfntedit -x \"%s\"=\"%s\" \"%s\" 2>&1" % (
tableTag, tempTablePath, tempOutputPath)
log = fdkutils.runShellCmd(command)
if not ("Done." in log):
print(log)
args1 = ['sfntedit', '-x', '%s=%s' % (tableTag, tempTablePath),
tempOutputPath]
success1 = fdkutils.run_shell_command(args1)
if not success1:
print("Error removing table '%s' from OTF font reference." %
tableTag)
return

command = "sfntedit -a \"%s\"=\"%s\" \"%s\" 2>&1" % (
tableTag, tempTablePath, outputPath)
log = fdkutils.runShellCmd(command)
if not ("Done." in log):
print(log)
args2 = ['sfntedit', '-a', '%s=%s' % (tableTag, tempTablePath),
outputPath]
success2 = fdkutils.run_shell_command(args2)
if not success2:
print("Error adding makeotf-made table '%s' to TrueType font." %
tableTag)
return

print("\tcopied \"%s\"." % tableTag)
print(" copied \"%s\"" % tableTag)

command = "sfntedit -f \"%s\" 2>&1" % outputPath
fdkutils.runShellCmd(command)
# fix checksums
fdkutils.run_shell_command(['sfntedit', '-f', outputPath])

print("Succeeded in merging makeotf tables with TrueType source font to "
"final TrueType output font at '%s'." % outputPath)
Expand Down
1 change: 1 addition & 0 deletions tests/makeotf_data/input/bug680/FontMenuNameDB
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[SourceCodePro-Regular] f=Source Code Pro s=Regular l=Source Code Pro m=1,Source Code Pro
Expand Down
32 changes: 32 additions & 0 deletions tests/makeotf_data/input/bug680/GPOS.fea
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@mGC_above_300_507 = [gravecmb variacmb acutecmb tonoscmb circumflexcmb tildecmb macroncmb overlinecmb brevecmb brevecmb.cyr dotaccentcmb dieresiscmb hoicmb candrabinducmb ringcmb hungarumlautcmb caroncmb dblgravecmb breveinvertedcmb commaturnedabovecmb aspercmb commaabovecmb leniscmb commabelowcmb.a xabovecmb perispomenicmb dieresisacutecmb dieresistonoscmb dieresisgravecmb dialytikagravecmb dieresistildecmb dieresismacroncmb dieresiscaroncmb circumflexacutecmb circumflexgravecmb circumflexhoicmb circumflextildecmb breveacutecmb brevegravecmb brevehoicmb brevetildecmb circumflexbrevecmb macronacutecmb carondotaccentcmb asperacutecmb aspergravecmb aspertildecmb lenisacutecmb lenisgravecmb lenistildecmb];
@mGC_above_300_676 = [gravecmb.cap acutecmb.cap circumflexcmb.cap tildecmb.cap macroncmb.cap overlinecmb.cap brevecmb.cap brevecmb.cyrcap dotaccentcmb.cap dieresiscmb.cap hoicmb.cap candrabinducmb.cap ringcmb.cap hungarumlautcmb.cap caroncmb.cap dblgravecmb.cap breveinvertedcmb.cap perispomenicmb.cap dieresisacutecmb.cap dieresisgravecmb.cap dieresismacroncmb.cap dieresiscaroncmb.cap circumflexacutecmb.cap circumflexgravecmb.cap circumflexhoicmb.cap circumflextildecmb.cap breveacutecmb.cap brevegravecmb.cap brevehoicmb.cap brevetildecmb.cap circumflexbrevecmb.cap macronacutecmb.cap carondotaccentcmb.cap];
@mGC_base_300_0 = [cedillacmb cedillacmb.cap];
@mGC_below_300_n20 = [lefttackbelowcmb righttackbelowcmb ringhalfleftbelowcmb uptackbelowcmb downtackbelowcmb plusbelowcmb minusbelowcmb dotbelowcmb dieresisbelowcmb ringbelowcmb commabelowcmb verticallinebelowcmb bridgebelowcmb caronbelowcmb brevebelowcmb breveinvertedbelowcmb tildebelowcmb macronbelowcmb ringhalfrightbelowcmb bridgeinvertedbelowcmb squarebelowcmb seagullbelowcmb iotasubscriptcmb];
@mGC_ogonek_300_0 = [ogonekcmb ogonekcmb.cap];

markClass @mGC_above_300_507 <anchor 300 507> @MC_above;
markClass @mGC_above_300_676 <anchor 300 676> @MC_above;
markClass @mGC_base_300_0 <anchor 300 0> @MC_base;
markClass @mGC_below_300_n20 <anchor 300 -20> @MC_below;
markClass @mGC_ogonek_300_0 <anchor 300 0> @MC_ogonek;
markClass horncmb <anchor 300 486> @MC_horn;
markClass leftangleabovecmb <anchor 300 507> @MC_aboveright;
markClass tildeoverlaycmb <anchor 300 244> @MC_center;


feature mark {
@MARK_GLYPHS = [gravecmb gravecmb.cap variacmb acutecmb acutecmb.cap tonoscmb circumflexcmb circumflexcmb.cap tildecmb tildecmb.cap macroncmb macroncmb.cap overlinecmb overlinecmb.cap brevecmb brevecmb.cyr brevecmb.cap brevecmb.cyrcap dotaccentcmb dotaccentcmb.cap dieresiscmb dieresiscmb.cap hoicmb hoicmb.cap candrabinducmb candrabinducmb.cap ringcmb ringcmb.cap hungarumlautcmb hungarumlautcmb.cap caroncmb caroncmb.cap dblgravecmb dblgravecmb.cap breveinvertedcmb breveinvertedcmb.cap commaturnedabovecmb aspercmb commaabovecmb leniscmb lefttackbelowcmb righttackbelowcmb leftangleabovecmb horncmb ringhalfleftbelowcmb uptackbelowcmb downtackbelowcmb plusbelowcmb minusbelowcmb dotbelowcmb dieresisbelowcmb ringbelowcmb commabelowcmb commabelowcmb.a cedillacmb cedillacmb.cap ogonekcmb ogonekcmb.cap verticallinebelowcmb bridgebelowcmb caronbelowcmb brevebelowcmb breveinvertedbelowcmb tildebelowcmb macronbelowcmb tildeoverlaycmb ringhalfrightbelowcmb bridgeinvertedbelowcmb squarebelowcmb seagullbelowcmb xabovecmb perispomenicmb perispomenicmb.cap iotasubscriptcmb dieresistonoscmb dialytikagravecmb asperacutecmb aspergravecmb aspertildecmb lenisacutecmb lenisgravecmb lenistildecmb];
@ZW_GLYPHS = [ZWNBS];

lookup ADJUST_WIDTHS {
pos [@MARK_GLYPHS @ZW_GLYPHS] <0 0 -600 0>;
pos [macrondoublebelowcmb breveinverteddoublecmb] <-300 0 -600 0>;
} ADJUST_WIDTHS;

include (mark.fea);
} mark;


feature mkmk {
include (mkmk.fea);
} mkmk;
Loading

0 comments on commit b4a7105

Please sign in to comment.