def _drawGlyphMarker(self,
                         axisName,
                         mx,
                         my,
                         glyphName,
                         fontSize,
                         location,
                         strokeW=2):
        # Middle circle
        context.fill(1)
        context.stroke(0.7)
        context.strokeWidth(strokeW)
        context.oval(mx - fontSize / 2 * self.R, my - fontSize / 2 * self.R,
                     fontSize * self.R, fontSize * self.R)

        variableFont = getVariableFont(self.font, location)
        # Show axis name below circle marker?
        if self.showAxisNames and axisName is not None:
            fs = context.newString(axisName,
                                   style=dict(font=variableFont.installedName,
                                              fontSize=fontSize / 4,
                                              textFill=0))
            tw, th = context.textSize(fs)
            context.text(
                fs, (mx - tw / 2, my - fontSize / 2 * self.R - th * 2 / 3))
        glyphPathScale = fontSize / self.font.info.unitsPerEm
        context.drawGlyphPath(variableFont,
                              glyphName,
                              mx,
                              my - fontSize / 3,
                              s=glyphPathScale,
                              fillColor=0)
Esempio n. 2
0
def drawLayers(bss):
    # Draw this layer in a couple of frame
    context.newPage(W, H)
    context.frameDuration(fd)
    #fill(backgroundColor[0],backgroundColor[1],backgroundColor[2])
    #rect(0, 0, W, H)
    y = 3*padding
    for bs in bss:
        context.text(bs, (2*padding, y+100))
def drawLayers(fss):
    # Draw this layer in a couple of frame
    _, h = fss[0].size()
    h += padding
    for n in range(frameLength):
        context.newPage(W, h)
        context.fill(
            (backgroundColor[0], backgroundColor[1], backgroundColor[2]))
        context.rect(0, 0, W, h)
        for fs in fss:
            context.text(fs, (2 * padding, -padding))
Esempio n. 4
0
def drawLayers(fss1, fss2):
    # Draw this layer in a couple of frame
    context.newPage(W, H)
    context.frameDuration(fd)
    context.fill((backgroundColor[0], backgroundColor[1], backgroundColor[2]))
    context.rect(0, 0, W, H)
    y = 3 * padding
    offsetY = -100
    for fs in fss1:
        context.text(fs, (2 * padding, y + offsetY + 310))
    for fs in fss2:
        context.text(fs, (2.35 * padding, y + offsetY + 5))
Esempio n. 5
0
def drawString(s, px, py, fontName, color=None, gridColor=None):
    if fontName in FONTS:
        fontName = FONTS[fontName]
    context.font(fontName)
    context.fontSize(FS)
    context.stroke(None)
    if color is not None:
        r, g, b, t = color
        context.fill((r, g, b, t))
    else:
        context.fill(color or 0)
    context.text(s, (px, py))
def drawLayers(fss, frame):
    # Draw this layer in a couple of frame
    context.newPage(W, H)
    context.frameDuration(fd)
    #fill(backgroundColor[0],backgroundColor[1],backgroundColor[2])
    #rect(0, 0, W, H)
    y = 3 * padding
    for fsSingle, fsDouble in fss:
        if frame < frames / 2:
            fs = fsSingle
        else:
            fs = fsDouble
        context.text(fs, (2 * padding, y + 100))
Esempio n. 7
0
def drawLayers(fss, fontSize):
    # Draw this layer in a couple of frame
    offsetX = 0
    offsetY = -20
    _, h = fss[0].size()
    h += M
    context.newPage(W, h)
    context.fill(Background_Color)
    context.rect(0, 0, W, h)
    for fs in fss:
        context.text(fs, (M + offsetX, M + offsetY))
        offsetX += Layer_Offset_X
        offsetY += Layer_Offset_Y
def drawLayers(fss, frame, dx, dy, doNewPage):
    # Draw this layer in a couple of frame
    if doNewPage:
        context.newPage(W, H)
        context.frameDuration(fd)
    #context.fill(backgroundColor[0],backgroundColor[1],backgroundColor[2])
    #context.rect(0, 0, W, H)
    for fsSingle, fsDouble in fss:
        if frame < frames/2:
            fs = fsSingle
        else:
            fs = fsDouble
        context.text(fs, (dx*2*padding, dy))
Esempio n. 9
0
def draw(w, y, drawVariable):
    u"""
      Draw 3 lines of text: the boundaries of with the width axis and
      the interpolated width from the slider value.
      If the slider goes of the extremes, then the middle line
      stops at the boundary width.
    """
    d = fitVariableWidth(f, HEADLINE, w, HEADLINE_SIZE, condensedLocation,
                         wideLocation)
    # move the canvas
    c.save()
    if not drawVariable:
        c.translate(0, -H / 2 + PADDING / 2)
    drawPageFrame(d['width'] + 2 * M)
    c.restore()

    minWidth = d['condensedWidth']
    maxWidth = d['wideWidth']
    fixedWidth = minWidth + (maxWidth - minWidth) / 2
    dFixed = c.fitVariableWidth(f, HEADLINE, fixedWidth, HEADLINE_SIZE,
                                condensedLocation, wideLocation)

    if drawVariable:
        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))
def drawLayers(layers):
    # Draw this layer in a couple of frame
    # Calculate the pixel size. 100 units on 1000 Em.
    #pixelSize =
    x = M
    y = 0
    _, h = layers[0]['text'].size()
    h += M / 2
    context.newPage(W, h)
    context.fill(Background_Color)
    context.rect(0, 0, W, h)
    for layerIndex, layer in sorted(layers.items()):
        context.text(layer['text'], (x, y))
        x += layer['offsetX']
        y += layer['offsetY']
def run():
    W, H = 1000, 400
    c.newPage(W, H)
    txt = "Hello World"
    x, y = 10, 100

    fs = c.newString(txt, style=dict(fontSize=300, font="Verdana"))
    # draw the text
    c.text(fs, (x, y))

    # calculate the size of the text
    textWidth, textHeight = c.textSize(txt)

    # set a red stroke color
    c.stroke(1, 0, 0)
    # loop over all font metrics
    for metric in (0, fs.fontDescender(), fs.fontAscender(), fs.fontXHeight(),
                   fs.fontCapHeight()):
        # draw a red line with the size of the drawn text
        c.line((x, y + metric), (W - 2 * x, y + metric))
