>>> from pagebot.fonttoolbox.objects.font import findFont >>> from pagebot.document import Document >>> from pagebot.constants import Letter >>> from pagebot import getContext >>> from pagebot.contributions.filibuster.blurb import Blurb >>> blurb = Bl
(self, f, foundryName=None, designer=None, foundryStyle=None,
fontNameStyle=None, designerStyle=None, **kwargs)
| 27 | NAME_SIZE = 24 |
| 28 | |
| 29 | def __init__(self, f, foundryName=None, designer=None, foundryStyle=None, |
| 30 | fontNameStyle=None, designerStyle=None, **kwargs): |
| 31 | """ |
| 32 | >>> from pagebot.fonttoolbox.objects.font import findFont |
| 33 | >>> from pagebot.document import Document |
| 34 | >>> from pagebot.constants import Letter |
| 35 | >>> from pagebot import getContext |
| 36 | >>> from pagebot.contributions.filibuster.blurb import Blurb |
| 37 | >>> blurb = Blurb() |
| 38 | >>> c = getContext() |
| 39 | >>> w, h = Letter |
| 40 | >>> m = 80 |
| 41 | >>> doc = Document(w=w, h=h, padding=30, context=c) |
| 42 | >>> page = doc[1] |
| 43 | >>> #font = findFont('RobotoDelta-VF') |
| 44 | >>> font = findFont('AmstelvarAlpha-VF') |
| 45 | >>> foundryName = 'Google Fonts' |
| 46 | >>> designer = 'David Berlow' |
| 47 | >>> title = Title(font, x=m, w=w-2*m, foundryName=foundryName, designer=designer, parent=page, context=c) |
| 48 | >>> tw, th = title.getTextSize() |
| 49 | >>> title.y = (h - th)*2/3 |
| 50 | >>> doc.export('_export/%sTitle.pdf' % font.info.familyName) |
| 51 | """ |
| 52 | Text.__init__(self, '', **kwargs) |
| 53 | |
| 54 | c = self.context |
| 55 | if foundryStyle is None: |
| 56 | foundryStyle = dict(font=f.path, fontSize=self.BODY_SIZE, leading=em(0.6)) |
| 57 | if fontNameStyle is None: |
| 58 | fontNameStyle = dict(font=f.path, leading=em(1.9)) |
| 59 | if designerStyle is None: |
| 60 | designerStyle = dict(font=f.path, fontSize=self.NAME_SIZE, leading=em(1.4), xTextAlign=RIGHT) |
| 61 | |
| 62 | self.f = f # Font instance |
| 63 | foundryName = foundryName or f.info.designer or 'Unknown foundry' |
| 64 | familyName = f.info.familyName or 'Unknown family' |
| 65 | designerName = 'by ' + designer or f.info.designer or 'Unknown designer' |
| 66 | |
| 67 | title = c.newString(foundryName+'\n', style=foundryStyle) |
| 68 | title += c.newString(familyName+'\n', style=fontNameStyle, w=self.w) |
| 69 | title += c.newString(designerName, style=designerStyle) |
| 70 | self.bs = title |
| 71 | |
| 72 | if __name__ == '__main__': |
| 73 | import doctest |