예제 #1
0
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())
예제 #2
0
        UI.append(dict(name='Alternative_g', ui='CheckBox'))  # [ss09].
        UI.append(dict(name='LC_Figures', ui='CheckBox'))  # [onum].
    else:
        Italic_Shapes = random() < 0.2  # [ss08]
        Condensed = random() < 0.2  # [ss07]
        Slashed_Zero = random() < 0.5  # [zero]
        Smallcaps = random() < 0.3  # [smcp]
        Caps_As_Smallcaps = random() < 0.1  # [c2sc]
        Extended_Ascenders = random() < 0.7  # [ss01]
        Extended_Capitals = random() < 0.5  # [ss02]
        Extended_Descenders = random() < 0.7  # [ss03]
        Contrast_Pixel = random() < 0.5  # [ss04]
        Alternative_g = random() < 0.3  # [ss09]
        LC_Figures = random() < 0.3  # [onum]

    context.Variable(UI, globals())

    # Store Italics flag, so we can test if it changed.
    scriptGlobals.random_Features = Random_Features

    # If no Bitcount fonts could be found, open the browser on the TypeNetwork shop page and stop this script.
    fontNamePaths = collectFonts(
        searchName
    )  # Collect available fonts, filter into characteristics, as weight, italic, etc.
    if not fontNamePaths:
        print 'The %s family is not installed in your system. How about buying a license @typenetwork?' % familyName
        os.system('open %s/fonts/%s' % (typetrStoreUrl, familyName.lower()))
    else:
        drawSample()
        export()
예제 #3
0
        c.text(d['fs'], (PADDING + M, y - PADDING - M))
    else:
        # Draw the instance choice of 3
        if w < fixedWidth:
            c.text(d['condensedFs'], (PADDING + M, y - PADDING - M))
        elif w < maxWidth:
            c.text(dFixed['fs'], (PADDING + M, y - PADDING - M))
        else:
            c.text(d['wideFs'], (PADDING + M, y - PADDING - M))


if INTERACTIVE:
    #dict(name='ElementOrigin', ui='CheckBox', args=dict(value=False)),
    c.Variable([
        dict(name='Width',
             ui='Slider',
             args=dict(minValue=PADDING, value=200, maxValue=W - 2 * PADDING))
    ], globals())

    draw(Width)
else:
    pageFrame = None
    angle = 0
    while angle < 360:
        c.newPage(W, H)
        c.fill(0.8)
        c.rect(0, 0, W, H)
        dx = sin(radians(angle)) * 0.5 + 0.5
        w = W / 2 + (W - 2 * PADDING - W / 2) * dx
        draw(w, H - PADDING, True)
        draw(w, (H - PADDING) / 2, False)
예제 #4
0
# hardcoded constants:
W = H = 1000
M = 20
w = W - 2*M
h = H - 2*H

#dict(name='ElementOrigin', ui='CheckBox', args=dict(value=False)),
c.Variable(
  [dict(name='X', ui='Slider',
        args=dict(minValue=-W/2, value=0, maxValue=W/2)),
   dict(name='Y', ui='Slider',
        args=dict(minValue=-H/2, value=0, maxValue=H/2)),
   dict(name='N', ui='Slider',
        args=dict(minValue=8*2, value=8*8, maxValue=8*32)),
   dict(name='Sx', ui='Slider',
        args=dict(minValue=2, value=10, maxValue=40)),
   dict(name='Sy', ui='Slider',
        args=dict(minValue=2, value=10, maxValue=40)),
   dict(name='Exy', ui='Slider',
        args=dict(minValue=0.01, value=0.58, maxValue=1)),
   dict(name='D', ui='Slider',
        args=dict(minValue=0.1, value=0.5, maxValue=5))
  ], globals())


def drawSpiral():
    mx = W/2+X
    my = H/2+Y
    runs = False
    c.newPath()
    c.moveTo((mx, my))