Esempio n. 12
0
def buildBusinessCard1(w, h):

    M = 4  # Margin

    # Page 66
    context.newPage(w, h)

    y = h

    context.image('docs/images/IMG_2381-50.jpg', (0, 0), w=w)

    # Title of cover, make it fit in with and add shadow
    style = dict(font='Upgrade-Regular',
                 fontSize=14,
                 textFill=1,
                 xTextAlign=CENTER)
    styleTitle = dict(font='Upgrade-Italic',
                      fontSize=10,
                      textFill=1,
                      xTextAlign=CENTER)
    styleEmail = dict(font='Upgrade-Light',
                      fontSize=8,
                      textFill=1,
                      xTextAlign=CENTER,
                      leading=10,
                      rTracking=0.02)
    bs = context.newString('Petr van Blokland\n', style=style)
    bs += context.newString('Designer | Educator | Founder\n',
                            style=styleTitle)
    bs += context.newString('[email protected] | @petrvanblokland',
                            style=styleEmail)
    tw, th = bs.size()
    context.text(bs, (w / 2 - tw / 2, h * 0.55))

    logoStyle = dict(font='Upgrade-Black',
                     fontSize=22,
                     textFill=1,
                     rTracking=1.4)
    bs = context.newString(u'.TYPETR', style=logoStyle)
    tw, th = bs.size()
    context.text(bs, (w / 2 - tw / 2 - 3, 2 * M))
Esempio n. 13
0
def buildBusinessCard(w, h):
	
    
    for imageIndex in range(1, 5):

        context.newPage(w, h) 
        
        y = h # Start vertical position on top of the page.
    
        # Draw one of the 4 Bitcount background images, filename indexed by imageIndex
        # The TYPETR Bitcount license can be purchased at:
        # https://store.typenetwork.com/foundry/typetr/fonts/bitcount
        imagePath = ROOT_PATH + '/Examples/Portfolios/images/BitcountRender%d.png' % imageIndex
        context.image(imagePath, (0, 0), w=w) # Set to full page width at origin
    
        # Define some style. Note thate TYPETR Upgrade is the identity typeface, which may not be installed.
        # Another font is selected in case TYPETR Upgrade is not available.
        # View more here: https://upgrade.typenetwork.com
        # A license can be purchased at:
        # https://store.typenetwork.com/foundry/typetr/fonts/upgrade
        style = dict(font='Upgrade-Regular', fontSize=14, textFill=1, xTextAlign=CENTER)
        styleTitle = dict(font='Upgrade-Italic', fontSize=10, textFill=1, xTextAlign=CENTER)
        styleEmail = dict(font='Upgrade-Light', fontSize=8, textFill=1, xTextAlign=CENTER, leading=10, rTracking=0.02)
        # Create styled BabelString for the name lines
        bs = context.newString('Petr van Blokland\n', style=style)  
        bs += context.newString('Designer | Educator | Founder\n', style=styleTitle)  
        bs += context.newString('[email protected] | @petrvanblokland', style=styleEmail)
        # Get the size of the text block, to position it centered
        tw, th = context.textSize(bs)  
        # Draw a textbox in the contextf canvas.
        context.text(bs, (w/2-tw/2, h*0.55))

        # Create a style for the logo. The size and tracking is hardcoded to fit the business card width.
        logoStyle = dict(font='Upgrade-Black', fontSize=22, textFill=1, rTracking=1.4)
        # Create the BabelString, containing the fitting logo with tracking.
        bs = context.newString(u'.TYPETR', style=logoStyle)
        # Get the size of the text block, to position it centered
        tw, th = bs.size()
        # Draw a textbox in the contextf canvas.
        context.text(bs, (w/2-tw/2-3, 2*M)) 
def buildDesignPages(w, h):

    cw = w - ML - MR

    # Page 66
    context.newPage(w, h)

    bs = context.newText(t)

    R = (ML, MB, w - ML - MR, h - MB - MT)
    overFill = context.textOverflow(bs, R)
    context.textBox(bs, R)

    pn = context.newString(66, style=pageNumberStyle)
    context.text(pn, (w / 2 - pn.w / 2, M / 2))

    pt = context.newString(bookTitle, style=pageTitleStyle)
    context.textBox(pt, (ML, h - MT * 0.75, cw, pt.h))

    # Page 67
    context.newPage(w, h)

    # Assume that we have a footnote on this page, calc it's space.
    fnMark = context.newString(footNoteRef, style=footNoteRefStyle)
    fn = fnMark + ' ' + context.newString(footNoteText, style=footNoteStyle)
    fnw, fnh = fn.textSize(cw)
    cfnh = fnh + bodyStyle['fontSize'] * bodyStyle['rLeading']
    ch = h - MB - MT - cfnh
    R = (ML, MB + cfnh, cw, ch)
    context.textBox(overFill, R)

    context.textBox(fn, (ML, MB, cw, fnh))

    pt = context.newString(chapterTitle, style=pageChapterStyle)
    context.textBox(pt, (ML, h - MT * 0.75, cw, pt.h))

    pn = context.newString(67, style=pageNumberStyle)
    context.text(pn, (w / 2 - pn.w / 2, M / 2))
Esempio n. 15
0
    def _drawBaselines(self, showIndex=False, showY=False, showLeading=False):
        # Let's see if we can draw over them in exactly the same position.
        fontSize = 8
        if showY:
            c.text(c.newString('0', style=dict(align='left',
                                               font='Verdana',
                                               fontSize=8,
                                               fill=(0, 0, 1))),
                   (self.x + self.w + 3, self.y + self.h - fontSize/4))

        prevY = 0
        for index in range(len(self)):
            _, y, _ = self.baseLines[index]
            c.line((self.x, self.y + self.h - y),
                   (self.x + self.w, self.y + self.h - y))
            if showIndex:
                c.text(c.newString('index', style=dict(align='right',
                                                       font='Verdana',
                                                       fontSize=fontSize,
                                                       fill=(0, 0, 1))),
                       (self.x-8, self.y + self.h - y - fontSize/3))
            if showY:
                c.text(c.newString('%d' % round(y),
                                   style=dict(align='left',
                                              font='Verdana',
                                              fontSize=fontSize,
                                              fill=(0, 0, 1))),
                       (self.x + self.w + 3, self.y + self.h - y - fontSize/4))
            if showLeading:
                leading = round(abs(y - prevY))
                c.text(c.newString('%d' % leading,
                                   style=dict(align='left',
                                              font='Verdana',
                                              fontSize=fontSize,
                                              fill=(1, 0, 0))),
                       (self.x + self.w + 3, self.y + self.h - prevY - leading/2 - fontSize/4))
            prevY = y
