def createStretchyRadical(aFont):
    radicalCodePoint = 0x221a
    mathfont.createSquareGlyph(aFont, radicalCodePoint)
    g = aFont.createChar(-1, "size1")
    mathfont.drawRectangleGlyph(g, mathfont.em, 2 * mathfont.em, 0)
    g = aFont.createChar(-1, "size2")
    mathfont.drawRectangleGlyph(g, mathfont.em, 3 * mathfont.em, 0)
    g = aFont.createChar(-1, "size3")
    mathfont.drawRectangleGlyph(g, mathfont.em, 4 * mathfont.em, 0)
    overlap = mathfont.em / 2
    aFont[radicalCodePoint].verticalVariants = "radical size1 size2 size3"
    aFont[radicalCodePoint].verticalComponents = \
        (("size2", False, 0, mathfont.em, 3 * mathfont.em), \
         ("size1", True, mathfont.em, mathfont.em, 2 * mathfont.em))
Пример #2
0
def createStretchyRadical(aFont):
    radicalCodePoint = 0x221a
    mathfont.createSquareGlyph(aFont, radicalCodePoint)
    g = aFont.createChar(-1, "size1")
    mathfont.drawRectangleGlyph(g, mathfont.em, 2 * mathfont.em, 0)
    g = aFont.createChar(-1, "size2")
    mathfont.drawRectangleGlyph(g, mathfont.em, 3 * mathfont.em, 0)
    g = aFont.createChar(-1, "size3")
    mathfont.drawRectangleGlyph(g, mathfont.em, 4 * mathfont.em, 0)
    aFont[radicalCodePoint].verticalVariants = "radical size1 size2 size3"
    # Part: (glyphName, isExtender, startConnector, endConnector, fullAdvance)
    aFont.math.MinConnectorOverlap = 0
    aFont[radicalCodePoint].verticalComponents = \
        (("size2", False, 0, mathfont.em, 3 * mathfont.em), \
         ("size1", True, mathfont.em, mathfont.em, 2 * mathfont.em))
Пример #3
0
# overscript is an accent.
font.math.UpperLimitBaselineRiseMin = 0
font.math.StretchStackTopShiftUp = 0
font.math.AccentBaseHeight = 2 * mathfont.em
font.math.OverbarVerticalGap = 0

createSizeVariants(font)
for key in operatorDictionary:
    value = operatorDictionary[key]
    for c in value["characters"]:
        if c in font:
            continue
        if c == NonBreakingSpace:
            g = font.createChar(c)
            mathfont.drawRectangleGlyph(g, mathfont.em, mathfont.em / 3, 0)
        else:
            mathfont.createSquareGlyph(font, c)
        createStretchy(font, c, c in inlineAxisOperators)
mathfont.save(font)

# Generate the python file.
for key in operatorDictionary:
    del operatorDictionary[key]["characters"]  # Remove this temporary value.
JSON = {
    "comment":
    "This file was automatically generated by operator-dictionary.py. Do not edit.",
    "dictionary": operatorDictionary
}
with open('../support/operator-dictionary.json', 'w') as fp:
    json.dump(JSON, fp, sort_keys=True, ensure_ascii=True)
Пример #4
0
#!/usr/bin/python

from utils import mathfont
import fontforge

nAryWhiteVerticalBarCodePoint = 0x2AFF
v1 = 5 * mathfont.em
f = mathfont.create("largeop-displayoperatorminheight%d" % v1,
                    "Copyright (c) 2016 MathML Association")
f.math.DisplayOperatorMinHeight = v1
mathfont.createSquareGlyph(f, nAryWhiteVerticalBarCodePoint)
g = f.createChar(-1, "uni2AFF.display")
mathfont.drawRectangleGlyph(g, mathfont.em, v1, 0)
f[nAryWhiteVerticalBarCodePoint].verticalVariants = "uni2AFF uni2AFF.display"
mathfont.save(f)

v1 = 2 * mathfont.em
v2 = 3 * mathfont.em
f = mathfont.create(
    "largeop-displayoperatorminheight%d-2AFF-italiccorrection%d" % (v1, v2),
    "Copyright (c) 2018 Igalia S.L.")
f.math.DisplayOperatorMinHeight = v1
mathfont.createSquareGlyph(f, nAryWhiteVerticalBarCodePoint)
g = f.createChar(-1, "uni2AFF.display")
p = g.glyphPen()
p.moveTo(0, 0)
p.lineTo(v2, v1)
p.lineTo(v2 + mathfont.em, v1)
p.lineTo(mathfont.em, 0)
p.closePath()
g.width = mathfont.em + v2
Пример #5
0
#!/usr/bin/python

