diff --git a/README.md b/README.md index 825bafc..2cbe4c6 100644 --- a/README.md +++ b/README.md @@ -231,9 +231,9 @@ required for an `.otf` font to work with `SwiftMath`. If you generate (and test) any other fonts please contribute them back to this project for others to benefit. -Note: The `KpMath-Light` and `KpMath-Sans` fonts current do not correctly -render very large radicals correctly. It appears that the font files do -not correctly define the offsets required to typeset these glyphs. If +Note: The `KpMath-Light` and `KpMath-Sans` fonts currently incorrectly +render very large radicals. It appears that the font files do +not properly define the offsets required to typeset these glyphs. If anyone can fix this, it would be greatly appreciated. ##### Text Color @@ -246,7 +246,7 @@ label.textColor = .red It is also possible to set different colors for different parts of the equation. Just access the `displayList` field and set the `textColor` -on the underlying displays that you want to change the color of. +of the underlying displays of which you want to change the color. ##### Custom Commands You can define your own commands that are not already predefined. This is diff --git a/Sources/SwiftMath/mathFonts.bundle/KpMath-Light.otf b/Sources/SwiftMath/mathFonts.bundle/KpMath-Light.otf index eda288d..85dba5f 100644 Binary files a/Sources/SwiftMath/mathFonts.bundle/KpMath-Light.otf and b/Sources/SwiftMath/mathFonts.bundle/KpMath-Light.otf differ diff --git a/Sources/SwiftMath/mathFonts.bundle/KpMath-Light.plist b/Sources/SwiftMath/mathFonts.bundle/KpMath-Light.plist index f71964f..0e6b4f4 100644 --- a/Sources/SwiftMath/mathFonts.bundle/KpMath-Light.plist +++ b/Sources/SwiftMath/mathFonts.bundle/KpMath-Light.plist @@ -2506,8 +2506,22 @@ 276 ocirc -220 + overleftarrow + -268 + overleftharpoon + -268 + overleftrightarrow + -335 + overrightarc + -275 + overrightarrow + -268 + overrightharpoon + -268 widebreve -220 + widebreve.h0 + -120 widecheck -220 widecheck.h0 @@ -2534,7 +2548,7 @@ DisplayOperatorMinHeight 1500 FlattenedAccentBaseHeight - 670 + 650 FractionDenomDisplayStyleGapMin 150 FractionDenominatorDisplayStyleShiftDown @@ -2568,15 +2582,15 @@ OverbarVerticalGap 150 RadicalDegreeBottomRaisePercent - 55 + 60 RadicalDisplayStyleVerticalGap 170 RadicalExtraAscender 50 RadicalKernAfterDegree - -560 + -600 RadicalKernBeforeDegree - 280 + 300 RadicalRuleThickness 50 RadicalVerticalGap @@ -2642,8 +2656,73 @@ h_variants + Leftarrow + + Leftarrow + Longleftarrow + + Leftrightarrow + + Leftrightarrow + Longleftrightarrow + + Mapsfrom + + Mapsfrom + Longmapsfrom + + Mapsto + + Mapsto + Longmapsto + + Rightarrow + + Rightarrow + Longrightarrow + + equal + + equiv + + hookleftarrow + + hookrightarrow + + leftarrow + + leftarrow + longleftarrow + + leftarrowtail + + leftharpoondown + + leftharpoonup + + leftrightarrow + + leftrightarrow + longleftrightarrow + + leftrightarrows + + leftrightharpoons + + mapsfrom + + mapsfrom + longmapsfrom + + mapsto + + mapsto + longmapsto + mathunderbar + minus + overbrace overbrace @@ -2663,6 +2742,10 @@ overleftharpoon + overleftrightarrow + + overleftrightarrow.h1 + overparen overparen @@ -2686,6 +2769,25 @@ overrightharpoon + rightarrow + + rightarrow + longrightarrow + + rightarrowtail + + rightharpoondown + + rightharpoonup + + rightleftarrows + + rightleftharpoons + + twoheadleftarrow + + twoheadrightarrow + underbrace underbrace @@ -2737,6 +2839,7 @@ widebreve widebreve + widebreve.h0 widebreve.h1 widebreve.h2 widebreve.h3 @@ -4909,27 +5012,27 @@ advance - 1200 + 2700 endConnector - 400 + 133 extender glyph - Vert.v2 + Vert.v4 startConnector - 400 + 133 advance - 472 + 400 endConnector - 157 + 133 extender glyph Vert.ex startConnector - 157 + 133 @@ -4941,27 +5044,27 @@ advance - 1200 + 2700 endConnector - 400 + 133 extender glyph - Vvert.v2 + Vvert.v4 startConnector - 400 + 133 advance - 472 + 400 endConnector - 157 + 133 extender glyph Vvert.ex startConnector - 157 + 133 @@ -5049,39 +5152,39 @@ advance - 895 + 1550 endConnector - 298 + 133 extender glyph lBrack.bt startConnector - 298 + 133 advance - 346 + 400 endConnector - 115 + 133 extender glyph lBrack.ex startConnector - 115 + 133 advance - 895 + 1550 endConnector - 298 + 133 extender glyph lBrack.tp startConnector - 298 + 133 @@ -5093,63 +5196,63 @@ advance - 737 + 800 endConnector - 246 + 70 extender glyph lbrace.bt startConnector - 246 + 70 advance - 326 + 200 endConnector - 109 + 70 extender glyph vbrace.ex startConnector - 109 + 70 advance - 777 + 1500 endConnector - 259 + 70 extender glyph lbracemid startConnector - 259 + 70 advance - 326 + 200 endConnector - 109 + 70 extender glyph vbrace.ex startConnector - 109 + 70 advance - 737 + 800 endConnector - 246 + 70 extender glyph lbrace.tp startConnector - 246 + 70 @@ -5161,39 +5264,39 @@ advance - 895 + 1550 endConnector - 298 + 133 extender glyph lbrack.bt startConnector - 298 + 133 advance - 326 + 400 endConnector - 109 + 133 extender glyph lbrack.ex startConnector - 109 + 133 advance - 895 + 1550 endConnector - 298 + 133 extender glyph lbrack.tp startConnector - 298 + 133 @@ -5205,27 +5308,27 @@ advance - 480 + 400 endConnector - 160 + 133 extender glyph lceil.ex startConnector - 160 + 133 advance - 1531 + 2700 endConnector - 510 + 133 extender glyph - lceil.tp + lceil.v4 startConnector - 510 + 133 @@ -5237,27 +5340,27 @@ advance - 1531 + 2700 endConnector - 510 + 133 extender glyph - lfloor.bt + lfloor.v4 startConnector - 510 + 133 advance - 480 + 400 endConnector - 160 + 133 extender glyph lceil.ex startConnector - 160 + 133 @@ -5269,39 +5372,103 @@ advance - 897 + 1700 endConnector - 299 + 133 extender glyph lparen.bt startConnector - 299 + 133 advance - 326 + 400 endConnector - 109 + 133 extender glyph lparen.ex startConnector - 109 + 133 advance - 897 + 1700 endConnector - 299 + 133 extender glyph lparen.tp startConnector - 299 + 133 + + + + mid + + italic + 0 + parts + + + advance + 925 + endConnector + 308 + extender + + glyph + mid + startConnector + 308 + + + advance + 925 + endConnector + 308 + extender + + glyph + mid + startConnector + 308 + + + + parallel + + italic + 0 + parts + + + advance + 925 + endConnector + 308 + extender + + glyph + parallel + startConnector + 308 + + + advance + 925 + endConnector + 308 + extender + + glyph + parallel + startConnector + 308 @@ -5313,39 +5480,39 @@ advance - 895 + 1550 endConnector - 298 + 133 extender glyph rBrack.bt startConnector - 298 + 133 advance - 326 + 400 endConnector - 109 + 133 extender glyph rBrack.ex startConnector - 109 + 133 advance - 895 + 1550 endConnector - 298 + 133 extender glyph rBrack.tp startConnector - 298 + 133 @@ -5357,63 +5524,63 @@ advance - 737 + 800 endConnector - 246 + 70 extender glyph rbrace.bt startConnector - 246 + 70 advance - 326 + 200 endConnector - 109 + 70 extender glyph vbrace.ex startConnector - 109 + 70 advance - 777 + 1500 endConnector - 259 + 70 extender glyph rbracemid startConnector - 259 + 70 advance - 326 + 200 endConnector - 109 + 70 extender glyph vbrace.ex startConnector - 109 + 70 advance - 737 + 800 endConnector - 246 + 70 extender glyph rbrace.tp startConnector - 246 + 70 @@ -5425,39 +5592,39 @@ advance - 895 + 1550 endConnector - 298 + 133 extender glyph rbrack.bt startConnector - 298 + 133 advance - 326 + 400 endConnector - 109 + 133 extender glyph rbrack.ex startConnector - 109 + 133 advance - 895 + 1550 endConnector - 298 + 133 extender glyph rbrack.tp startConnector - 298 + 133 @@ -5469,27 +5636,27 @@ advance - 480 + 400 endConnector - 160 + 133 extender glyph rceil.ex startConnector - 160 + 133 advance - 1531 + 2700 endConnector - 510 + 133 extender glyph - rceil.tp + rceil.v4 startConnector - 510 + 133 @@ -5501,27 +5668,27 @@ advance - 1531 + 2700 endConnector - 510 + 133 extender glyph - rfloor.bt + rfloor.v4 startConnector - 510 + 133 advance - 480 + 400 endConnector - 160 + 133 extender glyph rceil.ex startConnector - 160 + 133 @@ -5533,39 +5700,39 @@ advance - 897 + 1700 endConnector - 299 + 133 extender glyph rparen.bt startConnector - 299 + 133 advance - 326 + 400 endConnector - 109 + 133 extender glyph rparen.ex startConnector - 109 + 133 advance - 897 + 1700 endConnector - 299 + 133 extender glyph rparen.tp startConnector - 299 + 133 @@ -5697,27 +5864,27 @@ advance - 1200 + 2700 endConnector - 400 + 133 extender glyph - vert.v2 + vert.v4 startConnector - 400 + 133 advance - 472 + 400 endConnector - 157 + 133 extender glyph vert.ex startConnector - 157 + 133 @@ -5730,9 +5897,13 @@ Bbbsum.v1 Downarrow - + + Downarrow + Uparrow - + + Uparrow + Updownarrow Vert @@ -5740,12 +5911,16 @@ Vert Vert.v1 Vert.v2 + Vert.v3 + Vert.v4 Vvert Vvert Vvert.v1 Vvert.v2 + Vvert.v3 + Vvert.v4 awint @@ -5846,7 +6021,9 @@ coprodsans.v1 downarrow - + + downarrow + fint fint @@ -5991,6 +6168,10 @@ slash.v3 slash.v4 + mid + + mid + oiiint oiiint @@ -6066,6 +6247,10 @@ ointcw ointcw.v1 + parallel + + parallel + prod prod @@ -6201,7 +6386,9 @@ sumsans.v1 uparrow - + + uparrow + updownarrow varidotsint @@ -6304,6 +6491,8 @@ vert vert.v1 vert.v2 + vert.v3 + vert.v4 version diff --git a/Sources/SwiftMath/mathFonts.bundle/KpMath-Sans.otf b/Sources/SwiftMath/mathFonts.bundle/KpMath-Sans.otf index 0aa129e..39be8cd 100644 Binary files a/Sources/SwiftMath/mathFonts.bundle/KpMath-Sans.otf and b/Sources/SwiftMath/mathFonts.bundle/KpMath-Sans.otf differ diff --git a/Sources/SwiftMath/mathFonts.bundle/KpMath-Sans.plist b/Sources/SwiftMath/mathFonts.bundle/KpMath-Sans.plist index 7a63c88..eed7a59 100644 --- a/Sources/SwiftMath/mathFonts.bundle/KpMath-Sans.plist +++ b/Sources/SwiftMath/mathFonts.bundle/KpMath-Sans.plist @@ -35,9 +35,17 @@ hookabovecomb -220 imath - 176 + 149 + imath.sst + 160 + imath.st + 164 jmath - 221 + 181 + jmath.sst + 176 + jmath.st + 163 mbfBeta 304 mbfGamma @@ -1332,6 +1340,16 @@ 32737 ocirc -220 + overleftharpoon + -268 + overleftrightarrow + -335 + overrightarc + -275 + overrightarrow + -268 + overrightharpoon + -268 widebreve -205 widecheck @@ -1360,7 +1378,7 @@ DisplayOperatorMinHeight 1500 FlattenedAccentBaseHeight - 670 + 650 FractionDenomDisplayStyleGapMin 150 FractionDenominatorDisplayStyleShiftDown @@ -1394,15 +1412,15 @@ OverbarVerticalGap 150 RadicalDegreeBottomRaisePercent - 55 + 60 RadicalDisplayStyleVerticalGap 170 RadicalExtraAscender 50 RadicalKernAfterDegree - -560 + -600 RadicalKernBeforeDegree - 280 + 340 RadicalRuleThickness 50 RadicalVerticalGap @@ -1468,8 +1486,73 @@ h_variants + Leftarrow + + Leftarrow + Longleftarrow + + Leftrightarrow + + Leftrightarrow + Longleftrightarrow + + Mapsfrom + + Mapsfrom + Longmapsfrom + + Mapsto + + Mapsto + Longmapsto + + Rightarrow + + Rightarrow + Longrightarrow + + equal + + equiv + + hookleftarrow + + hookrightarrow + + leftarrow + + leftarrow + longleftarrow + + leftarrowtail + + leftharpoondown + + leftharpoonup + + leftrightarrow + + leftrightarrow + longleftrightarrow + + leftrightarrows + + leftrightharpoons + + mapsfrom + + mapsfrom + longmapsfrom + + mapsto + + mapsto + longmapsto + mathunderbar + minus + overbrace overbrace @@ -1489,6 +1572,10 @@ overleftharpoon + overleftrightarrow + + overleftrightarrow.h1 + overparen overparen @@ -1512,6 +1599,25 @@ overrightharpoon + rightarrow + + rightarrow + longrightarrow + + rightarrowtail + + rightharpoondown + + rightharpoonup + + rightleftarrows + + rightleftharpoons + + twoheadleftarrow + + twoheadrightarrow + underbrace underbrace @@ -1563,6 +1669,7 @@ widebreve widebreve + widebreve.h0 widebreve.h1 widebreve.h2 widebreve.h3 @@ -2964,27 +3071,27 @@ advance - 1200 + 2700 endConnector - 400 + 133 extender glyph - Vert.v2 + Vert.v4 startConnector - 400 + 133 advance - 472 + 400 endConnector - 157 + 133 extender glyph Vert.ex startConnector - 157 + 133 @@ -2996,27 +3103,27 @@ advance - 1200 + 2700 endConnector - 400 + 133 extender glyph - Vvert.v2 + Vvert.v4 startConnector - 400 + 133 advance - 472 + 400 endConnector - 157 + 133 extender glyph Vvert.ex startConnector - 157 + 133 @@ -3104,39 +3211,39 @@ advance - 895 + 1550 endConnector - 298 + 133 extender glyph lBrack.bt startConnector - 298 + 133 advance - 346 + 400 endConnector - 115 + 133 extender glyph lBrack.ex startConnector - 115 + 133 advance - 895 + 1550 endConnector - 298 + 133 extender glyph lBrack.tp startConnector - 298 + 133 @@ -3148,63 +3255,63 @@ advance - 737 + 800 endConnector - 246 + 67 extender glyph lbrace.bt startConnector - 246 + 67 advance - 326 + 200 endConnector - 109 + 67 extender glyph vbrace.ex startConnector - 109 + 67 advance - 777 + 1500 endConnector - 259 + 67 extender glyph lbracemid startConnector - 259 + 67 advance - 326 + 200 endConnector - 109 + 67 extender glyph vbrace.ex startConnector - 109 + 67 advance - 737 + 800 endConnector - 246 + 67 extender glyph lbrace.tp startConnector - 246 + 67 @@ -3216,39 +3323,39 @@ advance - 895 + 1550 endConnector - 298 + 133 extender glyph lbrack.bt startConnector - 298 + 133 advance - 326 + 400 endConnector - 109 + 133 extender glyph lbrack.ex startConnector - 109 + 133 advance - 895 + 1550 endConnector - 298 + 133 extender glyph lbrack.tp startConnector - 298 + 133 @@ -3260,27 +3367,27 @@ advance - 480 + 400 endConnector - 160 + 133 extender glyph lceil.ex startConnector - 160 + 133 advance - 1531 + 2700 endConnector - 510 + 133 extender glyph - lceil.tp + lceil.v4 startConnector - 510 + 133 @@ -3292,27 +3399,27 @@ advance - 1531 + 2700 endConnector - 510 + 133 extender glyph - lfloor.bt + lfloor.v4 startConnector - 510 + 133 advance - 480 + 400 endConnector - 160 + 133 extender glyph lceil.ex startConnector - 160 + 133 @@ -3324,39 +3431,103 @@ advance - 897 + 1700 endConnector - 299 + 133 extender glyph lparen.bt startConnector - 299 + 133 advance - 326 + 400 endConnector - 109 + 133 extender glyph lparen.ex startConnector - 109 + 133 advance - 897 + 1700 endConnector - 299 + 133 extender glyph lparen.tp startConnector - 299 + 133 + + + + mid + + italic + 0 + parts + + + advance + 925 + endConnector + 308 + extender + + glyph + mid + startConnector + 308 + + + advance + 925 + endConnector + 308 + extender + + glyph + mid + startConnector + 308 + + + + parallel + + italic + 0 + parts + + + advance + 925 + endConnector + 308 + extender + + glyph + parallel + startConnector + 308 + + + advance + 925 + endConnector + 308 + extender + + glyph + parallel + startConnector + 308 @@ -3368,39 +3539,39 @@ advance - 895 + 1550 endConnector - 298 + 133 extender glyph rBrack.bt startConnector - 298 + 133 advance - 326 + 400 endConnector - 109 + 133 extender glyph rBrack.ex startConnector - 109 + 133 advance - 895 + 1550 endConnector - 298 + 133 extender glyph rBrack.tp startConnector - 298 + 133 @@ -3412,63 +3583,63 @@ advance - 737 + 800 endConnector - 246 + 67 extender glyph rbrace.bt startConnector - 246 + 67 advance - 326 + 200 endConnector - 109 + 67 extender glyph vbrace.ex startConnector - 109 + 67 advance - 777 + 1500 endConnector - 259 + 67 extender glyph rbracemid startConnector - 259 + 67 advance - 326 + 200 endConnector - 109 + 67 extender glyph vbrace.ex startConnector - 109 + 67 advance - 737 + 800 endConnector - 246 + 67 extender glyph rbrace.tp startConnector - 246 + 267 @@ -3480,39 +3651,39 @@ advance - 895 + 1550 endConnector - 298 + 133 extender glyph rbrack.bt startConnector - 298 + 133 advance - 326 + 400 endConnector - 109 + 133 extender glyph rbrack.ex startConnector - 109 + 133 advance - 895 + 1550 endConnector - 298 + 133 extender glyph rbrack.tp startConnector - 298 + 133 @@ -3524,27 +3695,27 @@ advance - 480 + 400 endConnector - 160 + 133 extender glyph rceil.ex startConnector - 160 + 133 advance - 1531 + 2700 endConnector - 510 + 133 extender glyph - rceil.tp + rceil.v4 startConnector - 510 + 133 @@ -3556,27 +3727,27 @@ advance - 1531 + 2700 endConnector - 510 + 133 extender glyph - rfloor.bt + rfloor.v4 startConnector - 510 + 133 advance - 480 + 400 endConnector - 160 + 133 extender glyph rceil.ex startConnector - 160 + 133 @@ -3588,39 +3759,39 @@ advance - 897 + 1700 endConnector - 299 + 133 extender glyph rparen.bt startConnector - 299 + 133 advance - 326 + 400 endConnector - 109 + 133 extender glyph rparen.ex startConnector - 109 + 133 advance - 897 + 1700 endConnector - 299 + 133 extender glyph rparen.tp startConnector - 299 + 133 @@ -3752,27 +3923,27 @@ advance - 1200 + 2700 endConnector - 400 + 133 extender glyph - vert.v2 + vert.v4 startConnector - 400 + 133 advance - 472 + 400 endConnector - 157 + 133 extender glyph vert.ex startConnector - 157 + 133 @@ -3785,9 +3956,13 @@ Bbbsum.v1 Downarrow - + + Downarrow + Uparrow - + + Uparrow + Updownarrow Vert @@ -3795,12 +3970,16 @@ Vert Vert.v1 Vert.v2 + Vert.v3 + Vert.v4 Vvert Vvert Vvert.v1 Vvert.v2 + Vvert.v3 + Vvert.v4 awint @@ -3896,7 +4075,9 @@ coprod.v1 downarrow - + + downarrow + fint fint @@ -4040,6 +4221,10 @@ slash.v3 slash.v4 + mid + + mid + oiiint oiiint @@ -4114,6 +4299,10 @@ ointcw ointcw.v1 + parallel + + parallel + prod prod @@ -4236,7 +4425,9 @@ sum.v1 uparrow - + + uparrow + updownarrow varidotsint @@ -4338,6 +4529,8 @@ vert vert.v1 vert.v2 + vert.v3 + vert.v4 version diff --git a/Sources/SwiftMath/mathFonts.bundle/math_table_to_plist.py b/Sources/SwiftMath/mathFonts.bundle/math_table_to_plist.py new file mode 100644 index 0000000..1831cb1 --- /dev/null +++ b/Sources/SwiftMath/mathFonts.bundle/math_table_to_plist.py @@ -0,0 +1,205 @@ +#!/usr/local/bin/python3 +import plistlib +import sys +from fontTools.ttLib import TTFont + +def usage(code): + print('Usage math_table_to_plist.py ') + sys.exit(code) + +def process_font(font_file, out_file): + font = TTFont(font_file) + math_table = font['MATH'].table + constants = get_constants(math_table) + italic_c = get_italic_correction(math_table) + v_variants = get_v_variants(math_table) + h_variants = get_h_variants(math_table) + assembly = get_v_assembly(math_table) + accents = get_accent_attachments(math_table) + pl = { + "version" : "1.3", + "constants": constants, + "v_variants" : v_variants, + "h_variants" : h_variants, + "italic" : italic_c, + "accents" : accents, + "v_assembly" : assembly } + ofile = open(out_file, 'w+b') + plistlib.dump(pl, ofile) + ofile.close() + +def get_constants(math_table): + constants = math_table.MathConstants + if constants is None: + raise 'Cannot find MathConstants in MATH table' + + int_consts = [ 'ScriptPercentScaleDown', + 'ScriptScriptPercentScaleDown', + 'DelimitedSubFormulaMinHeight', + 'DisplayOperatorMinHeight', + 'RadicalDegreeBottomRaisePercent'] + consts = { c : getattr(constants, c) for c in int_consts } + + record_consts = [ 'MathLeading', + 'AxisHeight', + 'AccentBaseHeight', + 'FlattenedAccentBaseHeight', + 'SubscriptShiftDown', + 'SubscriptTopMax', + 'SubscriptBaselineDropMin', + 'SuperscriptShiftUp', + 'SuperscriptShiftUpCramped', + 'SuperscriptBottomMin', + 'SuperscriptBaselineDropMax', + 'SubSuperscriptGapMin', + 'SuperscriptBottomMaxWithSubscript', + 'SpaceAfterScript', + 'UpperLimitGapMin', + 'UpperLimitBaselineRiseMin', + 'LowerLimitGapMin', + 'LowerLimitBaselineDropMin', + 'StackTopShiftUp', + 'StackTopDisplayStyleShiftUp', + 'StackBottomShiftDown', + 'StackBottomDisplayStyleShiftDown', + 'StackGapMin', + 'StackDisplayStyleGapMin', + 'StretchStackTopShiftUp', + 'StretchStackBottomShiftDown', + 'StretchStackGapAboveMin', + 'StretchStackGapBelowMin', + 'FractionNumeratorShiftUp', + 'FractionNumeratorDisplayStyleShiftUp', + 'FractionDenominatorShiftDown', + 'FractionDenominatorDisplayStyleShiftDown', + 'FractionNumeratorGapMin', + 'FractionNumDisplayStyleGapMin', + 'FractionRuleThickness', + 'FractionDenominatorGapMin', + 'FractionDenomDisplayStyleGapMin', + 'SkewedFractionHorizontalGap', + 'SkewedFractionVerticalGap', + 'OverbarVerticalGap', + 'OverbarRuleThickness', + 'OverbarExtraAscender', + 'UnderbarVerticalGap', + 'UnderbarRuleThickness', + 'UnderbarExtraDescender', + 'RadicalVerticalGap', + 'RadicalDisplayStyleVerticalGap', + 'RadicalRuleThickness', + 'RadicalExtraAscender', + 'RadicalKernBeforeDegree', + 'RadicalKernAfterDegree', + ] + consts_2 = { c : getattr(constants, c).Value for c in record_consts } + consts.update(consts_2) + + variants = math_table.MathVariants + consts['MinConnectorOverlap'] = variants.MinConnectorOverlap + return consts + +def get_italic_correction(math_table): + glyph_info = math_table.MathGlyphInfo + if glyph_info is None: + raise "Cannot find MathGlyphInfo in MATH table." + italic = glyph_info.MathItalicsCorrectionInfo + if italic is None: + raise "Cannot find Italic Correction in GlyphInfo" + + glyphs = italic.Coverage.glyphs + count = italic.ItalicsCorrectionCount + records = italic.ItalicsCorrection + italic_dict = {} + for i in range(count): + name = glyphs[i] + record = records[i] + if record.DeviceTable is not None: + raise "Don't know how to process device table for italic correction." + italic_dict[name] = record.Value + return italic_dict + +def get_accent_attachments(math_table): + glyph_info = math_table.MathGlyphInfo + if glyph_info is None: + raise "Cannot find MathGlyphInfo in MATH table." + attach = glyph_info.MathTopAccentAttachment + if attach is None: + raise "Cannot find Top Accent Attachment in GlyphInfo" + + glyphs = attach.TopAccentCoverage.glyphs + count = attach.TopAccentAttachmentCount + records = attach.TopAccentAttachment + attach_dict = {} + for i in range(count): + name = glyphs[i] + record = records[i] + if record.DeviceTable is not None: + raise "Don't know how to process device table for accent attachment." + attach_dict[name] = record.Value + return attach_dict + +def get_v_variants(math_table): + variants = math_table.MathVariants + vglyphs = variants.VertGlyphCoverage.glyphs + vconstruction = variants.VertGlyphConstruction + count = variants.VertGlyphCount + variant_dict = {} + for i in range(count): + name = vglyphs[i] + record = vconstruction[i] + glyph_variants = [x.VariantGlyph for x in + record.MathGlyphVariantRecord] + variant_dict[name] = glyph_variants + return variant_dict + +def get_h_variants(math_table): + variants = math_table.MathVariants + hglyphs = variants.HorizGlyphCoverage.glyphs + hconstruction = variants.HorizGlyphConstruction + count = variants.HorizGlyphCount + variant_dict = {} + for i in range(count): + name = hglyphs[i] + record = hconstruction[i] + glyph_variants = [x.VariantGlyph for x in + record.MathGlyphVariantRecord] + variant_dict[name] = glyph_variants + return variant_dict + +def get_v_assembly(math_table): + variants = math_table.MathVariants + vglyphs = variants.VertGlyphCoverage.glyphs + vconstruction = variants.VertGlyphConstruction + count = variants.VertGlyphCount + assembly_dict = {} + for i in range(count): + name = vglyphs[i] + record = vconstruction[i] + assembly = record.GlyphAssembly + if assembly is not None: + # There is an assembly for this glyph + italic = assembly.ItalicsCorrection.Value + parts = [part_dict(part) for part in assembly.PartRecords] + assembly_dict[name] = { + "italic" : assembly.ItalicsCorrection.Value, + "parts" : parts } + return assembly_dict + +def part_dict(part): + return { + "glyph": part.glyph, + "startConnector" : part.StartConnectorLength, + "endConnector" : part.EndConnectorLength, + "advance" : part.FullAdvance, + "extender" : (part.PartFlags == 1) } + +def main(): + if len(sys.argv) != 3: + usage(1) + font_file = sys.argv[1] + plist_file = sys.argv[2] + process_font(font_file, plist_file) + +if __name__ == '__main__': + main()