-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTextPath.py
More file actions
executable file
·56 lines (44 loc) · 1.49 KB
/
TextPath.py
File metadata and controls
executable file
·56 lines (44 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
# -----------------------------------------------------------------------------
#
# P A G E B O T E X A M P L E S
#
# Copyright (c) 2017 Thom Janssen <https://github.com/thomgb>
# www.pagebot.io
# Licensed under MIT conditions
#
# Supporting DrawBot, www.drawbot.com
# Supporting Flat, xxyxyz.org/flat
# -----------------------------------------------------------------------------
#
# TextPath.py
#
#from pagebot.fonttoolbox.objects.font import findFont
from pagebot.fonttoolbox.objects.font import findFonts
from pagebot.contexts.basecontext.basepath import BasePath
from pagebot.document import Document
# TODO: find out how to remove overlap on text.
# Maybe avoid using text but load font in path?
def test(context):
doc = Document(w=800, h=600, autoPages=1, context=context)
font = findFonts(('Robo', 'Con', 'Bol', 'Ita'))[0]
page = doc[1] # Get the single page from te document.
'''
path = BezierPath()
path.rect(x=50, y=100, w=900, h=500)
path.text('Difference', font=fontName, fontSize=200, offset=(105, 200))
path.removeOverlap()
text('Hello world', (100, 650))
drawPath(path)
'''
style = dict(font=font, fontSize=100)
p = BasePath(context, style=style)
print(p)
p.text('H')
context.drawPath(p)
if __name__ == '__main__':
from pagebot import getContext
for contextName in ('DrawBot', 'Flat'):
context = getContext(contextName)
test(context)