from utils import mathfont
import fontforge

nAryWhiteVerticalBarCodePoint = 0x2AFF
v1 = 5 * mathfont.em
f = mathfont.create("largeop-displayoperatorminheight%d" % v1)
f.math.DisplayOperatorMinHeight = v1
mathfont.createSquareGlyph(f, nAryWhiteVerticalBarCodePoint)
g = f.createChar(-1, "uni2AFF.display")
mathfont.drawRectangleGlyph(g, mathfont.em, v1, 0)
f[nAryWhiteVerticalBarCodePoint].verticalVariants = "uni2AFF uni2AFF.display"
mathfont.save(f)

v1 = 2 * mathfont.em
v2 = 3 * mathfont.em
f = mathfont.create("largeop-displayoperatorminheight%d-2AFF-italiccorrection%d" % (v1, v2))
f.copyright = "Copyright (c) 2018 Igalia S.L."
f.math.DisplayOperatorMinHeight = v1
mathfont.createSquareGlyph(f, nAryWhiteVerticalBarCodePoint)
g = f.createChar(-1, "uni2AFF.display")
p = g.glyphPen()
p.moveTo(0, 0)
p.lineTo(v2, v1)
p.lineTo(v2 + mathfont.em, v1)
p.lineTo(mathfont.em, 0)
p.closePath();
g.width = mathfont.em + v2
g.italicCorrection = v2
f[nAryWhiteVerticalBarCodePoint].verticalVariants = "uni2AFF uni2AFF.display"
Пример #6
0
#!/usr/bin/python

from utils import mathfont
import fontforge

nArySumCodePoint = 0x2211 # largeop operator

v = 3 * mathfont.em
f = mathfont.create("limits-lowerlimitbaselinedropmin%d" % v)
mathfont.createSquareGlyph(f, nArySumCodePoint)
f.math.LowerLimitBaselineDropMin = v
f.math.LowerLimitGapMin = 0
f.math.OverbarExtraAscender = 0
f.math.OverbarVerticalGap = 0
f.math.StretchStackBottomShiftDown = 0
f.math.StretchStackGapAboveMin = 0
f.math.StretchStackGapBelowMin = 0
f.math.StretchStackTopShiftUp = 0
f.math.UnderbarExtraDescender = 0
f.math.UnderbarVerticalGap = 0
f.math.UpperLimitBaselineRiseMin = 0
f.math.UpperLimitGapMin = 0
mathfont.save(f)

v = 11 * mathfont.em
f = mathfont.create("limits-lowerlimitgapmin%d" % v)
mathfont.createSquareGlyph(f, nArySumCodePoint)
f.math.LowerLimitBaselineDropMin = 0
f.math.LowerLimitGapMin = v
f.math.OverbarExtraAscender = 0
f.math.OverbarVerticalGap = 0
Пример #7
0
# Set parameters for accent tests so that we only have large gap when
# overscript is an accent.
font.math.UpperLimitBaselineRiseMin = 0
font.math.StretchStackTopShiftUp = 0
font.math.AccentBaseHeight = 2 * mathfont.em
font.math.OverbarVerticalGap = 0

mathfont.createSizeVariants(font, True)

# Ensure a glyph exists for the combining characters that are handled specially
# in the specification:
# U+0338 COMBINING LONG SOLIDUS OVERLAY
# U+20D2 COMBINING LONG VERTICAL LINE OVERLAY
for combining_character in [0x338, 0x20D2]:
    mathfont.createSquareGlyph(font, combining_character)

