diff options
| -rw-r--r-- | icons/inkstitch256x256.png | bin | 0 -> 19440 bytes | |||
| -rw-r--r-- | lib/extensions/lettering.py | 32 | ||||
| -rw-r--r-- | lib/extensions/params.py | 4 | ||||
| -rw-r--r-- | lib/lettering/font.py | 20 |
4 files changed, 39 insertions, 17 deletions
diff --git a/icons/inkstitch256x256.png b/icons/inkstitch256x256.png Binary files differnew file mode 100644 index 00000000..f3e5f0e7 --- /dev/null +++ b/icons/inkstitch256x256.png diff --git a/lib/extensions/lettering.py b/lib/extensions/lettering.py index 75a18b24..875dea03 100644 --- a/lib/extensions/lettering.py +++ b/lib/extensions/lettering.py @@ -13,8 +13,6 @@ import inkex import wx import wx.adv -from .commands import CommandsExtension -from .lettering_custom_font_dir import get_custom_font_dir from ..elements import nodes_to_elements from ..gui import PresetsPanel, SimulatorPreview, info_dialog from ..i18n import _ @@ -22,7 +20,9 @@ from ..lettering import Font, FontError from ..svg import get_correction_transform from ..svg.tags import (INKSCAPE_LABEL, INKSTITCH_LETTERING, SVG_GROUP_TAG, SVG_PATH_TAG) -from ..utils import DotDict, cache, get_bundled_dir +from ..utils import DotDict, cache, get_bundled_dir, get_resource_dir +from .commands import CommandsExtension +from .lettering_custom_font_dir import get_custom_font_dir class LetteringFrame(wx.Frame): @@ -41,6 +41,9 @@ class LetteringFrame(wx.Frame): _("Ink/Stitch Lettering") ) + icon = wx.Icon(os.path.join(get_resource_dir("icons"), "inkstitch256x256.png")) + self.SetIcon(icon) + self.preview = SimulatorPreview(self, target_duration=1) self.presets_panel = PresetsPanel(self) @@ -139,10 +142,10 @@ class LetteringFrame(wx.Frame): for font_dir in font_dirs: font = Font(os.path.join(font_path, font_dir)) - if font.name == "" or font.id == "": + if font.marked_custom_font_name == "" or font.marked_custom_font_id == "": continue - self.fonts[font.name] = font - self.fonts_by_id[font.id] = font + self.fonts[font.marked_custom_font_name] = font + self.fonts_by_id[font.marked_custom_font_id] = font if len(self.fonts) == 0: info_dialog(self, _("Unable to find any fonts! Please try reinstalling Ink/Stitch.")) @@ -151,6 +154,7 @@ class LetteringFrame(wx.Frame): def set_font_list(self): for font in self.fonts.values(): image = font.preview_image + if image is not None: image = wx.Image(font.preview_image) """ @@ -166,16 +170,10 @@ class LetteringFrame(wx.Frame): """ # Windows requires all images to have the exact same size image.Rescale(300, 20, quality=wx.IMAGE_QUALITY_HIGH) - self.font_chooser.Append(font.name, wx.Bitmap(image)) + self.font_chooser.Append(font.marked_custom_font_name, wx.Bitmap(image)) else: self.font_chooser.Append(font.name) - def get_font_names(self): - font_names = [font.name for font in self.fonts.values()] - font_names.sort() - - return font_names - def get_font_descriptions(self): return {font.name: font.description for font in self.fonts.values()} @@ -186,9 +184,11 @@ class LetteringFrame(wx.Frame): '''A default font will be substituted.''' info_dialog(self, _(message) % font_id) try: - self.font_chooser.SetValue(self.fonts_by_id[font_id].name) + font = self.fonts_by_id[font_id].marked_custom_font_name except KeyError: - self.font_chooser.SetValue(self.default_font.name) + font = self.default_font.name + self.font_chooser.SetValue(font) + self.on_font_changed() @property @@ -205,7 +205,7 @@ class LetteringFrame(wx.Frame): def on_font_changed(self, event=None): font = self.fonts.get(self.font_chooser.GetValue(), self.default_font) - self.settings.font = font.id + self.settings.font = font.marked_custom_font_id self.scale_spinner.SetRange(int(font.min_scale * 100), int(font.max_scale * 100)) font_variants = [] diff --git a/lib/extensions/params.py b/lib/extensions/params.py index 40494ec7..82cc9be9 100644 --- a/lib/extensions/params.py +++ b/lib/extensions/params.py @@ -341,6 +341,10 @@ class SettingsFrame(wx.Frame): wx.Frame.__init__(self, None, wx.ID_ANY, _("Embroidery Params") ) + + icon = wx.Icon(os.path.join(get_resource_dir("icons"), "inkstitch256x256.png")) + self.SetIcon(icon) + self.notebook = wx.Notebook(self, wx.ID_ANY) self.tabs = self.tabs_factory(self.notebook) diff --git a/lib/lettering/font.py b/lib/lettering/font.py index cbd8f257..81044853 100644 --- a/lib/lettering/font.py +++ b/lib/lettering/font.py @@ -9,13 +9,14 @@ from copy import deepcopy import inkex -from .font_variant import FontVariant from ..elements import nodes_to_elements from ..exceptions import InkstitchException +from ..extensions.lettering_custom_font_dir import get_custom_font_dir from ..i18n import _, get_languages from ..stitches.auto_satin import auto_satin from ..svg.tags import INKSCAPE_LABEL, SVG_PATH_TAG from ..utils import Point +from .font_variant import FontVariant class FontError(InkstitchException): @@ -157,6 +158,23 @@ class Font(object): raise FontError(_("The font '%s' has no variants.") % self.name) return font_variants + @property + def marked_custom_font_id(self): + if not self.is_custom_font(): + return self.id + else: + return self.id + '*' + + @property + def marked_custom_font_name(self): + if not self.is_custom_font(): + return self.name + else: + return self.name + '*' + + def is_custom_font(self): + return get_custom_font_dir() in self.path + def render_text(self, text, destination_group, variant=None, back_and_forth=True, trim=False): """Render text into an SVG group element.""" self._load_variants() |