Esempio n. 16
0
    def draw(self):

        # Try to use TYPETR-Bitcount. Only is instsalled in the system.
        # See samples at https://bitcount.typenetwork.com
        # Order a license at: https://store.typenetwork.com/foundry/typetr/fonts/bitcount
        USE_BITCOUNT = True

        LETTERS = 'ABCEFGHIJKLMNOPQRSTUVWXYZ'

        Frames = 80
        W = H = 500

        IMAGE_PATH = '_export/HorizonWorld.gif'
        if not USE_BITCOUNT or not 'BitcountMonoDouble-RegularCircle' in context.installedFonts(
        ):
            fontNames = ['Georgia-Bold', 'Georgia']
        else:
            fontNames = []
            for fontName in installedFonts():
                if 'BitcountMono' in fontName and not 'Italic' in fontName:
                    fontNames.append(fontName)

        letters = []
        for n in range(10):
            c = choice(LETTERS)
            x = 0
            y = 15
            z = 20 + int(random() * 500)

            x = 1 / z + random() * 100 - 100
            cc = random() * 0.8 + 0.1, random() * 0.1, random() * 0.8 * 0.1
            f = choice(fontNames)
            letters.append((c, f, x, y, z, cc))

        for n in range(Frames):
            context.newPage(W, H)
            context.fill(0.8)
            context.rect(0, 0, W, H)
            for c, f, x, y, z, (r, g, b) in letters:
                #y = y/z
                context.fill(
                    (r, g, b)
                )  # Needs tuple, instead of separate r, g, b as in DrawBot
                context.font(f)
                context.stroke(None)
                fSize = min(200, 40000 / z)
                context.fontSize(fSize)
                context.text(c, (x + 250, y + 250 - fSize / 2))

                context.fill(None)
                context.strokeWidth(0.5)
                context.stroke(0.5)
                context.line((0, 250), (500, 250))

                context.fill(
                    (1, 1, 1, 0.4)
                )  # Needs tuple, instead of separate r, g, b as in DrawBot
                context.rect(0, 0, W, H / 2 - 1)

                for n in range(0, 500, 10):
                    context.fill(None)
                    context.stroke(1)
                    y = W / 2 - 2 - n * 0.4
                    lineThickness = (random() * 3 + 0.5) * (H / 2 - y) / 10
                    context.strokeWidth(lineThickness)
                    context.line((0, y - lineThickness / 2),
                                 (W, y - lineThickness / 2))

        context.saveImage(IMAGE_PATH)
Esempio n. 17
0
def buildCoverPages1(w, h, v):

    M = 10

    # Page 66
    context.newPage(w, h)

    context.fill(0.1)
    context.rect(0, 0, w, h)

    c1 = (0.2, 0.7, 1)
    c2 = 0.8

    y = h - M

    # Title of cover, make it fit in with and add shadow
    coverTitleStyle = dict(font='Upgrade-Hairline', fontSize=100, textFill=c1)
    bs = context.newString('THE', style=coverTitleStyle, w=w - M)
    bx, by, bw, bh = bs.bounds()
    context.text(bs, (w / 2 - (bw + bx) / 2, y - bh + by))

    y -= bh - by + M / 2

    coverTitleStyle = dict(font='Upgrade-Thin', fontSize=100, textFill=c1)
    bs = context.newString('LONGEST', style=coverTitleStyle, w=w - 1.5 * M)
    bx, by, bw, bh = bs.bounds()
    context.text(bs, (w / 2 - (bw + bx) / 2, y - bh + by))

    y -= bh - by + M / 2

    # Title of cover, make it fit in with and add shadow
    coverTitleStyle = dict(font='Upgrade-ExtraLight',
                           fontSize=100,
                           textFill=c1,
                           rTracking=0.05)
    bs = context.newString('MELLIFLUOUSLY',
                           style=coverTitleStyle,
                           w=w - 1.5 * M)
    bx, by, bw, bh = bs.bounds()
    context.text(bs, (w / 2 - (bw + bx) / 2, y - bh + by))

    y -= bh - by + M / 2

    coverTitleStyle = dict(font='Upgrade-Light',
                           fontSize=100,
                           textFill=c1,
                           rTracking=0.07)
    bs = context.newString('supercalifragilisticexpialidociously'.upper(),
                           style=coverTitleStyle,
                           w=w - 2 * M)
    bx, by, bw, bh = bs.bounds()
    context.text(bs, (w / 2 - (bw + bx) / 2, y - bh + by))

    y -= bh - by + M / 2

    coverTitleStyle = dict(font='Upgrade-Book',
                           fontSize=100,
                           textFill=c1,
                           rTracking=0.07)
    bs = context.newString(
        'pneumonoultramicroscopicsilicovolcanoconiosis'.upper(),
        style=coverTitleStyle,
        w=w - 2 * M)
    bx, by, bw, bh = bs.bounds()
    context.text(bs, (w / 2 - (bw + bx) / 2, y - bh + by))

    y -= bh - by + M / 2

    coverTitleStyle = dict(font='Upgrade-Light', fontSize=100, textFill=c1)
    bs = context.newString('INTERMIXED', style=coverTitleStyle, w=w - 1.5 * M)
    bx, by, bw, bh = bs.bounds()
    context.text(bs, (w / 2 - (bw + bx) / 2, y - bh + by))

    y -= bh - by + 2 * M

    # Title of cover, make it fit in with and add shadow
    coverTitleStyle = dict(font='Upgrade-Light', fontSize=100, textFill=c2)
    bs = context.newString('MATTHEW', style=coverTitleStyle, w=w - 1.5 * M)
    bx, by, bw, bh = bs.bounds()
    context.text(bs, (w / 2 - (bw + bx) / 2, y - bh + by))

    y -= bh - by + M / 2

    # Title of cover, make it fit in with and add shadow
    coverTitleStyle = dict(font='Upgrade-Light', fontSize=100, textFill=c2)
    bs = context.newString('DOW', style=coverTitleStyle, w=w - M)
    bx, by, bw, bh = bs.bounds()
    context.text(bs, (w / 2 - (bw + bx) / 2, y - bh + by))
