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
|
import pickle
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict, namedtuple
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
|
|
@ -23,6 +23,9 @@ from .utils import cached_property
|
||||||
from .image import Image
|
from .image import Image
|
||||||
|
|
||||||
|
|
||||||
|
Style = namedtuple('Style', ['color', 'bold', 'italic'])
|
||||||
|
|
||||||
|
|
||||||
class GlyphData(object):
|
class GlyphData(object):
|
||||||
def __init__(self, image_data, elevation, text, bold=False, italic=False, date_added=None):
|
def __init__(self, image_data, elevation, text, bold=False, italic=False, date_added=None):
|
||||||
self.image_data = image_data
|
self.image_data = image_data
|
||||||
|
|
@ -40,6 +43,10 @@ class GlyphData(object):
|
||||||
def color(self):
|
def color(self):
|
||||||
return self.image.color
|
return self.image.color
|
||||||
|
|
||||||
|
@property
|
||||||
|
def style(self):
|
||||||
|
return Style(self.color, self.bold, self.italic)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def image(self):
|
def image(self):
|
||||||
return Image.deserialize(self.image_data)
|
return Image.deserialize(self.image_data)
|
||||||
|
|
@ -80,6 +87,7 @@ class GlyphDB(object):
|
||||||
data = GlyphData.from_glyph(glyph, text, bold=bold, italic=italic)
|
data = GlyphData.from_glyph(glyph, text, bold=bold, italic=italic)
|
||||||
key = self._key_from_glyph(glyph)
|
key = self._key_from_glyph(glyph)
|
||||||
self._dict[key] = data
|
self._dict[key] = data
|
||||||
|
return data
|
||||||
|
|
||||||
def add(self, data):
|
def add(self, data):
|
||||||
key = self._key_from_data(data)
|
key = self._key_from_data(data)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue