Ejemplo n.º 1
0
def draw(w, y, drawVariable):
    u"""
      Draw 3 lines of text: the boundaries of with the width axis and
      the interpolated width from the slider value.
      If the slider goes of the extremes, then the middle line
      stops at the boundary width.
    """
    d = fitVariableWidth(f, HEADLINE, w, HEADLINE_SIZE, condensedLocation,
                         wideLocation)
    # move the canvas
    c.save()
    if not drawVariable:
        c.translate(0, -H / 2 + PADDING / 2)
    drawPageFrame(d['width'] + 2 * M)
    c.restore()

    minWidth = d['condensedWidth']
    maxWidth = d['wideWidth']
    fixedWidth = minWidth + (maxWidth - minWidth) / 2
    dFixed = c.fitVariableWidth(f, HEADLINE, fixedWidth, HEADLINE_SIZE,
                                condensedLocation, wideLocation)

    if drawVariable:
        c.text(d['fs'], (PADDING + M, y - PADDING - M))
    else:
        # Draw the instance choice of 3
        if w < fixedWidth:
            c.text(d['condensedFs'], (PADDING + M, y - PADDING - M))
        elif w < maxWidth:
            c.text(dFixed['fs'], (PADDING + M, y - PADDING - M))
        else:
            c.text(d['wideFs'], (PADDING + M, y - PADDING - M))
Ejemplo n.º 2
0
print 'unitsPerEm:', f.info.unitsPerEm
# GPOS
print '-- GPOS', '-' * L
print 'gposFeatures:', f.info.gposFeatures
# GSUB
print '-- GSUB', '-' * L
print 'gsubFeatures:', f.info.gsubFeatures
# Glyph content of the font
print '-- Glyhps', '-' * L
print 'Char set:', f.info.charSet
print 'Glyph set:', f.info.glyphSet

W = H = 1000
GX = GY = 20
M = 50
# Scale em of 2048 back to page size.
glyphIndex = 1
s = 0.04
for y in range(GY):
    for x in range(GX):
        # Offset of drawing origin
        c.save()
        c.translate(M + (W - 2 * M) / GX * x,
                    H - M - (H - 2 * M) / GY * (y + 1))
        g = f[f.info.glyphSet[glyphIndex]]
        c.drawPath(g.path, (0, 0), s)
        glyphIndex += 1
        c.restore()

c.saveImage(EXPORT_PATH)
Ejemplo n.º 3
0
#
#     This script is using defaultContext, so it should be able to run it with flexContext.
#

import pagebot
from pagebot.contexts import defaultContext as c
from pagebot.fonttoolbox.objects.font import Font

EXPORT_PATH = '_export/AlteredGlyphWithPoints.pdf'
FONT_PATH = pagebot.getFontPath() + "/fontbureau/AmstelvarAlpha-VF.ttf"

W = H = 1000
# Scale em of 2048 back to page size.
s = 0.5
# Offset of drawing origin
c.translate(100, 100)
# Open the font and get the glyph
f = Font(FONT_PATH)
g = f['H']
print g.analyzer.stems
"""
# These are the points we have in the H
print 'List of APoints of the glyph:', g.points
# Get the 4th APoint instance, that has reference back to the glyph.points[p.index]
p = g.points[3]
# This is the point we got.
print 'glyph.points[3]:', p.x, p.y, 'Glyph:', p.glyph.name, 'Index:', p.index
# Change the point position. In DrawBot this works interactive while holding cmd-drag in selected d.
d = -80
p.x += d
p.y += d