8 def __init__(self
, glyph
):
11 self
.font
= glyph
['font']
14 def add_glyph(self
, glyph
):
15 self
.glyphs
.append(glyph
)
20 elif left
.y
> right
.y
:
25 elif left
.x
> right
.x
:
32 # Load glyphs... share this with render_text.py
36 split
= line
.strip().split(',')
39 glyph
= { 'x' : int(split
[0]),
48 def generate_text_runs(glyphs
, WIDTH
):
55 skip_paragraph
= False
59 if glyph
['x'] == 0 and glyph
['y'] == 0 and glyph
['font'] == '0' and glyph
['glyph'] == '0':
61 print "Skipping paragraph due text being drawn over itself."
63 print "Skipping due too large x position"
65 current
.first_x
= current
.x
- last_x
66 if current
.first_x
< 0:
67 current
.first_x
= (WIDTH
- last_x
) + current
.x
68 assert current
.first_x
>= 0
69 current
.first_y
= current
.y
- last_y
70 text_runs
.append(current
)
72 if len(current
.glyphs
) != 0:
73 last_x
= current
.glyphs
[-1]['x']
74 assert last_x
<= WIDTH
78 skip_paragraph
= False
82 elif last_glyph
and last_glyph
['x'] == glyph
['x']:
88 current
= TextRun(glyph
)
90 if glyph
['x'] < WIDTH
:
91 current
.add_glyph(glyph
)
93 print "Omitting glyph due being out of space", glyph
98 text_runs
.append(current
)