示例#1
0
        Baseline2Top()
    ]),
    ('blue',
     [Shrink2TextHeight(),
      Shrink2TextWidth(),
      Right2Right(),
      XHeight2Top()]),
        #('green', [
        #    Shrink2TextHeight(), Shrink2TextWidth(),
        #    Left2Left(), CapHeight2Bottom()]),
    ('red', [
        Shrink2TextHeight(),
        Shrink2TextWidth(),
        Center2Center(),
        Baseline2Bottom()
    ]),
        #('blue', [
        #    Shrink2TextHeight(), Shrink2TextWidth(),
        #    Right2Right(), XHeight2Bottom()]),
):
    style = dict(font=f, fontSize=100, textFill=color(name=c))
    bs = context.newString(t, style=style)
    newTextBox(bs,
               parent=page,
               fill=(0.5, 0.5, 0.5, 0.5),
               conditions=conditions)

page.solve()

doc.export('_export/WordAlignment.pdf')
示例#2
0
               autoPages=NUM_PAGES,
               originTop=False,
               baselineGrid=BASELINE)
# Get the default page view of the document and set viewing parameters
view = doc.view
view.showTextOverflowMarker = True  # Shows as [+] marker on bottom-right of page.
# TODO: Fix the Arrow-connection drawing
view.showFlowConnections = False  # Draw arrows between elements of there is a flow.
view.showOrigin = True  # Show position of elements as cross-hair
view.showGrid = [GRID_COL_BG, GRID_ROW_BG,
                 GRID_SQR_BG]  # Set types of grid lines to show for background
view.showBaselineGrid = True  # Show default baseline grid of the column lines.

page = doc[1]

bs = context.newString('Headline Kphx',
                       style=dict(font=f, fontSize=150, textFill=(1, 0, 0)))
e = newTextBox(bs,
               x=100,
               y=300,
               parent=page,
               conditions=[Fit2Width(),
                           Shrink2TextHeight(),
                           CapHeight2Top()])
print(sorted(e.baselines), e.parent.top, e.top, e.bottom, e.bs.size,
      context.b.textSize(e.bs.s))
page.solve()
print(sorted(e.baselines), e.parent.top, e.top, e.bottom, e.bs.size,
      context.b.textSize(e.bs.s))
print(e.textLines)
doc.export('_export/HeadlineAlignment.pdf')
示例#3
0
#     TextFlowWithContext.py
#
#     Calculate the overflowing text and add it to another column.
#
#     This example shows the most basic version, using only DrawBot functions.
#     The overflow text takes the same parameters for the Formatted String as the
#     original text had.
#
from pagebotcocoa.contexts.drawbot.drawbotcontext import DrawBotContext

context = DrawBotContext()

W = H = 500
PADDING = 30
CW = (W - 3 * PADDING) / 2
CH = H - 2 * PADDING

context.newPage(W, H)

style = dict(font='Verdana',
             textFill=(1, 0, 0),
             fontSize=14,
             leading=16,
             firstLineIndent=20)
bs = context.newString('AAA ' * 300, style=style)

box = (PADDING, PADDING, CW, CH)
context.textBox(bs, box)
overflow = context.textOverflow(bs, box)
context.textBox(overflow, (PADDING + CW + PADDING, PADDING, CW, CH))