Skip to content

Commit

Permalink
修复 GlyphFile 数据加载问题
Browse files Browse the repository at this point in the history
  • Loading branch information
TakWolf committed Dec 11, 2024
1 parent 24ae084 commit 0e07230
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/pixel_font_knife/glyph_file_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,26 @@ def load(file_path: Path) -> 'GlyphFile':
file_path: Path
code_point: int
flavors: list[str]
data: GlyphData | None
_data: GlyphData | None

def __init__(self, file_path: Path, code_point: int, flavors: list[str]):
self.file_path = file_path
self.code_point = code_point
self.flavors = flavors
self.data = None
self._data = None

@property
def data(self) -> GlyphData:
if self._data is None:
self._data = GlyphData.load_png(self.file_path)
return self._data

@property
def bitmap(self) -> MonoBitmap:
if self.data is None:
self.data = GlyphData.load_png(self.file_path)
return self.data.bitmap

@property
def mask(self) -> MonoBitmap:
if self.data is None:
self.data = GlyphData.load_png(self.file_path)
return self.data.mask

@property
Expand Down

0 comments on commit 0e07230

Please sign in to comment.