Ejemplo n.º 1
0
def test(context):
    print("creating doc")
    doc = Document(w=W, h=H, context=context)
    doc.name = 'TextBoxes-%s' % doc.context.name
    print('# Testing text boxes in %s' % doc)

    page = doc[1]
    #s = getString(page)
    blurb = Blurb()
    txt = blurb.getBlurb('stylewars_bluray')

    i = len(txt.split('. ')[0]) + 1

    style = {'font': bungeeRegular, 'fontSize': 24, 'leading': 1.5}
    s = page.newString(txt[0:i], style=style)

    style = {'font': bungeeOutline, 'fontSize': 24, 'leading': 1.5}
    s += page.newString(txt[i:], style=style)

    w = W / 2 - 2 * M
    h = 460  #H - 2*M
    x = M
    y = H - M - h

    sc = color(0.3, 0.2, 0.1, 0.5)
    tb = newTextBox(s, x=x, y=y, w=w, h=h, parent=page, stroke=sc)
    y0 = H - M
    drawBaselines(x, y0, w, tb.baselines, s, page)

    # Get the rest of the text.
    txt = tb.getOverflow()
    style = {'font': pageBotBold, 'fontSize': 24, 'leading': 1.5}
    s = page.newString(txt, style=style)

    w = W / 2 - 2 * M
    h = 240  #H - 2*M
    x = M
    y = M

    tb = newTextBox(s, x=x, y=y, w=w, h=h, parent=page, stroke=sc)
    y0 = M + h
    drawBaselines(x, y0, w, tb.baselines, s, page)

    # Get the rest of the text.
    txt = tb.getOverflow()
    style = {'font': robotoRegular, 'fontSize': 24, 'leading': 1.5}
    s = page.newString(txt, style=style)

    h = 500
    x = W / 2
    y = M
    w = W / 2 - M
    tb = newTextBox(s, x=x, y=y, w=w, h=h, parent=page, stroke=sc)
    y0 = M + h
    drawBaselines(x, y0, w, tb.baselines, s, page)

    print('Starting doc build')
    doc.build()
Ejemplo n.º 2
0
GRIDX = []
GRIDY = []

SQ = 10

for i in range(1, int(W / SQ) + 1):
    GRIDX.append((pt(SQ)))

for i in range(1, int(H / SQ) + 1):
    GRIDY.append((pt(SQ)))

for contextName in ['DrawBot', 'Flat']:
    context = getContext(contextName)
    doc = Document(w=W, h=H, padding=30, context=context, originTop=False)
    doc.name = 'Grid-%s' % contextName
    page = doc[1]
    page.padding = (SQ, SQ, SQ, SQ)
    doc.gridX = GRIDX
    doc.gridY = GRIDY
    print(' * %s' % doc.name)
    doc.view.showGrid = True
    doc.view.showOrigin = True
    doc.view.showDimensions = True
    doc.view.showNameInfo = True
    doc.view.showColorBars = True
    #doc.view.showFrame = True
    #doc.view.showPadding = True
    #doc.view.showMargin = True
    #doc.view.showRegistrationMarks = True
    #style = getRootStyle()