Esempio n. 18
0
def buildCoverPages2(w, h, v):

    M = 30
    for pn in range(v):
        # Page 66
        context.newPage(w, h)

        context.fill(0.1)
        context.rect(0, 0, w, h)

        c1 = (0.2, 0.7, 1)
        c2 = 0.8

        y = h - M

        # Title of cover, make it fit in with and add shadow
        coverTitleStyle = dict(font='Upgrade-Book',
                               fontSize=100,
                               textFill=1,
                               rTracking=0.2,
                               openTypeFeatures=dict(smcp=True))
        bs = context.newString('One Lightyear Equals',
                               style=coverTitleStyle,
                               w=w - 2 * M)
        bx, by, bw, bh = bs.bounds()
        context.text(bs, (w / 2 - (bw + bx) / 2, y - bh + by))

        y -= 100

        styleColors = ('Upgrade-UltraBlack', 'Upgrade-ExtraBlack',
                       'Upgrade-Black', 'Upgrade-Semibold', 'Upgrade-Medium',
                       'Upgrade-Regular', 'Upgrade-Book', 'Upgrade-Light',
                       'Upgrade-ExtraLight', 'Upgrade-Thin',
                       'Upgrade-Hairline')
        if v == 1:
            R = 22
        else:
            R = math.sin(math.radians(pn * 360 / v)) * 16
        for index, name in enumerate(styleColors):
            coverTitleStyle = dict(font=name,
                                   fontSize=100,
                                   textFill=list(c1) +
                                   [index / len(styleColors)],
                                   rTracking=0.2,
                                   rLeading=0.9,
                                   openTypeFeatures=dict(tnum=True))
            bs = context.newString('9460\n7304\n7258\n0800\n512',
                                   style=coverTitleStyle,
                                   w=w - M / 2)
            bx, by, bw, bh = bs.bounds()
            context.text(bs, (w / 2 - (bw + bx) / 2 + (random() * R - R / 2),
                              -by + 1.5 * M + (random() * R - R / 2)))

        coverTitleStyle = dict(font='Upgrade-ExtraLight',
                               fontSize=100,
                               textFill=c1,
                               rTracking=0.05,
                               rLeading=0.9)
        bs = context.newString('mm', style=coverTitleStyle, w=w / 5)
        bx, by, bw, bh = bs.bounds()
        context.text(bs, (w * 4 / 6 + M, -by + 3.2 * M))

        coverTitleStyle = dict(font='Upgrade-Regular',
                               fontSize=100,
                               textFill=c2,
                               rTracking=0.2,
                               rLeading=1.2,
                               openTypeFeatures=dict(smcp=True))
        bs = context.newString('Design\nDesign\nSpace',
                               style=coverTitleStyle,
                               w=w / 5)
        bx, by, bw, bh = bs.bounds()
        context.text(bs, (w * 4 / 6 + M, -by + 0.75 * M))
