Ejemplo n.º 1
0
def getSystemFontPaths():
    u"""Answer the cleaned list of installed font names."""
    fontPaths = []
    for fontName in context.installedFonts():
        if not fontName.startswith('.'):
            fontPaths.append(context.getFontPathOfFont(fontName))
    return fontPaths
Ejemplo n.º 2
0
def getFamilyFontPaths(familyName):
    # Collect the DrawBot names of all available fonts for the named family, that are installed in the system.
    fontPaths = {} # Dictionary, where key is the DrawBot font name, value is the OS path of the font file.
    for fontName in context.installedFonts(): # Answers complete list of all installed fonts.
        if familyName in fontName: # If this is a with with the familyName that we are looking for...
            fontPaths[fontName] = context.getFontPathOfFont(fontName) # Store the name and find the font path name.
    return fontPaths #  Answer the dictionary. This is empty, if no Bitcount fonts are installed now.
Ejemplo n.º 3
0
#     Supporting usage of DrawBot, www.drawbot.com
#     Supporting usage of Flat, https://github.com/xxyxyz/flat
# -----------------------------------------------------------------------------
#
#     BookPages66-67.py
#
from pagebot.contexts import defaultContext as context

from pagebot.publications.publication import Publication
from pagebot.elements import *
from pagebot.document import Document
from pagebot.conditions import *
from pagebot.style import A5, CENTER, DISPLAY_BLOCK
from pagebot.fonttoolbox.objects.font import Font

installedFonts = context.installedFonts()
# Try if the Upgrade family is installed. Otherwise try an alternative font that is installed.
print installedFonts

h1Style = dict(font='Upgrade-Medium',
               fontSize=18,
               rLeading=1.4,
               tracking=0.2,
               paragraphBottomSpacing=12 * 0.5,
               display=DISPLAY_BLOCK)
h2Style = dict(font='Upgrade-Medium',
               fontSize=12,
               rLeading=1.3,
               tracking=0.2,
               paragraphTopSpacing=12 * 1.3 * 0.5,
               display=DISPLAY_BLOCK)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
#
#     Supporting usage of DrawBot, www.drawbot.com
#     Supporting usage of Flat, https://github.com/xxyxyz/flat
# -----------------------------------------------------------------------------
#
#     CompareBitpath2Bitcount.py

from random import random, shuffle
from pagebot.contexts import defaultContext as context

ITALIC = False

bitpaths = []
bitcounts = []

for fontName in context.installedFonts():
    if 'Bitcount' in fontName:
        if not 'Italic' in fontName:
            continue
        bitcounts.append(fontName)
    if 'Bitpath' in fontName:
        if not 'Italic' in fontName:
            continue
        bitpaths.append(fontName)
        

print len(bitpaths)
print len(bitcounts)

for c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz':
    context.newPage(2200, 300)
Ejemplo n.º 6
0
         "wght": 700,
         "wdth": 1000
     },
     'PromisePageBot-Black': {
         "wght": 800,
         "wdth": 800
     },
     'PromisePageBot-UltraBlack': {
         "wght": 1000,
         "wdth": 1000
     },
 }
 FONTS = {}
 VFONT_PATH = 'PromisePageBot-GX.ttf'
 # Install the test V-font
 if not 'PromisePageBot-Bold' in c.installedFonts():
     c.installFont(FONT_PATH + VFONT_PATH)
 for name, location in FONT_LOCATIONS.items():
     fontName, fontPath = generateInstance(FONT_PATH + VFONT_PATH,
                                           location,
                                           targetDirectory=FONT_PATH +
                                           'instances')
     FONTS[
         name] = fontName  #fontPath # Instead of fontName, no need to uninstall.
 LIGHT_CONDENSED = FONTS['PromisePageBot-LightCondensed']
 LIGHT = FONTS['PromisePageBot-Light']
 BOOK = FONTS['PromisePageBot-Book']
 BOOK_ITALIC = FONTS['PromisePageBot-Book']
 MEDIUM = FONTS['PromisePageBot-Medium']
 SEMIBOLD = FONTS['PromisePageBot-Semibold']
 SEMIBOLD_CONDENSED = FONTS['PromisePageBot-SemiboldCondensed']