def ini(): DEBUG = False # Make True to see grid and element frames. OUTPUT_FILE = 'DecovarAxes.pdf' FONT_PATH = pagebot.getFontPath() DecovarPath = FONT_PATH + 'fontbureau/Decovar-VF-chained3.ttf' #DecovarPath = u"/Users/petr/git/PageBotTYPETR/src/fonts/BitcountVar/BitcountGrid-GX.ttf" #decovarName = installFont(DecovarPath) #varFont = Font(DecovarPath) s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789' axes = varFont.axes print axes wght = axes['wght'][0] flow = axes['flow'][0] srif = axes['srif'][0] inli = axes['inli'][0] term = axes['term'][0] VARIABLES = [] for axisName, (minValue, defaultValue, maxValue) in axes.items(): VARIABLES.append( dict(name=axisName, ui='Slider', args=dict(value=defaultValue, minValue=minValue, maxValue=maxValue))) globals()[axisName] = defaultValue context.Variable(VARIABLES, globals())
def run(): LINE = 50 # Separator line. # F O N T S T U F F # Get the variable font. decovarPath = getFontPath() + '/fontbureau/Decovar-VF_2017-02-06.ttf' decovar = Font(decovarPath) if 1: # Font info stuff. # Font Info as in RoboFont objects print '-' * LINE print 'Family name:', decovar.info.familyName print 'Style name:', decovar.info.styleName print 'Path:', decovar.path print 'Units per em:', decovar.info.unitsPerEm if 1: # Variable stuff # Show the axes in this font. Key is axis name. Value is (minValue, defaultValue, maxValue) print '-' * LINE axes = decovar.axes # Get dictionary of axes in the font. print 'Axes (%d) in the font {name: (minValue, defaultValue, maxValue), ...}' % len( axes) print '.' * LINE print axes if 1: # Kerning stuff print '-' * LINE print 'Kerning (%d pairs) in %s' % (len( decovar.kerning), decovar.info.familyName) print '.' * LINE print decovar.kerning if 1: # Show the available tables in the TTFont print '-' * LINE print 'Tables in', decovar.info.familyName print '.' * LINE print decovar.ttFont.keys() # G L Y P H S T U F F if 1: g = decovar['A'] # Get the Glyph instance. print '-' * LINE print 'Glyph width of', g.name, g.width # Gets the value of ttFont['htmx'] print '.' * LINE print 'Add 10 to width and print again' g.width += 10 # We can change the value in the "live" font. f.save() print 'New width of', g.name, g.width print 'This give the interesting opportunity to let the page layout program alter values inside the font.' print 'if that is needed for a particular design.' if 1: # Info inside the TTGlyph structure. print '-' * LINE print 'help(g.ttGlyph)' print '.' * LINE help(g.ttGlyph)
def init(): DEBUG = False # Make True to see grid and element frames. FONT_PATH = pagebot.getFontPath() #fontPath = FONT_PATH + 'fontbureau/Decovar-VF-chained3.ttf' #fontPath = FONT_PATH + 'fontbureau/Decovar-VF-2axes.subset.ttf' #fontPath = FONT_PATH + 'fontbureau/Decovar-VF-2axes.ttf' fontPath = FONT_PATH + 'fontbureau/Decovar-VF-chained3.ttf' #fontPath = FONT_PATH + 'fontbureau/AmstelvarAlpha-Variations.ttf' fontPath = FONT_PATH + 'PromiseVar.ttf' #fontPath = FONT_PATH + 'BitcountGridVar.ttf' EXPORT_PATH = '_export/'+ fontPath.split('/')[-1].replace('ttf', 'pdf') varFont = Font(fontPath) varFontName = varFont.install() # Do DrawBot font install. axes = varFont.axes print axes RS = getRootStyle() RS['w'] = W = 600 RS['h'] = H = 600 M = 50
def _findFontPaths(self, path=None, fontPaths=None): u"""Recursively find the default PageBot font paths. Answer the dictioanary of name-path relations.""" if fontPaths is None: fontPaths = {} if path is None: path = getFontPath() for fileName in os.listdir(path): if fileName.startswith('.'): continue if not path.endswith('/'): path += '/' filePath = path + fileName if os.path.isdir(filePath): self._findFontPaths(filePath, fontPaths) # Recursively search in folder. elif fileName.lower().endswith( '.ttf') or fileName.lower().endswith('.otf'): fontPaths[fileName] = filePath return fontPaths
#==================== from math import pi, sin, cos import os from random import random, choice from copy import copy from fontTools.ttLib import TTFont from pagebot.elements import Element from pagebot.style import makeStyle #from pagebot.fonttoolbox.variationbuilder import generateInstance, drawGlyphPath from drawBot import fill, rect, oval, stroke, strokeWidth, installFont, installedFonts, FormattedString, moveTo, lineTo, newPath, drawPath #==================== DEBUG = False # Make True to see grid and element frames. FONT_PATH = pagebot.getFontPath() #fontPath = FONT_PATH + 'fontbureau/Decovar-VF-chained3.ttf' #fontPath = FONT_PATH + 'fontbureau/Decovar-VF-2axes.subset.ttf' #fontPath = FONT_PATH + 'fontbureau/Decovar-VF-2axes.ttf' fontPath = FONT_PATH + 'fontbureau/Decovar-VF-chained3.ttf' #fontPath = FONT_PATH + 'fontbureau/AmstelvarAlpha-Variations.ttf' #fontPath = FONT_PATH + 'PromiseVar.ttf' #fontPath = FONT_PATH + 'BitcountGridVar.ttf' EXPORT_PATH = '_export/' + fontPath.split('/')[-1].replace('ttf', 'pdf') varFont = Font(fontPath) varFontName = varFont.install() # Do DrawBot font install. axes = varFont.axes print axes RS = getRootStyle()
# For Variation Fonts we can use the plain Font-->TTFont wrapper for all styles. No need to use Family. from pagebot.fonttoolbox.objects.font import Font from pagebot.publications.typespecimen import TypeSpecimen #from pagebot.fonttoolbox.elements.variationcircle import VariationCircle import os from math import pi, sin, cos from random import random, choice from copy import copy from fontTools.ttLib import TTFont from pagebot.elements import Element from pagebot.style import makeStyle DEBUG = False # Make True to see grid and element frames. FONT_PATH = getFontPath() #fontPath = FONT_PATH + 'fontbureau/Decovar-VF-chained3.ttf' #fontPath = FONT_PATH + 'fontbureau/Decovar-VF-2axes.subset.ttf' #fontPath = FONT_PATH + 'fontbureau/Decovar-VF-2axes.ttf' fontPath = FONT_PATH + 'fontbureau/Decovar-VF-chained3.ttf' #fontPath = FONT_PATH + 'fontbureau/AmstelvarAlpha-Variations.ttf' fontPath = FONT_PATH + 'PromiseVar.ttf' #fontPath = FONT_PATH + 'BitcountGridVar.ttf' EXPORT_PATH = '_export/' + fontPath.split('/')[-1].replace('ttf', 'pdf') varFont = Font(fontPath) varFontName = varFont.install() # Do DrawBot font install. axes = varFont.axes print axes RS = getRootStyle()
# DecovarNameAnimation.py # # This script generates creates a Typetr logo as animated gif. # (takes around 10 minutes to run). # from fontTools.ttLib import TTFont from pagebot import getFontPath from pagebot.fonttoolbox.objects.ont import Font import pagebot.fonttoolbox.variablebuilder reload(pagebot.fonttoolbox.variablebuilder) from pagebot.fonttoolbox.variablebuilder import getVariableFont, drawGlyphPath EXPORT_PATH = '_export/DecovarAnimated002.gif' FONT_DIR = getFontPath() FONT_PATH = FONT_DIR + 'fontbureau/Decovar-VF_2017-02-06.ttf' TEXT = 'DECOVAR' F = 1 # Animation speed S = 5 #5 W = S * 6 * 10 * len(TEXT) - S * 10 H = S * 90 AXIS_FACTOR = 1000 FRAMES = 16 # Number of frames per sequence. MOVE = FRAMES / 80.0 STEP = 1 # 20 class AxisState(object):
# from __future__ import division import pagebot from pagebot.elements import * # For Variable Fonts we can use the plain Font-->TTFont wrapper for all styles. No need to use Family. from pagebot.fonttoolbox.objects.font import Font from pagebot.conditions import * from pagebot.publications.typespecimen import TypeSpecimen from pagebot.elements.variablefonts.variablecircle import VariableCircle OUTPUT_FILE = '_export/AmstelvarVariableCircle.pdf' CONDITIONS = [Fit2Width(), Float2Top()] # Stacking conditions for all elements in this page. fontPath = pagebot.getFontPath() + 'fontbureau/AmstelvarAlpha-VF.ttf' varFont = Font(fontPath) varFontName = varFont.install() # Do DrawBot font install. s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789' TERMINALS = ('trmA', 'trmB', 'trmC', 'trmD', 'trmE', 'trmF', 'trmG', 'trmH', 'trmF', 'trmG', 'trmK', 'trmL',) SKL = ('sklA', 'sklB', 'sklD') BLD = ('bldA', 'bldB') WMX = ('wmx2',) class VariableCircleSpecimen(TypeSpecimen): u"""Inherit from generic publication class the implements default specimen behavior.""" def getAxisCombinations(self): # Answer specific interesting combinations for axes in Decovar. combinations = []
from pagebot.fonttoolbox.objects.font import Font from pagebot.publications.typespecimen import TypeSpecimen from pagebot.elements.variablefonts.variablecube import VariableCube #from pagebot.elements.variablefonts.variablescatter import VariableScatter DEBUG = False # Make True to see grid and element frames. W, H = A4 PADDING = 20*MM NUM_PAGES = 5 # Number of pages to generate OUTPUT_FILE = 'AmstelvarRandomSpecimen.pdf' FONT_PATH = pagebot.getFontPath() # Location of PageBot fonts. AmstelVarPath = FONT_PATH + 'fontbureau/AmstelvarAlpha-Variables.ttf' # Installing the font in DrawBot #amstelVarName = installFont(AmstelVarPath) s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789' class VariableTypeSpecimen(TypeSpecimen): def getAxisCombinations(self): # Answer specific interesting combinations for axes in Decovar. combinations = [] for skl in SKL: for bld in BLD: combinations.append((skl, bld))
LANGUAGE = 'nl-be' # Tell RootStyle instance to use Dutch hyphenation.. MD_PATH = 'automatischePaginaCompositie_nl.md' # Path of the MarkDown text in local folder. EXPORT_PATH = '_export/AutomatischePaginaOpmaak.pdf' # Export part of generated PDF output document. MAIN_FLOW = 'main' # Element id of the text box on pages the hold the main text flow. # Some tracking presets H1_TRACK = H2_TRACK = 0.015 # 1/1000 of fontSize, multiplier factor. H3_TRACK = 0.030 # Tracking as relative factor to font size. P_TRACK = 0.030 VARIABLE_FONT = True if VARIABLE_FONT: # Path to the Variable font source, from which width/weight instances will be created. FONT_PATH = getFontPath() + '/fontBureau/AmstelvarAlpha-Variations.ttf' # Create instance, depending on the location in the Variable axes. LIGHT = getVariableFont(FONT_PATH, {"wght": 100, "wdth": 1000}) LIGHT_CONDENSED = getVariableFont(FONT_PATH, {"wght": 100, "wdth": 800}) BOOK_LIGHT = getVariableFont(FONT_PATH, {"wght": 175, "wdth": 1000}) BOOK_CONDENSED = getVariableFont(FONT_PATH, {"wght": 250, "wdth": 800}) BOOK = getVariableFont(FONT_PATH, {"wght": 250, "wdth": 1000}) BOOK_ITALIC = getVariableFont(FONT_PATH, {"wght": 250, "wdth": 1000}) MEDIUM = getVariableFont(FONT_PATH, {"wght": 400, "wdth": 1000}) SEMIBOLD = getVariableFont(FONT_PATH, {"wght": 400, "wdth": 1000}) SEMIBOLD_CONDENSED = getVariableFont(FONT_PATH, {"wght": 600, "wdth": 500}) BOLD = getVariableFont(FONT_PATH, {"wght": 800, "wdth": 1000}) BOLD_ITALIC = getVariableFont(FONT_PATH, {"wght": 800, "wdth": 1000}) BLACK = getVariableFont(FONT_PATH, {"wght": 1000, "wdth": 1000}) else: LIGHT_CONDENSED = 'Georgia'
# www.pagebot.io # Licensed under MIT conditions # # Supporting usage of DrawBot, www.drawbot.com # Supporting usage of Flat, https://github.com/xxyxyz/flat # ----------------------------------------------------------------------------- # # ShowFontContent.py # # import pagebot from pagebot.contexts import defaultContext as c from pagebot.fonttoolbox.objects.font import Font EXPORT_PATH = '_export/UpgradeFontOverviewr.pdf' FONT_PATH = pagebot.getFontPath() + "/fontbureau/AmstelvarAlpha-VF.ttf" FONT_PATH = u"/Users/petr/Desktop/TYPETR-git/TYPETR-Upgrade/scripts/export/ttf/Upgrade-Medium.ttf" L = 50 f = Font(FONT_PATH) # Names and text fields print '-- Names', '-' * L print 'Full name:', f.info.fullName print 'Family name:', f.info.familyName print 'Style name:', f.info.styleName print 'PS name:', f.info.psName print 'Designer:', f.info.designer print 'Description:', f.info.description print 'Trademark:', f.info.trademark # Metrics print '-- Metrics', '-' * L
# ----------------------------------------------------------------------------- # # P A G E B O T # # Copyright (c) 2016+ Buro Petr van Blokland + Claudia Mens & Font Bureau # www.pagebot.io # Licensed under MIT conditions # # Supporting usage of DrawBot, www.drawbot.com # Supporting usage of Flat, https://github.com/xxyxyz/flat # ----------------------------------------------------------------------------- # # ModifyFonts.py # import pagebot from pagebot.contexts import defaultContext as c from pagebot.fonttoolbox.objects.font import Font from pagebot.fonttoolbox.variablefontbuilder import getVariableFont, getConstrainedLocation fontPath = pagebot.getFontPath() f = Font(fontPath + '/fontbureau/AmstelvarAlpha-VF.ttf', install=False) # Now we have a variable font open. print f.axes # Get an instance at a certain location location = getConstrainedLocation(f, dict(wdth=3944 / 10, wght=760 / 10)) instance = getVariableFont(f, location, install=False, cached=False) c.drawPath(instance['H'].path, (100, 100), sx=0.4)