Add GlyphData.style.
This commit is contained in:
parent
f53eeed63b
commit
f256f550af
1 changed files with 9 additions and 1 deletions
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
|
||||
import pickle
|
||||
from collections import OrderedDict
|
||||
from collections import OrderedDict, namedtuple
|
||||
from datetime import datetime
|
||||
from os import path
|
||||
|
||||
|
|
@ -23,6 +23,9 @@ from .utils import cached_property
|
|||
from .image import Image
|
||||
|
||||
|
||||
Style = namedtuple('Style', ['color', 'bold', 'italic'])
|
||||
|
||||
|
||||
class GlyphData(object):
|
||||
def __init__(self, image_data, elevation, text, bold=False, italic=False, date_added=None):
|
||||
self.image_data = image_data
|
||||
|
|
@ -40,6 +43,10 @@ class GlyphData(object):
|
|||
def color(self):
|
||||
return self.image.color
|
||||
|
||||
@property
|
||||
def style(self):
|
||||
return Style(self.color, self.bold, self.italic)
|
||||
|
||||
@cached_property
|
||||
def image(self):
|
||||
return Image.deserialize(self.image_data)
|
||||
|
|
@ -80,6 +87,7 @@ class GlyphDB(object):
|
|||
data = GlyphData.from_glyph(glyph, text, bold=bold, italic=italic)
|
||||
key = self._key_from_glyph(glyph)
|
||||
self._dict[key] = data
|
||||
return data
|
||||
|
||||
def add(self, data):
|
||||
key = self._key_from_data(data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue