blob: 3d5dc5e0e1a98b96ac3af5653ad71ca88fdafc66 (
plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# Purpose: handle text styles
# Created: 06.01.2014
# Copyright (C) 2014, Manfred Moitzi
# License: MIT License
from __future__ import unicode_literals
__author__ = "mozman <mozman@gmx.at>"
from .layers import Table
from .tags import Tags
class Style(object):
def __init__(self, tags):
self.name = ""
self.height = 1.0
self.width = 1.0
self.oblique = 0.
self.is_backwards = False
self.is_upside_down = False
self.font = ""
self.big_font = ""
for code, value in tags.plain_tags():
if code == 2:
self.name = value
elif code == 70:
self.flags = value
elif code == 40:
self.height = value
elif code == 41:
self.width = value
elif code == 50:
self.oblique = value
elif code == 71:
self.is_backwards = bool(value & 2)
self.is_upside_down = bool(value & 4)
self.oblique = value
elif code == 3:
self.font = value
elif code == 4:
self.big_font = value
class StyleTable(Table):
name = 'styles'
@staticmethod
def from_tags(tags):
styles = StyleTable()
for entry_tags in styles.entry_tags(tags):
style = Style(entry_tags)
styles._table_entries[style.name] = style
return styles
DEFAULT_STYLE = """ 0
STYLE
2
STANDARD
70
0
40
0.0
41
1.0
50
0.0
71
0
42
1.0
3
Arial
4
"""
default_text_style = Style(Tags.from_text(DEFAULT_STYLE))
|