예제 #5
0
    s = u"""글자가 일상이 된다 산돌커뮤니케이션 ABCD123 Latin すべての文化集団は,独自の言語,文字,書記システムを持つ.それゆえ,個々の書記システムをサイバースペースに移転することは. ABCD123 Latin included"""
    c.newPage(W, H)
    fsr = c.newString(s, style=dict(font='Generic-Regular', fontSize=FontSize))
    fsb = c.newString(s,
                      style=dict(font='Generic-Regular_Bold',
                                 fontSize=FontSize))
    fsbRed = c.newString(s,
                         style=dict(font='Generic-Regular_Bold',
                                    fill=(1, 0, 0),
                                    fontSize=FontSize))
    c.textBox(fsr, (100, 600, 820, 350))
    c.textBox(fsb, (100, 300, 820, 350))
    c.textBox(fsbRed, (100, 0, 820, 350))
    c.textBox(fsr, (100, 0, 820, 350))


if __name__ == '__main__':

    c.Variable(
        [
            #dict(name='ElementOrigin', ui='CheckBox',
            #     args=dict(value=False)),
            dict(name='FontSize',
                 ui='Slider',
                 args=dict(minValue=30, value=50, maxValue=120)),
        ],
        globals())

    run()
    c.saveImage('_export/TestKanjiFormattedString.pdf')
예제 #6
0
context.Variable(
    [
        dict(name='TerminalValue',
             ui='PopUpButton',
             args=dict(items=TERMINAL_VALUES_S)),
        dict(name='TerminalShape',
             ui='PopUpButton',
             args=dict(items=('Rounded [trmA]', 'Pointed [trmB]',
                              'Rounded slab [trmC]', 'Angled [trmD]',
                              'Cleaved [trmE]', 'Plussed [trmF]',
                              'Slabbed [trmG]', 'Rectangled [trmK]',
                              'Starred [trmL]'))),
        dict(name='SkeletonValue',
             ui='PopUpButton',
             args=dict(items=SKELETON_VALUES_S)),
        dict(name='SkeletonShape',
             ui='PopUpButton',
             args=dict(items=('Neon [sklA]', 'Cleaved [sklB]',
                              'Zebra [sklD]'))),
        dict(name='BlendValue',
             ui='PopUpButton',
             args=dict(items=BLEND_VALUES_S)),
        dict(name='BlendShape',
             ui='PopUpButton',
             args=dict(items=('Straight [bldA]', 'Leaved [bldB]'))),
        dict(name='WeightValue',
             ui='PopUpButton',
             args=dict(items=WEIGHT_VALUES_S)),

        # create a variable called 'useColor'
        # and the related ui is a CheckBox.
        #dict(name="useColor", ui="CheckBox"),
        # create a variable called 'c'
        # and the related ui is a ColorWell.
        #dict(name="c", ui="ColorWell")
    ],
    globals())
예제 #7
0
                                             xTextAlign=CENTER))
    nt = newTextBox(bs, x=100, y=100, conditions=conditions, parent=page, fill=(1, 1, 0))
    print bs.s
    #print nt.x, nt.y, nt.w, nt.h
    score = page.solve()
    #if score.fails:
    #    print score.fails
    #print nt.x, nt.y, nt.w, nt.h

    # Set the view parameters for the required output.
    view = doc.getView()
    view.w = view.h = W, H
    view.padding = 100 # Make view padding to show crop marks and frame
    view.showPageFrame = True
    view.showPageCropMarks = True
    view.showElementOrigin = False
    view.showElementDimensions = True

    return doc

if __name__ == '__main__':

    context.Variable([
        #dict(name='ElementOrigin', ui='CheckBox', args=dict(value=False)),
        dict(name='OriginTop', ui='CheckBox', args=dict(value=False)),
    ], globals())

    d = makeDocument()
    d.export('_export/DrawViewPageFrame.pdf')

    dict(name='INTERPOLATION',
         ui='Slider',
         args=dict(value=0.5, minValue=0, maxValue=1)),
    dict(name='CONNECT',
         ui='Slider',
         args=dict(value=30, minValue=0, maxValue=90)),
]
angle = -90
for axisName in axes:
    VARIABLES.append(
        dict(name=axisName,
             ui='Slider',
             args=dict(value=angle, minValue=-90, maxValue=270)))
    globals()[axisName] = axes[axisName][1]
    angle += 360 / len(axes)
