diff options
| author | Claudine Peyrat <88194877+claudinepeyrat06@users.noreply.github.com> | 2025-06-25 10:30:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-25 10:30:24 +0200 |
| commit | a0a3fab4c9578027ae9af4aa2eec0b3a363df20c (patch) | |
| tree | 4985e5ddd1a2bec476df65b97e613f435f4b998b /lib/lettering | |
| parent | 2134897db8f0893c8e9a64286eeb76c770790639 (diff) | |
switch from NFKC to NFC normalization form in the lettering tool (#3828)
* switch from NFKC to NFC
* Additional normalization.
---------
Co-authored-by: CapellanCitizen <>
Diffstat (limited to 'lib/lettering')
| -rw-r--r-- | lib/lettering/font.py | 4 | ||||
| -rw-r--r-- | lib/lettering/font_variant.py | 4 | ||||
| -rw-r--r-- | lib/lettering/glyph.py | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/lib/lettering/font.py b/lib/lettering/font.py index d1ed6154..5ae6743a 100644 --- a/lib/lettering/font.py +++ b/lib/lettering/font.py @@ -8,6 +8,7 @@ import os from collections import defaultdict from copy import deepcopy from random import randint +import unicodedata import inkex @@ -217,6 +218,9 @@ class Font(object): """Render text into an SVG group element.""" self._load_variants() + # Normalize the text in the same way that glyph names are normalized (NFC) + text = unicodedata.normalize('NFC', text) + if variant is None: variant = self.default_variant diff --git a/lib/lettering/font_variant.py b/lib/lettering/font_variant.py index 4862b00b..80d9d3e6 100644 --- a/lib/lettering/font_variant.py +++ b/lib/lettering/font_variant.py @@ -74,7 +74,7 @@ class FontVariant(object): for layer in glyph_layers: self._clean_group(layer) layer.attrib[INKSCAPE_LABEL] = layer.attrib[INKSCAPE_LABEL].replace("GlyphLayer-", "", 1) - glyph_name = normalize('NFKC', layer.attrib[INKSCAPE_LABEL]) + glyph_name = normalize('NFC', layer.attrib[INKSCAPE_LABEL]) try: self.glyphs[glyph_name] = Glyph(layer) except (AttributeError, ValueError): @@ -144,7 +144,7 @@ class FontVariant(object): # binding glyph only have two shapes, isol and fina non_binding_char = ['ا', 'أ', 'ﺇ', 'آ', 'ٱ', 'د', 'ذ', 'ر', 'ز', 'و', 'ؤ'] - normalized_non_binding_char = [normalize('NFKC', letter) for letter in non_binding_char] + normalized_non_binding_char = [normalize('NFC', letter) for letter in non_binding_char] return not (character in normalized_non_binding_char) def is_mark(self, character): diff --git a/lib/lettering/glyph.py b/lib/lettering/glyph.py index fd1e1985..98f69ecb 100644 --- a/lib/lettering/glyph.py +++ b/lib/lettering/glyph.py @@ -39,7 +39,7 @@ class Glyph(object): self.name = group.label if len(self.name) > 11: - self.name = normalize('NFKC', self.name[11:]) + self.name = normalize('NFC', self.name[11:]) self._process_baseline(group.getroottree().getroot()) self.clips = self._process_clips(group) self.node = self._process_group(group) |