Esempio n. 19
0
        >>> uninstallFontFile(path)
        >>> f = AppKit.NSFont.fontWithName_size_(u'-', 12)
        >>> f is not None
        False
    """


def _runDocTests():
    import doctest
    return doctest.testmod()


from pagebot.contexts import defaultContext as c
if __name__ == "__main__":
    if True:
        import sys
        sys.exit(_runDocTests()[0])
    else:
        # Test to be run in DrawBot
        from tnTestFonts import getFontPath
        path = getFontPath("Condor-Bold.otf")
        try:
            installFontFile(path)
        except FontInstallError, error:
            print "font probably already installed"
            #print error
        c.font("Condor-Bold")
        c.fontSize(200)
        c.text("Hallo", (100, 100))
        # uninstallFontFile(path)
Esempio n. 20
0
def drawFontLabel(p, varFamily, f, fIndex=None, fAxis=None):
    x, y = p
    print f.info.styleName, f.info.weightClass, f.info.widthClass

    glyphH = f[GLYPH]
    if not glyphH.width:
        print glyphH, 'No width'
        return

    s = 0.05 * 1000 / f.info.unitsPerEm
    leading = 2048 / f.info.unitsPerEm
    stroke(None)
    fill(0)
    save()
    translate(x - glyphH.width / 2 * s, y - leading - 50)
    scale(s)
    drawPath(glyphH.path)
    restore()
    y -= leading + 50

    save()
    pathLabel = '-'.join(path2Name(f.path).split('-')[1:])
    #label = path2Name(f.path)
    if fAxis is not None:
        label = '@' + fAxis
    elif fIndex is None:
        label = ''
    else:
        label = '#%d ' % fIndex
    label += '%s\n(%s)\n%d' % (pathLabel.replace('.ttf', '').replace(
        '_', '\n').replace('-', '\n'), f.info.styleName, f.info.weightClass)
    fs = FormattedString(label, fontSize=10, align='center')
    tw, th = textSize(fs)
    text(fs, (x - tw / 2, y - 14))
    restore()
    y -= leading + th - 22

    # Draw marker on actual position of H.stem and H.weight as green dot
    stemValues = f.analyzer.stems.keys()
    if stemValues:  # Cannot find H-stem, skip this marker
        stem = min(stemValues)
        # XOPQ (counter) + H.stem == H.width - H.stem - H.lsb - H.rsb
        width = glyphH.width - stem - glyphH.leftMargin - glyphH.rightMargin

        c.fill((0, 0.5, 0))
        c.stroke(None)
        R = 16
        weightLoc, widthLoc = stem, width / 2
        c.oval(weightLoc - R / 2, widthLoc - R / 2, R, R)
        if fAxis is not None:
            label = '@' + fAxis
        elif fIndex is None:
            label = ''
        else:
            label = '#%d\n' % fIndex
        bs = c.newString(label + ('S:%d\nW:%d\n%d' %
                                  (weightLoc, widthLoc, f.info.weightClass)),
                         style=dict(fontSize=10,
                                    xTextAlign='center',
                                    textFill=0))
        tw, th = c.textSize(bs)
        c.text(bs, (weightLoc - tw / 2, widthLoc - 24))

        if varFamily.originFont is f:
            # If one of these is the guessed origin font, then draw marker
            c.fill(None)
            c.stroke((0, 0.5, 0), 2)  # Stroke color and width
            R = 23
            c.oval(weightLoc - R / 2, widthLoc - R / 2, R, R)

    else:
        pass
Esempio n. 21
0
#     P A G E B O T
#
#     Copyright (c) 2016+ Buro Petr van Blokland + Claudia Mens & Font Bureau
#     www.pagebot.io
#     Licensed under MIT conditions
#
#     Supporting usage of DrawBot, www.drawbot.com
#     Supporting usage of Flat, https://github.com/xxyxyz/flat
# -----------------------------------------------------------------------------
#
from random import random
from pagebot.contexts import defaultContext as context

for p in range(20):
    context.newPage(1000, 1000)
    for n in range(50):
        context.fill((random(), 0, random(), 0.5 + random() * 0.2))
        ch = random()
        x = 20 + random() * 800
        y = 20 + random() * 800
        if ch < 0.2:
            context.oval(x, y, 80, 80)
        elif ch < 0.4:
            context.rect(x, y, 80, 80)
        else:
            bs = context.newString('Hello world on %d,%d' % (x, y),
                                   style=dict(fontSize=24))
            context.text(bs, (x, y))

context.saveImage('_export/OurNiceDrawing.pdf')
Esempio n. 22
0
def draw(w):
    u"""
      Draw 3 lines of text: the boundaries of with the width axis
       and the interpolated width from the slider value.
      If the slider goes of the extremes, then the middle line stops
       at the boundary width.
    """
    d = fitVariableWidth(f, HEADLINE, w, HEADLINE_SIZE,
                         condensedLocation, wideLocation)

    c.newPage(W, H)
    c.fill(1)
    c.rect(0, 0, W, H)
    c.text(d['condensedFs'], (PADDING, 50))
    c.text(d['fs'], (PADDING, 100))
    c.text(d['wideFs'], (PADDING, 150))
    c.fill(None)
    c.stroke(0)
    c.line((PADDING, PADDING), (PADDING, H-PADDING))
    c.line((PADDING+d['condensedWidth'], PADDING),
         (PADDING+d['condensedWidth'], H-PADDING))
    c.line((PADDING+d['width'], PADDING),
         (PADDING+d['width'], H-PADDING))
    c.line((PADDING+d['wideWidth'], PADDING),
         (PADDING+d['wideWidth'], H-PADDING))
    c.stroke(None)
    c.fill(0)
    c.text('%d %0.2f' % (round(d['condensedWidth']),
                         d['condensedLocation']['wdth']),
           (PADDING + d['condensedWidth'] + 5, PADDING))
    c.text('%d %0.2f' % (round(d['width']), d['location']['wdth']),
           (PADDING + d['width'] + 5, PADDING))
    c.text('%d %0.2f' % (round(d['wideWidth']), d['wideLocation']['wdth']),
           (PADDING + d['wideWidth'] + 5, PADDING))
    c.stroke(1, 0, 0)
    c.line((PADDING+w, PADDING), (PADDING+w, H-PADDING))
    c.stroke(None)
    c.fill(1, 0, 0)
    c.text('Column %d' % w, (PADDING+w+5, H-PADDING-5))
def buildCoverPages1(w, h, imagePath, page):

    magazineTitle = 'Bier!'

    M = 10  # Margin
    ML, MR, MT, MB = M, M, M, 1.5 * M
    cw = w - ML - MR
    LM = 2 * M

    # Page 66
    context.newPage(w, h)

    biw, bih = ((None, h), (w, None), (None, h), (None, h))[page]
    # Draw image, covering all page, scaled.
    context.image('docs/images/' + imagePath, (0, 0), w=biw, h=bih)

    t = (
        u'Voorjaar 2018 | No. 36 | €5',
        u'Zomer 2018 | No. 37 | €5',
        u'Najaar 2018 | No. 38 | €5',
        u'Winter 2018 | No. 39 | €5',
    )

    priceStyle1 = dict(font='Upgrade-Book',
                       fontSize=15,
                       textFill=1,
                       rTracking=0.02)
    priceStyle2 = dict(font='Upgrade-Book',
                       textFill=1,
                       fontSize=15,
                       openTypeFeatures=dict(sups=True))
    bs = context.newString(t[page], style=priceStyle1)
    bs += context.newString('95', style=priceStyle2)
    bx, by, bw, bh = bs.bounds()
    context.text(bs, (w - M - (bx + bw), MB))

    y = h - M
    print listOpenTypeFeatures('Upgrade-Light')
    c = (  # Title colors per page
        0, 1, 0, 1)
    # Title of cover, make it fit in with and add shadow
    style = dict(font='Upgrade-Light',
                 fontSize=15.5,
                 textFill=c[page],
                 openTypeFeatures=dict(smcp=True, c2sc=True, ss08=True),
                 rLeading=0.9,
                 rTracking=0.02)
    #bs = context.newString('onafhankelijk smaakmakend\rmagazine over speciaal bier', style=style)
    bs = context.newString('onafhankelijk smaakmakend\r'.upper(), style=style)
    style['rTracking'] = 0.042
    bs += context.newString('magazine over speciaal bier'.upper(), style=style)
    bx, by, bw, bh = bs.bounds()
    context.text(bs, (w / 2.3, y - bh - M / 2))

    # Title of cover, make it fit in with and add shadow
    coverTitleStyle = dict(font='Upgrade-Black',
                           fontSize=100,
                           textFill=1,
                           rTracking=-0.025)
    bs = context.newString(magazineTitle, style=coverTitleStyle, w=w)
    bx, by, bw, bh = bs.bounds()
    context.setShadow(shadow)
    context.text(bs, (w / 2 - (bw + bx) / 2, y - bh))
    context.resetShadow()

    y -= (bh - by) + 2 * LM

    t = ((u'Leven in de brouwerij', w * 2 / 3.2), (u'De Koninck Late Night',
                                                   w * 2 / 3.2),
         (u'Brouwerijtour', w / 2), (u'Bierreis grensstreek', w * 2 / 3.2))
    style = dict(font='Upgrade-Italic',
                 fontSize=64,
                 textFill=(1, 1, 1, 0.8),
                 rLeading=1)
    bs = context.newString(t[page][0], style=style, w=t[page][1])
    bx, by, bw, bh = bs.bounds()
    context.text(bs, (M, y - bh))

    y -= (bh - by) + LM - 8

    t = (
        (u'Hommels', w / 2),
        (u'Geproefde bieren', w / 2 - 2 * M),
        (u'Beer Battle', w / 2 - 2 * M),
        (u'Droomweekend bier', w / 2),
    )
    style = dict(font='Upgrade-Semibold',
                 fontSize=50,
                 textFill=(0xd4 / 255, 0x89 / 255, 0x5a / 255, 0.8),
                 rTracking=0.02,
                 rLeading=0.7)
    bs = context.newString(t[page][0], style=style, w=t[page][1])
    bx, by, bw, bh = bs.bounds()
    context.setShadow(shadow)
    context.text(bs, (M, y - bh))
    context.resetShadow()

    y -= (bh - by) + 3.5 * LM

    t = (
        (u'De Baronie\nWestmalle\nCafé Trappisten', w - 2 * M,
         (0x3e / 255, 0x1a / 255, 0x09 / 255, 0.2)),
        (u'Vlaamse\nBiergaai', w / 2 - 3 * M, (0xd4 / 255, 0x89 / 255,
                                               0x5a / 255, 0.1)),
        (u'.\n\n\nHollandse\nHopvogel', w / 2 - 2 * M, (0xd4 / 255, 0x89 / 255,
                                                        0x5a / 255, 0.1)),
        (u'Italiaans abdijbier', w - 2 * M, (0xd4 / 255, 0x89 / 255,
                                             0x5a / 255, 0.1)),
    )
    style = dict(font='Upgrade-Black',
                 fontSize=60,
                 textFill=t[page][2],
                 textStroke=(1, 1, 1, 0.5),
                 textStrokeWidth=3,
                 rTracking=0.03,
                 rLeading=0.9)
    bs = context.newString(t[page][0], style=style, w=t[page][1])
    bx, by, bw, bh = bs.bounds()
    context.text(bs, (M, y - bh))

    y -= (bh - by) - LM

    t = (
        u'Kompaan brouwt het beste bier van Nederland',
        u'Wederopbouw: Help de monniken met “Deep Roots”',
        u'Two Chefs Brewing opent microbrouwerij Amsterdam',
        u'Brouwerij in distilleerderij in Weesper kerk',
    )
    style = dict(font='Upgrade-Regular',
                 fontSize=100,
                 textFill=(1, 1, 1, 0.95),
                 rTracking=0.02)
    bs = context.newString(t[page], style=style, w=w - 3 * M)
    bx, by, bw, bh = bs.bounds()
    context.setShadow(shadow)
    context.text(bs, (1.5 * M, 6 * M))
    context.resetShadow()
Esempio n. 24
0
from pagebot.contexts import defaultContext as c

for p in range(10):
    c.newPage(1000, 1000)
    for n in range(50):
        c.fill((random(), 0, random(), 0.5 + random() * 0.2))
        ch = random()
        x = 20 + random() * 800
        y = 20 + random() * 800
        if ch < 0.2:
            c.oval(x, y, 80, 80)
        elif ch < 0.4:
            c.rect(x, y, 80, 80)
        else:
            c.fontSize(24)
            c.text('Hello world on %d,%d' % (x, y), (x, y))

c.saveImage('_export/HelloCircleSquare.gif')
Esempio n. 25
0
#     Supporting usage of Flat, https://github.com/xxyxyz/flat
# -----------------------------------------------------------------------------
#
#     UseBabelStrings.py
#
#     BabelString instances are wrappers around formatted strings,
#     hiding their context. For DrawBot BabelStrings (bs.s) contain
#     OSX/IOS FormattedStrings.
#     For FlexContext, equivalent text-formatted structures are implemented.
#
from pagebot.contexts import defaultContext as context

W = H = 1000
M = 100

EXPORT_PATH = '_export/UseBabelStrings.pdf'
# Create a page and set y on top margin.
context.newPage(W, H)
y = H - M
# Create formatted string, with default settings of font, fontSize and textFill color
bs = context.newString('This is a formatted BabelString')
context.text(bs, (100, y))
# Add string with formatting style dict
bs += context.newString('\nAdd an other string with format',
                        style=dict(textFill=(1, 0, 0),
                                   fontSize=20,
                                   rLeading=1.4))
y -= 50
context.text(bs, (100, y))

context.saveImage(EXPORT_PATH)
    def draw(self, orgX, orgY):
        if not self.show:
            return
        w = self.w  # Width of the icon
        h = self.ih  # Height of the icon
        e = self.E * self.scale  # Ear size
        l = self.L * self.scale  # Line
        x = self.x + orgX
        y = self.y + orgY

        path = c.newPath()
        c.moveTo((0, 0))
        c.lineTo((0, h))
        c.lineTo((w - e, h))
        c.lineTo((w, h - e))
        c.lineTo((w, 0))
        c.lineTo((0, 0))
        c.closePath()
        c.moveTo((w - e, h))
        c.lineTo((w - e, h - e))
        c.lineTo((w, h - e))

        c.saveGraphicState()
        c.fill(1)
        c.stroke(0)
        c.strokeWidth = self.line
        c.moveTo((x, y))
        c.drawPath(path)
        labelSize = e
        fs = c.newString(self.char,
                         style=dict(font=self.f.installedName,
                                    textFill=0,
                                    fontSize=h * 2 / 3))
        tw, th = c.textSize(fs)
        c.text(fs, (w / 2 - tw / 2, h / 2 - th / 3.2))

        if self.title:
            fs = c.newString(self.title,
                             style=dict(font=self.labelFont.installedName,
                                        textFill=0,
                                        rTracking=self.LABEL_RTRACKING,
                                        fontSize=labelSize))
            tw, th = c.textSize(fs)
            c.text(fs, (w / 2 - tw / 2, self.ih + th / 2))

        y = -self.LABEL_RLEADING * labelSize
        if self.name:
            fs = c.newString(self.name,
                             style=dict(font=self.labelFont.installedName,
                                        textFill=0,
                                        rTracking=self.LABEL_RTRACKING,
                                        fontSize=labelSize))
            tw, th = c.textSize(fs)
            c.text(fs, (w / 2 - tw / 2, y))
            y -= self.LABEL_RLEADING * labelSize
        if self.label:
            fs = c.newString(self.label,
                             style=dict(font=self.labelFont.installedName,
                                        textFill=0,
                                        rTracking=self.LABEL_RTRACKING,
                                        fontSize=labelSize))
            tw, th = c.textSize(fs)
            c.text(fs, (w / 2 - tw / 2, y))
        c.restoreGraphicState()
Esempio n. 27
0
# Draw vertical line in the middle of the page as reference.
context.fill(None)
context.strokeWeight = 0.5
context.stroke((0, 0, 0.4))
context.line((w / 2, 0), (w / 2, h))

TRACKING = 1
FONT_SIZE = 14
TRACKED_SPACE = FONT_SIZE * TRACKING

# New Babel string, probably DrawBot FormattedString flavor.
bs = context.newString('TRACKEDSTRING',
                       style=dict(font='Verdana',
                                  fontSize=FONT_SIZE,
                                  rTracking=TRACKING))
# Call DrawBot textSize to determine the size of the string
# including the tracking
tw, th = bs.size()

context.text(bs, (w / 2 - tw / 2, 70))
context.stroke((1, 0, 0))
context.rect(w / 2 - tw / 2, 60, tw, th)

print TRACKED_SPACE

tw -= TRACKED_SPACE

context.text(bs, (w / 2 - tw / 2, 20))
context.stroke((1, 0, 0))
context.rect(w / 2 - tw / 2, 10, tw, th)
Esempio n. 28
0
print len(bitpaths)
print len(bitcounts)

for c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz':
    context.newPage(2200, 300)
    fonts = bitpaths + bitcounts
    print len(fonts)
    shuffle(fonts)
    for name in fonts:
        #if not 'Double' in name:
        #   continue
        if not 'Single' in name:
            continue
        if not 'Mono' in name:
            continue
        fs = context.newString('Jill Pichotta',
                               style=dict(font=name,
                                          fontSize=200,
                                          #openTypeFeatures=dict(ss01=True,
                                          #                      ss02=True,
                                          #                      ss03=True),
                                          tracking=40,
                                          #textFill=None,
                                          textFill=(random(), random(), random(), 0.1),
                                          textStroke=(random(), random(), random()),
                                          textStrokeWidth=0.5))
        context.text(fs, (50, 100))
        
context.saveImage('_export/CompareBitpath2BitcountJP.pdf')
    def draw(self, page, x, y):
        u"""Draw the circle info-graphic, showing most info about the variation font as can be interpreted from the file."""
        c.fill(0.9)
        c.stroke(None)
        mx = x + self.w / 2
        my = y + self.h / 2

        # Gray circle that defines the area of
        c.oval(x, y, self.w, self.h)

        # Draw axis spikes first, so we can cover them by the circle markers.
        axes = self.font.axes
        fontSize = self.style.get('fontSize', self.DEFAULT_FONT_SIZE)

        # Draw name of the font
        c.fill(0)
        c.text(
            c.newString(self.font.info.familyName,
                        style=dict(font=self.style['labelFont'],
                                   fontSize=self.style['axisNameFontSize'])),
            (x - fontSize / 2, y + self.h + fontSize / 2))

        # Draw spokes
        c.fill(None)
        c.stroke(0)
        c.strokeWidth(1)
        c.newPath()
        for axisName, angle in self.angles.items():
            markerX, markerY = self._angle2XY(angle, self.w / 2)
            c.moveTo((mx, my))
            c.lineTo((mx + markerX, my + markerY))
        c.drawPath()

        # Draw default glyph marker in middle.
        glyphName = self.glyphNames[0]
        defaultLocation = {}
        self._drawGlyphMarker(mx,
                              my,
                              glyphName,
                              fontSize,
                              defaultLocation,
                              strokeW=3)

        # Draw DeltaLocation circles.
        for axisName, (minValue, defaultValue, maxValue) in axes.items():
            angle = self.angles[axisName]
            # Outside maxValue
            location = {axisName: maxValue}
            markerX, markerY = self._angle2XY(angle, self.w / 2)
            self._drawGlyphMarker(mx + markerX, my + markerY, glyphName,
                                  fontSize / 2, location)

            # Interpolated DeltaLocation circles.
            location = {
                axisName: minValue + (maxValue - minValue) * INTERPOLATION
            }
            markerX, markerY = self._angle2XY(angle, self.w / 4)
            self._drawGlyphMarker(mx + markerX * INTERPOLATION * 2,
                                  my + markerY * INTERPOLATION * 2, glyphName,
                                  fontSize / 2, location)

        # Draw axis names and DeltaLocation values
        if self.showAxisNames:
            for axisName, (minValue, defaultValue, maxValue) in axes.items():
                angle = self.angles[axisName]
                location = {axisName: maxValue}
                valueFontSize = self.style.get('valueFontSize', 12)
                axisNameFontSize = self.style.get('axisNameFontSize', 12)
                markerX, markerY = self._angle2XY(angle, self.w / 2)
                fs = c.newString(
                    makeAxisName(axisName),
                    style=dict(font=self.style.get('labelFont', 'Verdana'),
                               fontSize=axisNameFontSize,
                               fill=self.style.get('axisNameColor', 0)))
                tw, th = c.textSize(fs)
                c.fill(0.7, 0.7, 0.7, 0.6)
                c.stroke(None)
                c.rect(mx + markerX - tw / 2 - 4,
                       my + markerY - axisNameFontSize / 2 - th * 1.5 - 4,
                       tw + 8, th)
                c.text(fs, (mx + markerX - tw / 2,
                            my + markerY - axisNameFontSize / 2 - th * 1.5))

                # DeltaLocation master value
                if maxValue < 10:
                    sMaxValue = '%0.2f' % maxValue
                else:
                    sMaxValue = ` int(round(maxValue)) `
                fs = c.newString(
                    sMaxValue,
                    style=dict(font=self.style.get('labelFont', 'Verdana'),
                               fontSize=valueFontSize,
                               fill=self.style.get('axisValueColor', 0)))
                tw, th = c.textSize(fs)
                c.fill(0.7, 0.7, 0.7, 0.6)
                c.stroke(None)
                c.rect(mx + markerX - tw / 2 - 4,
                       my + markerY + valueFontSize / 2 + th * 1.5 - 4, tw + 8,
                       th)
                c.text(fs, (mx + markerX - tw / 2,
                            my + markerY + valueFontSize / 2 + th * 1.5))

                # DeltaLocation value
                interpolationValue = minValue + (maxValue -
                                                 minValue) * INTERPOLATION
                if interpolationValue < 10:
                    sValue = '%0.2f' % interpolationValue
                else:
                    sValue = ` int(round(interpolationValue)) `
                fs = c.newString(
                    sValue,
                    style=dict(font=self.style.get('labelFont', 'Verdana'),
                               fontSize=valueFontSize,
                               fill=self.style.get('axisValueColor', 0)))
                tw, th = c.textSize(fs)
                c.fill(0.7, 0.7, 0.7, 0.6)
                c.stroke(None)
                c.rect(
                    mx + markerX * INTERPOLATION - tw / 2 - 4, my +
                    markerY * INTERPOLATION + valueFontSize / 2 + th * 1.5 - 4,
                    tw + 8, th)
                c.text(
                    fs,
                    (mx + markerX * INTERPOLATION - tw / 2, my +
                     markerY * INTERPOLATION + valueFontSize / 2 + th * 1.5))

                # DeltaLocation value
                if minValue < 10:
                    sValue = '%0.2f' % minValue
                else:
                    sValue = ` int(round(minValue)) `
                fs = c.newString(
                    sValue,
                    style=dict(font=self.style.get('labelFont', 'Verdana'),
                               fontSize=valueFontSize,
                               fill=self.style.get('axisValueColor', 0)))
                tw, th = c.textSize(fs)
                c.fill(0.7, 0.7, 0.7, 0.6)
                c.stroke(None)
                minM = 0.2
                c.rect(mx + markerX * minM - tw / 2 - 4,
                       my + markerY * minM + th * 0.5 - 4, tw + 8, th)
                c.text(fs, (mx + markerX * minM - tw / 2,
                            my + markerY * minM + th * 0.5))
Esempio n. 30
0
    def draw(self, page, x, y):
        u"""Draw the circle info-graphic, showing most info about the variation font as can be interpreted from the file."""
        c.fill(0.9)
        c.stroke(None)
        mx = x + self.w / 2
        my = y + self.h / 2

        # Gray circle that defines the area of
        c.oval(x, y, self.w, self.h)

        # Draw axis spikes first, so we can cover them by the circle markers.
        axes = self.font.axes
        fontSize = self.style.get('fontSize', self.DEFAULT_FONT_SIZE)

        # Calculate sorted relative angle pairs.
        xAngles = {}  # X-ref, key is angle, value is list of axisName
        for axisName in axes:
            angle = globals()[axisName]
            if not angle in xAngles:  # Ignore overlapping
                xAngles[angle] = axisName
        #print xAngles
        sortedAngles = sorted(xAngles)
        anglePairs = []
        a1 = None
        for a2 in sortedAngles:
            if a1 is not None:
                if abs(a2 - a1) < 35:
                    anglePairs.append((a1, a2))
            a1 = a2

        # Draw name of the font
        c.fill(0)
        c.text(
            c.newString(self.font.info.familyName,
                        style=dict(font=self.style['labelFont'],
                                   fontSize=self.style['titleFontSize'])),
            (x - fontSize / 2, y + self.h + fontSize / 4))

        # Draw spokes
        c.fill(None)
        c.stroke(0.7)
        c.strokeWidth(1)
        # Gray on full circle
        c.newPath()
        for axisName, angle in self.angles.items():
            markerX, markerY = self._angle2XY(angle, self.w / 2)
            c.moveTo((mx - markerX, my - markerY))
            c.lineTo((mx + markerX, my + markerY))
        c.drawPath()

        # Black on range of axis.
        c.stroke(0)
        c.newPath()
        for axisName, angle in self.angles.items():
            markerX, markerY = self._angle2XY(angle, self.w / 2)
            c.moveTo((mx, my))
            c.lineTo((mx + markerX, my + markerY))
        c.drawPath()

        # Pair combinations
        if anglePairs:
            c.newPath()
            for a1, a2 in anglePairs:
                markerX1, markerY1 = self._angle2XY(a1, self.w / 2)
                markerX2, markerY2 = self._angle2XY(a2, self.w / 2)
                c.moveTo((mx + markerX1, my + markerY1))
                c.lineTo((mx + markerX2, my + markerY2))
                c.moveTo((mx + markerX1 * INTERPOLATION,
                          my + markerY1 * INTERPOLATION))
                c.lineTo((mx + markerX2 * INTERPOLATION,
                          my + markerY2 * INTERPOLATION))
            c.stroke(0, 0, 1)
            c.fill(None)
            c.drawPath()

        # Draw default glyph marker in middle.
        glyphName = self.glyphNames[0]
        defaultLocation = {}
        self._drawGlyphMarker(mx,
                              my,
                              glyphName,
                              fontSize,
                              defaultLocation,
                              strokeW=3)

        # Draw DeltaLocation circles.
        for axisName, (minValue, defaultValue, maxValue) in axes.items():
            angle = self.angles[axisName]
            # Outside maxValue
            location = {axisName: maxValue}
            markerX, markerY = self._angle2XY(angle, self.w / 2)
            self._drawGlyphMarker(mx + markerX, my + markerY, glyphName,
                                  fontSize / 2, location)

            # Interpolated DeltaLocation circles.
            location = {
                axisName: minValue + (maxValue - minValue) * INTERPOLATION
            }
            markerX, markerY = self._angle2XY(angle, self.w / 4)
            self._drawGlyphMarker(mx + markerX * INTERPOLATION * 2,
                                  my + markerY * INTERPOLATION * 2, glyphName,
                                  fontSize / 2, location)

            # If there are any pairs, draw the interpolation between them
            #if anglePairs:
            #    for a1, a2 in anglePairs:
            #        axis1 =

        # helper function:
        def makeAxisName(axisName):
            if not axisName in ('wght', 'wdth', 'opsz'):
                return axisName.upper()
            return axisName

        # Draw axis names and DeltaLocation values
        if self.showAxisNames:
            for axisName, (minValue, defaultValue, maxValue) in axes.items():
                angle = self.angles[axisName]
                location = {axisName: maxValue}
                valueFontSize = self.style.get('valueFontSize', 12)
                axisNameFontSize = self.style.get('axisNameFontSize', 12)
                markerX, markerY = self._angle2XY(angle, self.w / 2)
                fs = c.newString(
                    makeAxisName(axisName),
                    style=dict(font=self.style.get('labelFont', 'Verdana'),
                               fontSize=axisNameFontSize,
                               fill=self.style.get('axisNameColor', 0)))
                tw, th = c.textSize(fs)
                c.fill(0.7, 0.7, 0.7, 0.6)
                c.stroke(None)
                c.rect(mx + markerX - tw / 2 - 4,
                       my + markerY - axisNameFontSize / 2 - th * 1.5 - 4,
                       tw + 8, th)
                c.text(fs, (mx + markerX - tw / 2,
                            my + markerY - axisNameFontSize / 2 - th * 1.5))

                # DeltaLocation master value
                if maxValue < 10:
                    sMaxValue = '%0.2f' % maxValue
                else:
                    sMaxValue = ` int(round(maxValue)) `
                fs = c.newString(
                    sMaxValue,
                    style=dict(font=self.style.get('labelFont', 'Verdana'),
                               fontSize=valueFontSize,
                               fill=self.style.get('axisValueColor', 0)))
                tw, th = c.textSize(fs)
                c.fill(0.7, 0.7, 0.7, 0.6)
                c.stroke(None)
                c.rect(mx + markerX - tw / 2 - 4,
                       my + markerY + valueFontSize / 2 + th * 1.5 - 4, tw + 8,
                       th)
                c.text(fs, (mx + markerX - tw / 2,
                            my + markerY + valueFontSize / 2 + th * 1.5))

                # DeltaLocation value
                interpolationValue = minValue + (maxValue -
                                                 minValue) * INTERPOLATION
                if interpolationValue < 10:
                    sValue = '%0.2f' % interpolationValue
                else:
                    sValue = ` int(round(interpolationValue)) `
                fs = c.newString(
                    sValue,
                    style=dict(font=self.style.get('labelFont', 'Verdana'),
                               fontSize=valueFontSize,
                               fill=self.style.get('axisValueColor', 0)))
                tw, th = c.textSize(fs)
                c.fill(0.7, 0.7, 0.7, 0.6)
                c.stroke(None)
                c.rect(
                    mx + markerX * INTERPOLATION - tw / 2 - 4, my +
                    markerY * INTERPOLATION + valueFontSize / 2 + th * 1.5 - 4,
                    tw + 8, th)
                c.text(
                    fs,
                    (mx + markerX * INTERPOLATION - tw / 2, my +
                     markerY * INTERPOLATION + valueFontSize / 2 + th * 1.5))

                # DeltaLocation value
                if minValue < 10:
                    sValue = '%0.2f' % minValue
                else:
                    sValue = ` int(round(minValue)) `
                fs = c.newString(
                    sValue,
                    style=dict(font=self.style.get('labelFont', 'Verdana'),
                               fontSize=valueFontSize,
                               fill=self.style.get('axisValueColor', 0)))
                tw, th = c.textSize(fs)
                c.fill(0.7, 0.7, 0.7, 0.6)
                c.stroke(None)
                minM = 0.2
                c.rect(mx + markerX * minM - tw / 2 - 4,
                       my + markerY * minM - 8, tw + 8, th)
                c.text(fs,
                       (mx + markerX * minM - tw / 2, my + markerY * minM - 4))