context.Variable(VARIABLES, globals())


def makeDocument(rs):

    # 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
    doc = Document(rs, autoPages=1)

    # Change template of page 1
    page = doc[1]
    glyphName = 'A'
    angles = {}
    style = dict(fontSize=FONT_SIZE,
                 labelFont='Verdana',
예제 #9
0
#
#     Supporting usage of DrawBot, www.drawbot.com
#     Supporting usage of Flat, https://github.com/xxyxyz/flat
# -----------------------------------------------------------------------------
#
#     variables.py
#
from pagebot.contexts import defaultContext as context

if __name__ == '__main__':
    context.Variable([
        # create a variable called 'w'
        # and the related ui is a Slider.
        dict(name="w", ui="Slider"),
        # create a variable called 'h'
        # and the related ui is a Slider.
        dict(name="h", ui="Slider",
             args=dict(
                       # some vanilla specific
                       # setting for a slider
                       value=100,
                       minValue=50,
                       maxValue=300)),
        # create a variable called 'useColor'
        # and the related ui is a CheckBox.
        dict(name="useColor", ui="CheckBox"),
        # create a variable called 'c'
        # and the related ui is a ColorWell.
        dict(name="c", ui="ColorWell")
    ], globals())
예제 #10
0
    page.padding = pagePadding 
     
    # Resources
    blockFill = None #(1, 1, 0) # Use color to debug page area
    
    # Styles
    titleStyle =dict(font='Georgia', fontSize=26, rLeading=1.4, xTextAlign=CENTER, textFill=1)
    authorStyle = dict(font='Georgia-Italic', textFill=1, fontSize=18, xTextAlign=CENTER)
    headStyle = dict(font='Verdana-Bold', textFill=0, fontSize=14, rLeading=1.4, 
        xTextAlign=LEFT, paragraphTopSpacing=30, paragraphBottomSpacing=0)
    bodyStyle = dict(font='Verdana', textFill=0, fontSize=12, rLeading=1.4, 
        xTextAlign=LEFT, paragraphTopSpacing=10, hyphenation=True)
   
     
    score = page.solve()
    if score.fails:
        print 'Condition fails', score.fails 
    
    return doc # Answer the doc for further doing.

  
context.Variable([
    dict(name='PageWidth', ui='Slider', args=dict(minValue=MinPageW, value=PAGE_SIZE[0], maxValue=MaxPageW)),
    dict(name='PageHeight', ui='Slider', args=dict(minValue=MinPageH, value=PAGE_SIZE[1], maxValue=MaxPageH)),
], globals())

        
d = makeDocument()
d.export(EXPORT_PATH) 

예제 #11
0
        stroke=None,
    )

    score = page.solve()
    if score.fails:
        print score.fails

    return doc  # Answer the doc for further doing.


if __name__ == '__main__':

    c.Variable(
        [
            #dict(name='ElementOrigin', ui='CheckBox', args=dict(value=False)),
            dict(name='DoTextFlow', ui='CheckBox', args=dict(value=False)),
            dict(name='BoxWidth',
                 ui='Slider',
                 args=dict(minValue=200, value=500, maxValue=PageSize)),
            dict(name='PagePadding',
                 ui='Slider',
                 args=dict(minValue=0, value=30, maxValue=100)),
            dict(name='PageSize',
                 ui='Slider',
                 args=dict(minValue=200, value=500, maxValue=PageSize)),
        ],
        globals())

    d = makeDocument()
    d.export(EXPORT_PATH)
예제 #12
0
         args=dict(value=15, minValue=0, maxValue=90)),
]