for key in operatorDictionary:
    value = operatorDictionary[key]
    for c in value["characters"]:
        if c in font:
            continue
        if c == NonBreakingSpace:
            g = font.createChar(c)
            mathfont.drawRectangleGlyph(g, mathfont.em, mathfont.em // 3, 0)
        else:
            mathfont.createSquareGlyph(font, c)
        mathfont.createStretchy(font, c, c in inlineAxisOperators)
mathfont.save(font)

# Generate the python file.
Пример #8
0
#!/usr/bin/python

from utils import mathfont
import fontforge

arrowCodePoint = 0x2192  # horizontal stretch operator

v = 3 * mathfont.em
f = mathfont.create("stretchstack-bottomshiftdown%d" % v)
mathfont.createSquareGlyph(f, arrowCodePoint)
f.math.LowerLimitBaselineDropMin = 0
f.math.LowerLimitGapMin = 0
f.math.OverbarExtraAscender = 0
f.math.OverbarVerticalGap = 0
f.math.StretchStackBottomShiftDown = v
f.math.StretchStackGapAboveMin = 0
f.math.StretchStackGapBelowMin = 0
f.math.StretchStackTopShiftUp = 0
f.math.UnderbarExtraDescender = 0
f.math.UnderbarVerticalGap = 0
f.math.UpperLimitBaselineRiseMin = 0
f.math.UpperLimitGapMin = 0
mathfont.save(f)

v = 11 * mathfont.em
f = mathfont.create("stretchstack-gapbelowmin%d" % v)
mathfont.createSquareGlyph(f, arrowCodePoint)
f.math.LowerLimitBaselineDropMin = 0
f.math.LowerLimitGapMin = 0
f.math.OverbarExtraAscender = 0
f.math.OverbarVerticalGap = 0
Пример #9
0
#!/usr/bin/python

from utils import mathfont
import fontforge

breveCodePoint = 0x2D8 # accent operator
degreeCodePoint = 0xB0 # nonaccent operator
accentBaseHeight = 4 * mathfont.em

v = 3 * mathfont.em
f = mathfont.create("underover-accentbaseheight%d-overbarextraascender%d" % (accentBaseHeight, v))
mathfont.createSquareGlyph(f, breveCodePoint)
mathfont.createSquareGlyph(f, degreeCodePoint)
f.math.AccentBaseHeight = accentBaseHeight
f.math.LowerLimitBaselineDropMin = 0
f.math.LowerLimitGapMin = 0
f.math.OverbarExtraAscender = v
f.math.OverbarVerticalGap = 0
f.math.StretchStackBottomShiftDown = 0
f.math.StretchStackGapAboveMin = 0
f.math.StretchStackGapBelowMin = 0
f.math.StretchStackTopShiftUp = 0
f.math.UnderbarExtraDescender = 0
f.math.UnderbarVerticalGap = 0
f.math.UpperLimitBaselineRiseMin = 0
f.math.UpperLimitGapMin = 0
mathfont.save(f)

v = 11 * mathfont.em
f = mathfont.create("underover-accentbaseheight%d-overbarverticalgap%d" % (accentBaseHeight, v))
mathfont.createSquareGlyph(f, breveCodePoint)
Пример #10
0
#!/usr/bin/python

from utils import mathfont
import fontforge

breveCodePoint = 0x2D8  # accent operator
degreeCodePoint = 0xB0  # nonaccent operator
accentBaseHeight = 4 * mathfont.em

v = 3 * mathfont.em
f = mathfont.create("underover-accentbaseheight%d-overbarextraascender%d" %
                    (accentBaseHeight, v))
mathfont.createSquareGlyph(f, breveCodePoint)
mathfont.createSquareGlyph(f, degreeCodePoint)
f.math.AccentBaseHeight = accentBaseHeight
f.math.LowerLimitBaselineDropMin = 0
f.math.LowerLimitGapMin = 0
f.math.OverbarExtraAscender = v
f.math.OverbarVerticalGap = 0
f.math.StretchStackBottomShiftDown = 0
f.math.StretchStackGapAboveMin = 0
f.math.StretchStackGapBelowMin = 0
f.math.StretchStackTopShiftUp = 0
f.math.UnderbarExtraDescender = 0
f.math.UnderbarVerticalGap = 0
f.math.UpperLimitBaselineRiseMin = 0
f.math.UpperLimitGapMin = 0
mathfont.save(f)

v = 11 * mathfont.em
f = mathfont.create("underover-accentbaseheight%d-overbarverticalgap%d" %
Пример #11
0
#!/usr/bin/env python3

from utils import mathfont
import fontforge

verticalArrowCodePoint = 0x21A8
v1 = 5 * mathfont.em
v2 = 14 * mathfont.em
f = mathfont.create("axisheight%d-verticalarrow%d" % (v1, v2),
                    "Copyright (c) 2016 MathML Association")
f.math.AxisHeight = v1
f.math.MinConnectorOverlap = 0
mathfont.createSquareGlyph(f, verticalArrowCodePoint)
g = f.createChar(-1, "size1")
mathfont.drawRectangleGlyph(g, mathfont.em, v2 / 2, 0)
g = f.createChar(-1, "size2")
mathfont.drawRectangleGlyph(g, mathfont.em, v2, 0)
g = f.createChar(-1, "bot")
mathfont.drawRectangleGlyph(g, mathfont.em, v2 + v1, 0)
g = f.createChar(-1, "ext")
mathfont.drawRectangleGlyph(g, mathfont.em, mathfont.em, 0)
f[verticalArrowCodePoint].verticalVariants = "uni21A8 size1 size2"
# Part: (glyphName, isExtender, startConnector, endConnector, fullAdvance)
f[verticalArrowCodePoint].verticalComponents = \
  (("bot", False, 0, mathfont.em, v2 + v1), ("ext", True, mathfont.em, mathfont.em, mathfont.em))
mathfont.save(f)
Пример #12
0
#!/usr/bin/python

from utils import mathfont
import fontforge

arrowCodePoint = 0x2192 # horizontal stretch operator

v = 3 * mathfont.em
f = mathfont.create("stretchstack-bottomshiftdown%d" % v,
                    "Copyright (c) 2016 MathML Association")
mathfont.createSquareGlyph(f, arrowCodePoint)
f.math.LowerLimitBaselineDropMin = 0
f.math.LowerLimitGapMin = 0
f.math.OverbarExtraAscender = 0
f.math.OverbarVerticalGap = 0
f.math.StretchStackBottomShiftDown = v
f.math.StretchStackGapAboveMin = 0
f.math.StretchStackGapBelowMin = 0
f.math.StretchStackTopShiftUp = 0
f.math.UnderbarExtraDescender = 0
f.math.UnderbarVerticalGap = 0
f.math.UpperLimitBaselineRiseMin = 0
f.math.UpperLimitGapMin = 0
mathfont.save(f)

v = 11 * mathfont.em
f = mathfont.create("stretchstack-gapbelowmin%d" % v,
                    "Copyright (c) 2016 MathML Association")
mathfont.createSquareGlyph(f, arrowCodePoint)
f.math.LowerLimitBaselineDropMin = 0
f.math.LowerLimitGapMin = 0
Пример #13
0
font.math.LowerLimitGapMin = 0
font.math.StretchStackBottomShiftDown = 0
font.math.StretchStackGapAboveMin = 0
font.math.UnderbarVerticalGap = 0
font.math.UnderbarExtraDescender = 0
font.math.UpperLimitBaselineRiseMin = 0
font.math.UpperLimitGapMin = 0
font.math.StretchStackTopShiftUp = 0
font.math.StretchStackGapBelowMin = 0
font.math.OverbarVerticalGap = 0
font.math.AccentBaseHeight = 0
font.math.OverbarExtraAscender = 0

# These two characters will be stretchable in both directions.
horizontalArrow = 0x295A  # LEFTWARDS HARPOON WITH BARB UP FROM BAR
verticalArrow = 0x295C  # UPWARDS HARPOON WITH BARB RIGHT FROM BAR

mathfont.createSizeVariants(font)

# Add stretchy vertical and horizontal constructions for the horizontal arrow.
mathfont.createSquareGlyph(font, horizontalArrow)
mathfont.createStretchy(font, horizontalArrow, True)
mathfont.createStretchy(font, horizontalArrow, False)

# Add stretchy vertical and horizontal constructions for the vertical arrow.
mathfont.createSquareGlyph(font, verticalArrow)
mathfont.createStretchy(font, verticalArrow, True)
mathfont.createStretchy(font, verticalArrow, False)

mathfont.save(font)
Пример #14
0
#!/usr/bin/python

from utils import mathfont
import fontforge

verticalArrowCodePoint = 0x21A8
v1 = 5 * mathfont.em
v2 = 14 * mathfont.em
f = mathfont.create("axisheight%d-verticalarrow%d" % (v1, v2))
f.math.AxisHeight = v1
mathfont.createSquareGlyph(f, verticalArrowCodePoint)
g = f.createChar(-1, "size1")
mathfont.drawRectangleGlyph(g, mathfont.em, v2 / 2, 0)
g = f.createChar(-1, "size2")
mathfont.drawRectangleGlyph(g, mathfont.em, v2, 0)
g = f.createChar(-1, "bot")
mathfont.drawRectangleGlyph(g, mathfont.em, v2 + v1, 0)
g = f.createChar(-1, "ext")
mathfont.drawRectangleGlyph(g, mathfont.em, mathfont.em, 0)
f[verticalArrowCodePoint].verticalVariants = "uni21A8 size1 size2"
f[verticalArrowCodePoint].verticalComponents = \
  (("bot", False, 0, 0, mathfont.em), ("ext", True, 0, 0, mathfont.em));
mathfont.save(f)