def showAll(): """Shows all fonts that are shipped with PageBot.""" context = getContext() doc = Document(w=W, h=H, originTop=False, autoPages=1, context=context) page = doc[1] page.padding = P c1 = (Left2Left(), Fit2Right(), Float2Top()) # Group condition c2 = (Left2Left(), Float2Top()) # Title condition c3 = (Right2Right(), Float2Top()) # Speciment condition families = getFamilyPaths() fam = findFamily('Roboto') print(fam) fam = getFamily('Bungee') print(fam) fam = getFamily('BungeeOutline') print(fam) fam = getFamily('Roboto') #verboseFam(fam) fam = getFamily('RobotoCondensed') verboseFam(fam) fam = getFamily('PageBot') print(fam) for s in fam.getStyles(): print(' - %s' % s) #print(families) print('Number of families found: %d' % len(families)) fontPaths = getFontPaths() print('Number of fonts found: %d' % len(fontPaths)) tfp = getTestFontsPath() pbFonts = getPageBotFontPaths() print('Number of fonts shipped with PageBot: %d' % len(pbFonts)) #print(sorted(pbFonts.keys())) font = findFont('Roboto-Black') print('The Font object from the pagebot.fonttoolbox.objects module: %s' % font) print('It has %d glyphs.' % len(font)) i = 0 for pbFont in sorted(pbFonts.keys()): if 'Bungee' in pbFont or 'PageBot' in pbFont: # Filter some of the PageBot fonts. f = findFont(pbFont) if f is not None: i += 1 g = newGroup(parent=page, conditions=c1, padding=7, borderTop=1, strokeWidth=0) newText('%s\n' % pbFont, parent=g, conditions=c2, fontSize=16, strokeWidth=0) newText('ABCDEabcde012345', parent=g, conditions=c3, font=f, fontSize=pt(44), strokeWidth=0) if i > 10: page = page.next page.padding = P i = 0 doc.solve() doc.export('_export/Fonts.pdf')
G = 3*U # Default gutter = space between the columns # Hard coded column sizes derived from the scan. C1, C2, C3 = (150, 112, 112) # Construct the grid pattern. # Last value None means that there is no gutter running inside the right padding. GRID_X = ((C1, G), (C2, G), (C3, None)) GRID_Y = ((H - PT - PB, None),) # 1923 American Type Founders Specimen Book & Catalog # Path to the scan, used to show at first page of this document. ATF_PATH = 'images/ATFArtcraftBold.png' # Build the specimen pages for the font names that include these patterns. FAMILIES = ( getFamily('Upgrade'), #getFamily('Bungee'), #getFamily('Roboto'), #getFamily('AmstelvarAlpha') ) #labelFamily = getFamily('Roboto') labelFamily = getFamily('Upgrade') labelFont = labelFamily.findRegularFont() # Ask family to find the most regular font. labelStyle = dict(font=labelFont.path, fontSize=7, rLeading=1, paragraphTopSpacing=4, paragraphBottomSpacing=4) # Sample glyphs set in bottom right frame. Automatic add a spacing between all characters. GLYPH_SET = ' '.join(u'ABCDEFGHIJKLMNOPQRSTUVWXYZ&$1234567890abcdefghijklmnopqrstuvwxyz.,-‘:;!?') # Export in _export folder that does not commit in Git. Force to export PDF. DO_OPEN = False if SHOW_GRID:
from pagebot.elements import newRect, newTextBox # For clarity, most of the MakeABookCover.py example document is setup # as a sequential excecution of Python functions. For complex documents # this is not the best method. More functions and classes will be used in the # real templates, which are available from the PageBotTemplates repository. W, H = B4 W -= 48 # Make a bit more narrow format. BLEED = 8 # Export in folder that does not commit to Git. Force to export PDF. EXPORT_PATH = '_export/ABookCover.pdf' family = getFamily('Roboto') fontRegular = family.findFont('Regular') fontBold = family.findFont('Bold') fontItalic = family.findFont('Italic') ampersandFont = findFont('Georgia') def makeDocument(): u"""Demo random book cover generator.""" # Create new document with (w,h) and fixed amount of pages. # Make number of pages with default document size. # Initially make all pages default with template # One page, just the cover. doc = Document(w=W, h=H,
# from pagebot.contexts import defaultContext as context from pagebot.fonttoolbox.objects.family import getFamily from pagebot.style import CENTER from pagebot.document import Document from pagebot.elements import * from pagebot.conditions import * S = 0.2 # Document scale W = 1000 * S # Scaled 1 meter x 2 meter H = 2000 * S M = 80 * S PADDING = (2 * M, M, M, M) family = getFamily('Upgrade') fontRegular = family.findFont('Upgrade-Regular') fontMedium = family.findFont('Upgrade-Medium') fontBold = family.findFont('Upgrade-Bold') fontItalic = family.findFont('Upgrade-Italic') ddsStyle = dict(font=fontMedium.path, textFill=1, rLeading=0.9, xTextAlign=CENTER, fontSize=205 * S) welcomeStyle = dict(font=fontBold.path, rLeading=1.1, fontSize=90 * S, rTracking=0.45, xTextAlign=CENTER),
print('Total installed fonts: %d' % len(fontNames)) fontNames = context.installedFonts('Verdana') # ['Verdana', 'Verdana-Bold', 'Verdana-BoldItalic', 'Verdana-Italic'] print(fontNames) fontNames = context.installedFonts('Verdana-BoldItalic') # ['Verdana-BoldItalic'] print(fontNames) fontNames = context.installedFonts(['Verdana', 'Georgia']) # ['Georgia', 'Georgia-Bold', 'Georgia-BoldItalic', 'Georgia-Italic', 'Verdana', 'Verdana-Bold', 'Verdana-BoldItalic', 'Verdana-Italic'] print(fontNames) # The PageBot method to look for fonts is find a fanily with an exact name match family = getFamily('Bungee') # <PageBot Family Bungee (5 fonts)> print(family) font = getFont('Verdana-BoldItalic') font = findFont('Roboto') # None print(font) robotoRegular = findFont('Roboto-Regular') # <Font Roboto-Regular> print(robotoRegular) font = findFont('Roboto-cannot-be-found', default='Roboto-Regular') # <Font Roboto-Regular>
# Hard coded column sizes derived from the scan. C1, C2, C3 = (150, 112, 112) # Construct the grid pattern. # Last value None means that there is no gutter running inside the right padding. GRID_X = ((C1, G), (C2, G), (C3, None)) GRID_Y = ((H - PT - PB, None), ) # 1923 American Type Founders Specimen Book & Catalog # Path to the scan, used to show at first page of this document. ATF_PATH = 'resources/ATFArtcraftBold.png' # Build the specimen pages for the font names that include these patterns. FAMILIES = ( #getFamily('Upgrade'), #getFamily('PageBot'), getFamily('Bungee'), #getFamily('Roboto'), #getFamily('AmstelvarAlpha') ) labelFamily = getFamily('Roboto') #labelFamily = getFamily('Upgrade') labelFont = labelFamily.findRegularFont( ) # Ask family to find the most regular font. labelStyle = dict(font=labelFont.path, fontSize=7, leading=em(1), paragraphTopSpacing=4, paragraphBottomSpacing=-10) # Sample glyphs set in bottom right frame. Automatic add a spacing between all characters. GLYPH_SET = ' '.join(