def makeHeader(page, font): page.padding = PADDING #newImage('gallery/Fog35KeyMap.png', parent=page, z=100, conditions=[Fit2WidthSides(), Top2TopSide()]) header = newRect(h=inch(1), padding=pt(8), mb=inch(0.6), parent=page, fill=0.4, conditions=[Fit2Width(), Top2Top()]) title = context.newString('Key map', style=titleStyle) newTextBox(title, w=page.pw / 3, fill=0.5, parent=header, pt=12, mr=8, borderTop=dict(stroke=whiteColor, strokeWidth=SHADOW), borderLeft=dict(stroke=whiteColor, strokeWidth=SHADOW), borderRight=dict(stroke=blackColor, strokeWidth=SHADOW), borderBottom=dict(stroke=blackColor, strokeWidth=SHADOW), conditions=[Left2Left(), Fit2Height()]) t = 'Size: %s Font: %s\nNotice: © %s\nPrinted by PageBot on %s' % \ (pt(SQSIZE), font.path.split('/')[-1], font.info.copyright, now()) fontInfo = context.newString(t, style=fontInfoStyle) newTextBox( fontInfo, fill=1, parent=header, margin=0, padding=pt(4), borderTop=dict(stroke=blackColor, strokeWidth=SHADOW), borderLeft=dict(stroke=blackColor, strokeWidth=SHADOW), conditions=[Right2Right(), Float2Left(), Fit2Right(), Fit2Height()])
def makeHeader(page, font): page.padding = PADDING header = newRect(h=inch(1), padding=pt(8), mb=inch(0.6), parent=page, fill=0.4, conditions=[Fit2Width(), Top2Top()]) title = context.newString('Key map', style=titleStyle) mr = pt(8) newTextBox( title, w=page.pw * 0.35, fill=0.5, parent=header, pt=pt(12), # Padding top mr=mr, # Margin right of the "Key map" text box element borderTop=dict(stroke=whiteColor, strokeWidth=SHADOW), borderLeft=dict(stroke=whiteColor, strokeWidth=SHADOW), borderRight=dict(stroke=blackColor, strokeWidth=SHADOW), borderBottom=dict(stroke=blackColor, strokeWidth=SHADOW), conditions=[Left2Left(), Fit2Height()]) t = 'Size: %s Font: %s\nNotice: © %s\nPrinted by PageBot on %s' % \ (pt(SQSIZE), font.path.split('/')[-1], font.info.copyright, now().datetime) fontInfo = context.newString(t, style=fontInfoStyle) newTextBox(fontInfo, fill=1, parent=header, margin=0, w=page.pw * 0.65 - 3 * mr, padding=pt(4), borderTop=dict(stroke=blackColor, strokeWidth=SHADOW), borderLeft=dict(stroke=blackColor, strokeWidth=SHADOW), conditions=[Right2Right(), Top2Top(), Fit2Height()]) page.solve()
def setPageStyle(page, index): if SHOW_BACKGROUND: bgi = newImage(BACKGROUND_PDF, z=-10, parent=page, index=index // 2) #, conditions=[Fit()]) bgi.size = inch(W * 2, H) if page.isRight: bgi.x -= W # Page numbers dy1 = BASELINE + pt(4) dy2 = BASELINE if page.isLeft: bs = context.newString('FALL 2018', style=styles['typeTitleRight']) newTextBox(bs, w=CW, h=page.pb - dy1, parent=page, conditions=[Bottom2SideBottom(), Right2Right()], bleed=0) bs = context.newString(page.pn[0], style=styles['pnLeft']) newTextBox(bs, w=CW, h=page.pb - dy2, parent=page, conditions=[Bottom2SideBottom(), Left2Left()], bleed=0) else: bs = context.newString('TYPE No. 3', style=styles['typeTitleLeft']) newTextBox(bs, w=CW, h=page.pb - dy1, parent=page, conditions=[Bottom2SideBottom(), Left2Left()], bleed=0) bs = context.newString(page.pn[0], style=styles['pnRight']) newTextBox(bs, w=CW, h=page.pb - dy2, parent=page, conditions=[Bottom2SideBottom(), Right2Right()], bleed=0) page.solve()
def setPageStyle(page, index): if page.isLeft: page.bleed = BLEED_LEFT page.padding = '3p1.5', LM, '4p1.5', RM else: page.bleed = BLEED_RIGHT page.padding = '3p1.5', RM, '4p1.5', LM page.gridX = (CW, GUTTER), (CW, GUTTER), (CW, GUTTER), (CW, 0) page.gridY = (CH, GUTTER), (CH, GUTTER), (CH, GUTTER), (CH, GUTTER), (CH, GUTTER), (CH, GUTTER), (CH, GUTTER), (CH, 0) #newTextBox(parent=page, name=BOX_NAME, fill=0.9, nextElementName=BOX_NAME, bleed=0, # conditions=[Fit()]) if SHOW_TEMPLATE: bgi = newImage(TEMPLATE_PDF, z=-10, parent=page, index=index//2)#, conditions=[Fit()]) bgi.size = inch(W*2, H) if page.isRight: bgi.x -= W # Page numbers dy1 = BASELINE+pt(4) dy2 = BASELINE if page.isLeft: bs = context.newString('FALL 2018', style=styles['typeTitleRight']) newTextBox(bs, w=CW, h=page.pb-dy1, parent=page, conditions=[Bottom2SideBottom(), Right2Right()], bleed=0) bs = context.newString(page.pn[0], style=styles['pnLeft']) newTextBox(bs, w=CW, h=page.pb-dy2, parent=page, conditions=[Bottom2SideBottom(), Left2Left()], bleed=0) else: bs = context.newString('TYPE No. 3', style=styles['typeTitleLeft']) newTextBox(bs, w=CW, h=page.pb-dy1, parent=page, conditions=[Bottom2SideBottom(), Left2Left()], bleed=0) bs = context.newString(page.pn[0], style=styles['pnRight']) newTextBox(bs, w=CW, h=page.pb-dy2, parent=page, conditions=[Bottom2SideBottom(), Right2Right()], bleed=0) path = '../../../Art_TYPE-3/Firsts_images_TYPE-3/1. page-number-printed-1470.pdf' if page.pn[0] == startPage: pass elif page.pn[0] == startPage+1: pass else: pass page.solve()
def makeDocument(families): u"""Create the main document in the defined size with a couple of automatic empty pages.""" # Calculate the amount of pages to create numPages = 1 # Add one page for the original page scan. for family in families: numPages += len(family) # Length of the family is the amount of fonts. numPages = min(numPages, MAX_PAGES - 1) doc = Document(w=W, h=H, title='Variable Font Sample Page', originTop=False, autoPages=numPages, context=context, gridX=GRID_X, gridY=GRID_Y) pn = 1 page = doc[pn] page.ch = 0 # No vertical grid page.padding = PADDING page.gridX = GRID_X newImage(ATF_PATH, x=0, y=0, w=W, parent=page) # Get default view from the document and set the viewing parameters. view = doc.view view.padding = inch( 0.5) # For showing cropmarks and such, make > mm(20) or inch(1). view.showPageCropMarks = True # Won't show if there is not padding in the view. view.showPageFrame = SHOW_FRAMES # No frame in case PAPER_COLOR exists to be shown. view.showPagePadding = SHOW_FRAMES # No frame in case PAPER_COLOR exists to be shown. view.showPageRegistrationMarks = True view.showGrid = SHOW_GRID # Show GRID_X lines view.showPageNameInfo = True # Show file name and date of the document view.showTextOverflowMarker = False # Don't show marker in case Filibuster blurb is too long. # Build the pages for all fonts that include one of these patterns. pn += 1 for family in families[:1]: pn = buildSpecimenPages(doc, family, pn) if pn > MAX_PAGES: break doc.solve() return doc
def makeDocument(families): u"""Create the main document in the defined size with a couple of automatic empty pages.""" # Calculate the amount of pages to create numPages = len(families) + 1 # One family per spread. doc = Document(w=W, h=H, title='Variable Font Sample Page', originTop=False, startPage=0, autoPages=numPages, context=context, gridX=GRID_X, gridY=GRID_Y) # Get default view from the document and set the viewing parameters. view = doc.view view.padding = inch( 0.5) # For showing cropmarks and such, make >=20*MM or INCH. view.showPageCropMarks = True # Won't show if there is not padding in the view. view.showPageFrame = SHOW_FRAMES # No frame in case PAPER_COLOR exists to be shown. view.showPagePadding = SHOW_FRAMES # No frame in case PAPER_COLOR exists to be shown. view.showPageRegistrationMarks = True view.showGrid = SHOW_GRID # Show GRID_X lines view.showPageNameInfo = True # Show file name and date of the document view.showTextOverflowMarker = False # Don't show marker in case Filibuster blurb is too long. # Build the pages for all fonts that include one of these patterns. for family in families: page = doc[1] page.ch = pt(0) # No vertical grid page.padding = PADDING page.gridX = GRID_X newImage(FB_PATH_L, x=0, y=0, w=W / 2, parent=page) newImage(FB_PATH_R, x=W / 2, y=0, w=W / 2, parent=page) buildSpecimenPages(page, family) doc.solve() return doc
# Example baseline position, showing that start can be different from page side # or top of text box. BASELINE = pt(15) BASELINE_START = 3.5 * BASELINE PADDING = 5 * BASELINE # Page padding related to baseline in this example. doc = Document( size=B5, padding=PADDING, originTop=True, autoPages=3, # Create multiple pages, to show the page number/total pages. baselineGrid=BASELINE, baselineGridStart=BASELINE_START) view = doc.view # Get the current view of this document. Defaulse it PageView. view.padding = inch( 0.5) # Define padding of the view, so there is space for crop marks view.showBaselineGrid = [BASE_LINE_BG, BASE_INDEX_LEFT] # Set to True to show baseline index #view.showBaselineGrid = [BASE_LINE_BG, BASE_Y_LEFT] # Use this line to show vertical positions view.showPadding = True # Show the padding of the page. The size is then (page.pw, page.ph) view.showCropMarks = True view.showRegistrationMarks = True view.showNameInfo = True # Show document/name/date info in view padding area. view.showFrame = True # Show frame of the page size. # The page has no child elements, just showing the metrics of the padding and baseline. # Export the document showing the baselines of the page as horizontal lines and the padding. doc.export('_export/PageBaselines.pdf')
from pagebot.elements.pbimage2 import Image #context = FlatContext() context = getContext() # Example image that has nice areas to put text as example. imagePath = getResourcesPath() + '/images/peppertom_lowres_398x530.png' W = H = pt(1000) # Document size PADDING = pt(100) # Page padding on all sides # Create a new document with 1 page. Set overall size and padding. doc = Document(w=W, h=H, padding=PADDING, context=context, originTop=True) # Get the default page view of the document and set viewing parameters view = doc.view view.padding = inch(1) view.showFrame = True view.showPadding = True view.showColorBars = False view.showCropMarks = True view.showRegistrationMarks = True # Get the page page = doc[1] # Make image box as child element of the page and set its layout conditions. im = Image(imagePath, parent=page, conditions=[Fit()], showPadding=True, padding=100, stroke=(1, 0, 0))
dateStyle = dict(font=bodyFont, fontSize=pt(9), leading=BASELINE, textFill=0) urlStyle = dict(font=boldFont, fontSize=pt(9), leading=BASELINE, textFill=0) #============================================================================= # Create the document and define the viewing parameters # ............................................................................. doc = Document(w=W, h=H, originTop=False, gridX=gridX, gridY=gridY, baselineGrid=BASELINE, autoPages=PAGE_COUNT) # Set the viewing parameters view = doc.view view.padding = inch(0.5) view.showCropMarks = True view.showRegistrationMarks = True view.showNameInfo = True view.showGrid = [GRID_COL, GRID_ROW_BG] # Defaults to showing GRID_ view.showBaselines = [BASE_LINE, BASE_INDEX_RIGHT] view.showFrame = True view.showPadding = True view.showColorBars = False # Set to True for color calibration bars. # ============================================================================= # Add background image from existing newspaper. # This assumes that our document has the same size/proportions # as the background image. # And overlay transparant gray layer to see template as shaded # .............................................................................
SHOW_TEMPLATE = False # True shows the FB Specimen scan at the back of every page to show alignment. SHOW_GRID = False # Show page grid and elements backgrounds in opaque colors. if SHOW_GRID: # Some debugging colors, used when SHOW_GRID is on. DEBUG_COLOR0 = (0.7, 0.3, 0.7, 0.2) DEBUG_COLOR1 = (0.3, 0.3, 0.7, 0.2) DEBUG_COLOR2 = (0.7, 0.3, 0.3, 0.2) DEBUG_COLOR3 = (0.3, 0.7, 0.3, 0.2) else: # Otherwise ignore the background colors of the column elements. DEBUG_COLOR0 = DEBUG_COLOR1 = DEBUG_COLOR2 = DEBUG_COLOR3 = None blurb = Blurb() # Basic page metrics. U = pt(8) # Page layout units, to unite baseline grid and gutter. W = inch(6.34 * 2) # Draw as spread, as page view does not support them (yet) H = inch(10) # Copy size from the original specimen. # Hard coded padding sizes derived from the scan. PT, PR, PB, PL = PADDING = pt(23, 34, 28, 28) # Page padding top, right, bottom, left L = 2 * U # Baseline leading G = 2 * U # Default gutter = space between the columns GM = 7 * U # Gutter in middle of the spread. # Hard coded column sizes derived from the scan. C = (W - PL - PR - GM - 4 * G) / 6 C3 = 3 * C + 2 * G # Construct the grid pattern. # Last value None means that there is no gutter running inside the right padding. GRID_X = ((C, G), (C, G), (C, GM), (C, G), (C, G), (C, None)) GRID_Y = ((H - PT - PB, None), )
# Copyright (c) 2016+ Buro Petr van Blokland + Claudia Mens # www.pagebot.io # # P A G E B O T # # Licensed under MIT conditions # # Supporting DrawBot, www.drawbot.com # Supporting Flat, xxyxyz.org/flat # ----------------------------------------------------------------------------- # # metrics.py # from pagebot.toolbox.units import inch, p, pt W, H = inch(8, 10.875) BLEED_LEFT = p(1), 0, p(1), p(1) # 1 Pica bleed on top, left bottom BLEED_RIGHT = p(1), p(1), p(1), 0 # 1 Pica bleed in top, right, bottom GUTTER = p(2) ML, MR = p(5, 6) CW = (W - ML - MR - 3 * GUTTER) / 4 CH = p(5.5) BASELINE = pt(12) BASELINE_START = pt(44) PADDING_LEFT = '3p1.5', ML, '4p1.5', MR PADDING_RIGHT = '3p1.5', MR, '4p1.5', ML GRIDX = (CW, GUTTER), (CW, GUTTER), (CW, GUTTER), (CW, GUTTER) GRIDY = (CH, GUTTER), (CH, GUTTER), (CH, GUTTER), (CH, GUTTER), (CH, GUTTER), ( CH, GUTTER), (CH, GUTTER), (CH, 0)
#from pagebot.contexts.flatcontext import FlatContext from pagebot.contexts.platform import getContext from pagebot.fonttoolbox.objects.font import findFont from pagebot.document import Document from pagebot.elements import * # Import all types of page-child elements for convenience from pagebot.toolbox.color import color from pagebot.toolbox.units import em, p, pt, mm, inch from pagebot.style import CENTER from pagebot.toolbox.color import blueColor, darkGrayColor, redColor, Color, noColor, color from pagebot.conditions import * # Import all conditions for convenience. from pagebot.constants import GRID_COL, GRID_ROW, GRID_SQR #context = FlatContext() context = getContext() W, H = pt(inch(9)), pt(inch(12)) # Document size PADDING = pt(mm(13)) # Page padding on all sides G = mm(4) # 2 Pica gutter PW = W - 2 * PADDING # Usable padded page width PH = H - 2 * PADDING # Usable padded page height CW = (PW - (G * 2)) # Column width CH = PH # Hard coded grid, will be automatic in later examples. GRIDX = ((CW, G), (CW, 0)) GRIDY = ((CH, 0), ) # Abstract Paragraph text = """Roanne Adams launched RoAndCo in 2006 after being recognized as one of Print magazine’s “New Visual Artist (20 under 30).” In 2010, she was named one of the city’s most “outstanding up-and-coming design professionals” by T: The New York Times Style Magazine and she received an Art Director’s Club Young Guns 9 award in 2011. Roanne currently serves on the Board of Directors for AIGA’s New York Chapter. With her keen eye for style and a skill for visually embodying brands’ personalities, Roanne has earned the trust and respect of clients and collaborators alike. Photography by James Chorous""" font = findFont('Roboto')
from pagebot.fonttoolbox.objects.font import findFont from pagebot.document import Document from pagebot.elements import * # Import all types of page-child elements for convenience from pagebot.toolbox.color import color from pagebot.toolbox.units import em, p, pt, mm, inch from pagebot.style import CENTER from pagebot.toolbox.color import blueColor, darkGrayColor, redColor, Color, noColor, color from pagebot.conditions import * # Import all conditions for convenience. from pagebot.constants import GRID_COL, GRID_ROW, GRID_SQR #context = FlatContext() context = getContext() # NEW: W, H = pt(inch(9)), pt(inch(12)) # Document size W, H = inch(9, 12) # Document size # NEW: Not need to convert to pt # PADDING = pt(mm(13)) # Page padding on all sides PADDING = mm(13) # Page padding on all sides G = mm(4) # 2 Pica gutter PW = W - 2 * PADDING # Usable padded page width PH = H - 2 * PADDING # Usable padded page height CW = (PW - (G * 2)) / 3 # Column width CH = PH # Hard coded grid, will be automatic in later examples. GRIDX = ((CW, G), (CW, 0)) GRIDY = ((CH, 0), ) text = """the moment when I realized that people were actually looking at my website. People thought I was good at what I did, and they were pushing me to do more of it. I began doing more freelance projects on the side, and that’s what eventually motivated me to freelance full-time. Going freelance and deciding to start your own studio are pretty big risks. Have you taken any other risks to move forward?
SHOW_TEMPLATE = False # True shows the ATF scan at the back of every page to show alignment. SHOW_GRID = False # Show page grid and elements backgrounds in opaque colors. if SHOW_GRID: # Some debugging colors, used when SHOW_GRID is on. DEBUG_COLOR0 = (0.7, 0.3, 0.7, 0.2) DEBUG_COLOR1 = (0.3, 0.3, 0.7, 0.2) DEBUG_COLOR2 = (0.7, 0.3, 0.3, 0.2) DEBUG_COLOR3 = (0.3, 0.7, 0.3, 0.2) else: # Otherwise ignore the background colors of the column elements. DEBUG_COLOR0 = DEBUG_COLOR1 = DEBUG_COLOR2 = DEBUG_COLOR3 = None blurb = Blurb() # Basic page metrics. U = pt(8) # Page layout units, to unite baseline grid and gutter. W = inch(7.3) # Copy size from original (?) ATF specimen. H = inch(11) # Hard coded padding sizes derived from the scan. PT, PR, PB, PL = PADDING = pt(36, 34, 75, 70) # Page padding top, right, bottom, left L = 2 * U # Baseline leading 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
from pagebot.contexts.platform import getContext from pagebot.style import TOP, BOTTOM from pagebot.fonttoolbox.objects.font import findFont from pagebot.document import Document from pagebot.elements import * # Import all types of page-child elements for convenience from pagebot.toolbox.color import color from pagebot.toolbox.units import em, p, pt, mm, inch from pagebot.style import CENTER from pagebot.toolbox.color import blueColor, darkGrayColor, redColor, Color, noColor, color from pagebot.conditions import * # Import all conditions for convenience. from pagebot.constants import GRID_COL, GRID_ROW, GRID_SQR #context = FlatContext() context = getContext() W, H = pt(inch(9)), pt( inch(12)) # Document size, It's in pt, if not, display error message. PADDING = pt(mm(13)) # Page padding on all sides G = mm(4) # 2 Pica gutter PW = W - 2 * PADDING # Usable padded page width PH = H - 2 * PADDING # Usable padded page height CW = (PW - (G * 2)) / 3 # Column width CH = PH # Hard coded grid, will be automatic in later examples. GRIDX = ((CW, G), (CW, 0)) GRIDY = ((CH, 0), ) text = """the moment when I realized that people were actually looking at my website. People thought I was good at what I did, and they were pushing me to do more of it. I began doing more freelance projects on the side, and that’s what eventually motivated me to freelance full-time. Going freelance and deciding to start your own studio are pretty big risks. Have you taken any other risks to move forward? I’ve taken a lot of risks, but I haven’t done anything so bold as risking my life or anything! If you have an appetite for it, take big risks when you’re young and have less responsibility—and before you have kids. Risk-taking is a good thing, but it does evolve into more risks. The longer I run my studio and the larger it grows, the risk of something going wrong or falling apart becomes greater. But your threshold for those scenarios becomes greater over the years.