#FIXME: put something into this axes dict:
#       shouldn't it be loaded from the varfont metadata ?
axes = {}
angle = -90
for axisName in axes:
    VARIABLES.append(
        dict(name=axisName,
             ui='Slider',
             args=dict(value=angle, minValue=-90, maxValue=270)))
    globals()[axisName] = axes[axisName][1]
    angle += 360 / len(axes)

c.Variable(VARIABLES, globals())


def makeDocument(rs):
    # 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
    doc = Document(rs, autoPages=1)

    # Change template of page 1
    page = doc[1]
    glyphName = 'A'
    angles = {}
    style = dict(fontSize=FONT_SIZE,
                 labelFont='Verdana',
                 axisNameFontSize=14,
예제 #13
0
                                              fill=(1, 0, 0))),
                       (self.x + self.w + 3, self.y + self.h - prevY - leading/2 - fontSize/4))
            prevY = y

    def _drawFrame(self):
        c.stroke(0, 0, 1)
        c.fill(None)
        c.rect(self.x, self.y, self.w, self.h)


W = 400
H = 600
G = 40

c.Variable([
    dict(name='W', ui='Slider', args=dict(minValue=200, value=400, maxValue=1000)),
    dict(name='H', ui='Slider', args=dict(minValue=200, value=600, maxValue=1000)),
], globals())


fs = c.newString(u'This åéöøa hêädliñe rúns over one or more lines.\n',
                 style=dict(align='left',
                            font='BitcountMonoDouble-RegularCircleItalic',
                            fontSize=24,
                            openTypeFeatures=dict(ss01=True,
                                                  ss02=True,
                                                  ss06=True),
                            lineHeight=26,
                            tracking=1.2))
fs += c.newString(('This an example of TextLines and TextRuns'
                   ' and more and more. '),
                  style=dict(font='Verdana', fontSize=14, lineHeight=22))
예제 #14
0
    c = [1, 0, 0]

    context.Variable([
        # create a variable called 'w'
        # and the related ui is a Slider.
        dict(name="w", ui="Slider"),
        # create a variable called 'h'
        # and the related ui is a Slider.
        dict(name="h", ui="Slider",
                args=dict(
                    # some vanilla specific
                    # setting for a slider
                    value=100,
                    minValue=50,
                    maxValue=300)),
        # position of the rectangle
        dict(name="x", ui="Slider",
            args=dict(value=0, minValue=0, maxValue=1000)),
        dict(name="y", ui="Slider",
            args=dict(value=0, minValue=0, maxValue=1000)),
        # create a variable called 'useColor'
        # and the related ui is a CheckBox.
        # TODO Fix color checkbox and well
        #dict(name="useColor", ui="CheckBox"),
        
        # create a variable called 'c'
        # and the related ui is a ColorWell.
        #dict(name="c", ui="ColorWell")
        ], globals())

    # check if the 'useColor' variable is checked
예제 #15
0
# Variable == vanilla power in DrawBot
from pagebot.contexts import defaultContext as context
#from AppKit import NSColor

if __name__ == '__main__':

    # create a color
    _color = None  #NSColor.colorWithCalibratedRed_green_blue_alpha_(0, .5, 1, .8)
    # setup variables useing different vanilla ui elements.
    context.Variable([
        dict(name="aList",
             ui="PopUpButton",
             args=dict(items=['a', 'b', 'c', 'd'])),
        dict(name="aText", ui="EditText", args=dict(text='hello world')),
        dict(name="aSlider",
             ui="Slider",
             args=dict(value=100, minValue=50, maxValue=300)),
        dict(name="aCheckBox", ui="CheckBox", args=dict(value=True)),
        dict(name="aColorWell", ui="ColorWell", args=dict(color=_color)),
        dict(name="aRadioGroup",
             ui="RadioGroup",
             args=dict(titles=['I', 'II', 'III'], isVertical=False)),
    ], globals())

    print aList
    print aText
    print aSlider
    print aCheckBox
    print aColorWell
    print aRadioGroup