Commit 971f4d68 authored by Etienne Nadji's avatar Etienne Nadji
Browse files

Styles: character style: @HyphenWordMin

	modifié :         ../articles/en/spec.rst
	modifié :         styles.py
parent b392f459
......@@ -48,19 +48,23 @@ DOCUMENT/CHARSTYLE
Omitted XPath : ``/SCRIBUSUTF8NEW/DOCUMENT``.
+------------------------------+--------------------+------------+---------+----------+
| XML | Explanation | Value | Default | Optional |
| element/attribute | | | | |
+==============================+====================+============+=========+==========+
| ``/CHARSTYLE/@DefaultStyle`` | Same as STYLE, but | string | | |
| | not documented | | | |
+------------------------------+--------------------+------------+---------+----------+
| ``/CHARSTYLE/@wordTrack`` | Space width | Percentage | | |
| | | 0 -> 1 | | |
+------------------------------+--------------------+------------+---------+----------+
| ``/CHARSTYLE/@KERN`` | Kerning | Percentage | | |
| | | 0 -> 100 | | |
+------------------------------+--------------------+------------+---------+----------+
+-------------------------------+--------------------+------------+---------+----------+
| XML | Explanation | Value | Default | Optional |
| element/attribute | | | | |
+===============================+====================+============+=========+==========+
| ``/CHARSTYLE/@DefaultStyle`` | Same as STYLE, but | String | | |
| | not documented | | | |
+-------------------------------+--------------------+------------+---------+----------+
| ``/CHARSTYLE/@wordTrack`` | Space width | Percentage | | |
| | | 0 -> 1 | | |
+-------------------------------+--------------------+------------+---------+----------+
| ``/CHARSTYLE/@KERN`` | Kerning | Percentage | | |
| | | 0 -> 100 | | |
+-------------------------------+--------------------+------------+---------+----------+
| ``/CHARSTYLE/@HyphenWordMin`` | Minimal number of | Integer | | |
| | caracters for word | >= 3 | | |
| | hyphenation | | | |
+-------------------------------+--------------------+------------+---------+----------+
DOCUMENT/Sections
-----------------
......
......@@ -1005,10 +1005,30 @@ class CharacterStyle(StyleAbstract):
self.font["space_width"] = dimensions.Dim(1, "pcdecim")
self.font["kerning"] = None
self.hyphen_word_min = None
def fromxml(self, xml):
is_character = StyleAbstract.fromxml(self, xml, True)
if is_character:
#--- Hyphenation ------------------------------------------------
if (hyphen_word := xml.get("HyphenWordMin")) is not None:
try:
word_length = int(hyphen_word)
if word_length < 3:
raise InsaneSLAValue(
"HyphenWordMin in '{}' character style must be an integer >= 3.".format(self.name)
)
self.hyphen_word_min = word_length
except ValueError:
raise InsaneSLAValue(
"HyphenWordMin in '{}' character style must be an integer >= 3.".format(self.name)
)
#--- Font settings ----------------------------------------------
if (wordtrack := xml.get("wordTrack")) is not None:
......@@ -1039,6 +1059,11 @@ class CharacterStyle(StyleAbstract):
def toxml(self):
xml = StyleAbstract.toxml(self)
#--- Hyphenation ------------------------------------------------
if self.hyphen_word_min is not None:
xml.attrib["HyphenWordMin"] = str(self.hyphen_word_min)
#--- Font settings ----------------------------------------------
if self.font["space_width"] is not None:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment