>>> 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, description=None, foundryStyle=None,
fontNameStyle=None, bodyStyle=None, **kwargs)
| 25 | BODY_SIZE = 11 |
| 26 | |
| 27 | def __init__(self, f, foundryName=None, description=None, foundryStyle=None, |
| 28 | fontNameStyle=None, bodyStyle=None, **kwargs): |
| 29 | """ |
| 30 | >>> from pagebot.fonttoolbox.objects.font import findFont |
| 31 | >>> from pagebot.document import Document |
| 32 | >>> from pagebot.constants import Letter |
| 33 | >>> from pagebot import getContext |
| 34 | >>> from pagebot.contributions.filibuster.blurb import Blurb |
| 35 | >>> blurb = Blurb() |
| 36 | >>> c = getContext() |
| 37 | >>> w, h = Letter |
| 38 | >>> m = 80 |
| 39 | >>> doc = Document(w=w, h=h, padding=30, context=c) |
| 40 | >>> page = doc[1] |
| 41 | >>> font = findFont('AmstelvarAlpha-VF') |
| 42 | >>> foundryName = 'Google Fonts' |
| 43 | >>> description = blurb.getBlurb('article', newLines=True, cnt=120) |
| 44 | >>> bio = Bio(font, x=m, w=w-2*m, foundryName=foundryName, description=description, parent=page, context=c) |
| 45 | >>> tw, th = bio.getTextSize() |
| 46 | >>> bio.y = (h - th)*2/3 |
| 47 | >>> doc.export('_export/TypeNetworkBio.pdf') |
| 48 | """ |
| 49 | Text.__init__(self, '', **kwargs) |
| 50 | |
| 51 | c = self.context |
| 52 | if foundryStyle is None: |
| 53 | foundryStyle = dict(font=f.path, fontSize=self.BODY_SIZE, leading=em(0.6)) |
| 54 | if fontNameStyle is None: |
| 55 | fontNameStyle = dict(font=f.path, leading=em(1.9)) |
| 56 | if bodyStyle is None: |
| 57 | bodyStyle = dict(font=f.path, fontSize=self.BODY_SIZE, leading=em(1.4)) |
| 58 | |
| 59 | self.f = f # Font instance |
| 60 | foundryName = foundryName or f.info.designer or 'Unknown foundry' |
| 61 | familyName = f.info.familyName or 'Unknown family' |
| 62 | bio = c.newString(foundryName+'\n', style=foundryStyle) |
| 63 | bio += c.newString(familyName+'\n', style=fontNameStyle, w=self.w*2/3) |
| 64 | bio += c.newString(description or f.info.description or 'Unknown description ' * 40, |
| 65 | style=bodyStyle) |
| 66 | self.bs = bio |
| 67 | |
| 68 | if __name__ == '__main__': |
| 69 | import doctest |