From e514b1be4ffc630984329afe0235b7fb46b5d084 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 13 Nov 2024 19:51:36 +0100 Subject: [PATCH 1/7] Fix DocX line height setting --- novelwriter/constants.py | 3 +++ novelwriter/formats/todocx.py | 35 +++++++++++++++-------------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/novelwriter/constants.py b/novelwriter/constants.py index 2d67b5a7f..bd5efac5f 100644 --- a/novelwriter/constants.py +++ b/novelwriter/constants.py @@ -105,6 +105,9 @@ class nwStyles: H_LEVEL = {"H0": 0, "H1": 1, "H2": 2, "H3": 3, "H4": 4} H_SIZES = {0: 2.50, 1: 2.00, 2: 1.75, 3: 1.50, 4: 1.25} + T_NORMAL = 1.0 + T_SMALL = 0.8 + T_LABEL = { "H0": QT_TRANSLATE_NOOP("Constant", "Title"), "H1": QT_TRANSLATE_NOOP("Constant", "Heading 1 (Partition)"), diff --git a/novelwriter/formats/todocx.py b/novelwriter/formats/todocx.py index 5b499b45a..6410a5e99 100644 --- a/novelwriter/formats/todocx.py +++ b/novelwriter/formats/todocx.py @@ -521,12 +521,6 @@ def _generateStyles(self) -> None: hScale = self._scaleHeads hColor = _docXCol(self._theme.head) if self._colorHeads else None fSz = self._fontSize - fnSz = 0.8 * self._fontSize - fSz0 = (nwStyles.H_SIZES[0] * fSz) if hScale else fSz - fSz1 = (nwStyles.H_SIZES[1] * fSz) if hScale else fSz - fSz2 = (nwStyles.H_SIZES[2] * fSz) if hScale else fSz - fSz3 = (nwStyles.H_SIZES[3] * fSz) if hScale else fSz - fSz4 = (nwStyles.H_SIZES[4] * fSz) if hScale else fSz # Add Normal Style styles.append(DocXParStyle( @@ -545,12 +539,12 @@ def _generateStyles(self) -> None: styles.append(DocXParStyle( name="Title", styleId=S_TITLE, - size=fSz0, + size=(nwStyles.H_SIZES[0] * fSz) if hScale else fSz, basedOn=S_NORM, nextStyle=S_NORM, before=fSz * self._marginTitle[0], after=fSz * self._marginTitle[1], - line=fSz0 * self._lineHeight, + line=fSz * self._lineHeight, level=0, bold=self._boldHeads, )) @@ -559,12 +553,12 @@ def _generateStyles(self) -> None: styles.append(DocXParStyle( name="Heading 1", styleId=S_HEAD1, - size=fSz1, + size=(nwStyles.H_SIZES[1] * fSz) if hScale else fSz, basedOn=S_NORM, nextStyle=S_NORM, before=fSz * self._marginHead1[0], after=fSz * self._marginHead1[1], - line=fSz1 * self._lineHeight, + line=fSz * self._lineHeight, level=0, color=hColor, bold=self._boldHeads, @@ -574,12 +568,12 @@ def _generateStyles(self) -> None: styles.append(DocXParStyle( name="Heading 2", styleId=S_HEAD2, - size=fSz2, + size=(nwStyles.H_SIZES[2] * fSz) if hScale else fSz, basedOn=S_NORM, nextStyle=S_NORM, before=fSz * self._marginHead2[0], after=fSz * self._marginHead2[1], - line=fSz2 * self._lineHeight, + line=fSz * self._lineHeight, level=1, color=hColor, bold=self._boldHeads, @@ -589,12 +583,12 @@ def _generateStyles(self) -> None: styles.append(DocXParStyle( name="Heading 3", styleId=S_HEAD3, - size=fSz3, + size=(nwStyles.H_SIZES[3] * fSz) if hScale else fSz, basedOn=S_NORM, nextStyle=S_NORM, before=fSz * self._marginHead3[0], after=fSz * self._marginHead3[1], - line=fSz3 * self._lineHeight, + line=fSz * self._lineHeight, level=1, color=hColor, bold=self._boldHeads, @@ -604,12 +598,12 @@ def _generateStyles(self) -> None: styles.append(DocXParStyle( name="Heading 4", styleId=S_HEAD4, - size=fSz4, + size=(nwStyles.H_SIZES[4] * fSz) if hScale else fSz, basedOn=S_NORM, nextStyle=S_NORM, before=fSz * self._marginHead4[0], after=fSz * self._marginHead4[1], - line=fSz4 * self._lineHeight, + line=fSz * self._lineHeight, level=1, color=hColor, bold=self._boldHeads, @@ -653,12 +647,12 @@ def _generateStyles(self) -> None: styles.append(DocXParStyle( name="Footnote Text", styleId=S_FNOTE, - size=fnSz, + size=nwStyles.T_SMALL * fSz, basedOn=S_NORM, before=0.0, - after=fnSz * self._marginFoot[1], - left=fnSz * self._marginFoot[0], - line=fnSz * self._lineHeight, + after=fSz * self._marginFoot[1], + left=fSz * self._marginFoot[0], + line=fSz * self._lineHeight, )) # Add to Cache @@ -795,6 +789,7 @@ def _stylesXml(self) -> str: _wTag("before"): str(int(20.0 * firstFloat(style.before))), _wTag("after"): str(int(20.0 * firstFloat(style.after))), _wTag("line"): str(int(20.0 * firstFloat(style.line, size))), + _wTag("lineRule"): "auto", }) if style.left is not None: xmlSubElem(pPr, _wTag("ind"), attrib={ From d8c14f6712fea4e8df17c03bdc507705dd0a913c Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 13 Nov 2024 20:04:52 +0100 Subject: [PATCH 2/7] Make ODT margins scale to em units --- novelwriter/formats/toodt.py | 167 +++++++++++------------------------ 1 file changed, 51 insertions(+), 116 deletions(-) diff --git a/novelwriter/formats/toodt.py b/novelwriter/formats/toodt.py index af78f8921..750e05796 100644 --- a/novelwriter/formats/toodt.py +++ b/novelwriter/formats/toodt.py @@ -173,44 +173,10 @@ def __init__(self, project: NWProject, isFlat: bool) -> None: self._fontStyle = "normal" self._fontPitch = "variable" self._fontBold = "bold" - self._fSizeTitle = "30pt" - self._fSizeHead1 = "24pt" - self._fSizeHead2 = "20pt" - self._fSizeHead3 = "16pt" - self._fSizeHead4 = "14pt" - self._fSizeHead = "14pt" - self._fSizeText = "12pt" - self._fSizeFoot = "10pt" - self._fLineHeight = "115%" self._fBlockIndent = "1.693cm" - self._fTextIndent = "0.499cm" self._dLanguage = "en" self._dCountry = "GB" - # Text Margins - self._mTopTitle = "0.423cm" - self._mTopHead1 = "0.423cm" - self._mTopHead2 = "0.353cm" - self._mTopHead3 = "0.247cm" - self._mTopHead4 = "0.247cm" - self._mTopHead = "0.423cm" - self._mTopText = "0.000cm" - self._mTopMeta = "0.000cm" - self._mTopSep = "0.247cm" - - self._mBotTitle = "0.212cm" - self._mBotHead1 = "0.212cm" - self._mBotHead2 = "0.212cm" - self._mBotHead3 = "0.212cm" - self._mBotHead4 = "0.212cm" - self._mBotHead = "0.212cm" - self._mBotText = "0.247cm" - self._mBotMeta = "0.106cm" - self._mBotSep = "0.247cm" - - self._mBotFoot = "0.106cm" - self._mLeftFoot = "0.600cm" - # Document Size and Margins self._mDocWidth = "21.0cm" self._mDocHeight = "29.7cm" @@ -262,52 +228,14 @@ def initDocument(self) -> None: self._dLanguage = lang or self._dLanguage self._dCountry = country or self._dCountry - self._fontFamily = self._textFont.family() - self._fontSize = self._textFont.pointSize() - self._fontWeight = FONT_WEIGHT_MAP.get(fontWeight, fontWeight) - self._fontStyle = FONT_STYLE.get(self._textFont.style(), "normal") - self._fontPitch = "fixed" if self._textFont.fixedPitch() else "variable" - self._fontBold = FONT_WEIGHT_MAP.get(fontBold, fontBold) - self._headWeight = self._fontBold if self._boldHeads else None - - hScale = self._scaleHeads - self._fSizeTitle = self._emToPt(nwStyles.H_SIZES[0] if hScale else 1.0) # Was 2.50 - self._fSizeHead1 = self._emToPt(nwStyles.H_SIZES[1] if hScale else 1.0) # Was 2.00 - self._fSizeHead2 = self._emToPt(nwStyles.H_SIZES[2] if hScale else 1.0) # Was 1.60 - self._fSizeHead3 = self._emToPt(nwStyles.H_SIZES[3] if hScale else 1.0) # Was 1.30 - self._fSizeHead4 = self._emToPt(nwStyles.H_SIZES[4] if hScale else 1.0) # Was 1.15 - self._fSizeHead = self._emToPt(nwStyles.H_SIZES[4] if hScale else 1.0) # Was 1.15 - self._fSizeText = self._emToPt(1.0) - self._fSizeFoot = self._emToPt(0.8) - - mScale = self._lineHeight/1.15 - - self._mTopTitle = self._emToCm(mScale * self._marginTitle[0]) - self._mTopHead1 = self._emToCm(mScale * self._marginHead1[0]) - self._mTopHead2 = self._emToCm(mScale * self._marginHead2[0]) - self._mTopHead3 = self._emToCm(mScale * self._marginHead3[0]) - self._mTopHead4 = self._emToCm(mScale * self._marginHead4[0]) - self._mTopHead = self._emToCm(mScale * self._marginHead4[0]) - self._mTopText = self._emToCm(mScale * self._marginText[0]) - self._mTopMeta = self._emToCm(mScale * self._marginMeta[0]) - self._mTopSep = self._emToCm(mScale * self._marginSep[0]) - - self._mBotTitle = self._emToCm(mScale * self._marginTitle[1]) - self._mBotHead1 = self._emToCm(mScale * self._marginHead1[1]) - self._mBotHead2 = self._emToCm(mScale * self._marginHead2[1]) - self._mBotHead3 = self._emToCm(mScale * self._marginHead3[1]) - self._mBotHead4 = self._emToCm(mScale * self._marginHead4[1]) - self._mBotHead = self._emToCm(mScale * self._marginHead4[1]) - self._mBotText = self._emToCm(mScale * self._marginText[1]) - self._mBotMeta = self._emToCm(mScale * self._marginMeta[1]) - self._mBotSep = self._emToCm(mScale * self._marginSep[1]) - - self._mLeftFoot = self._emToCm(self._marginFoot[0]) - self._mBotFoot = self._emToCm(self._marginFoot[1]) - - self._fLineHeight = f"{round(100 * self._lineHeight):d}%" + self._fontFamily = self._textFont.family() + self._fontSize = self._textFont.pointSize() + self._fontWeight = FONT_WEIGHT_MAP.get(fontWeight, fontWeight) + self._fontStyle = FONT_STYLE.get(self._textFont.style(), "normal") + self._fontPitch = "fixed" if self._textFont.fixedPitch() else "variable" + self._fontBold = FONT_WEIGHT_MAP.get(fontBold, fontBold) + self._headWeight = self._fontBold if self._boldHeads else None self._fBlockIndent = self._emToCm(self._blockIndent) - self._fTextIndent = self._emToCm(self._firstWidth) # Clear Errors self._errData = [] @@ -782,6 +710,9 @@ def _pageStyles(self) -> None: def _defaultStyles(self) -> None: """Set the default styles.""" + hScale = self._scaleHeads + textSize = self._emToPt(nwStyles.T_NORMAL) + # Add Paragraph Family Style xStyl = ET.SubElement(self._xStyl, _mkTag("style", "default-style"), attrib={ _mkTag("style", "family"): "paragraph", @@ -796,7 +727,7 @@ def _defaultStyles(self) -> None: _mkTag("fo", "font-family"): self._fontFamily, _mkTag("fo", "font-weight"): self._fontWeight, _mkTag("fo", "font-style"): self._fontStyle, - _mkTag("fo", "font-size"): self._fSizeText, + _mkTag("fo", "font-size"): textSize, _mkTag("fo", "language"): self._dLanguage, _mkTag("fo", "country"): self._dCountry, }) @@ -812,7 +743,7 @@ def _defaultStyles(self) -> None: _mkTag("fo", "font-family"): self._fontFamily, _mkTag("fo", "font-weight"): self._fontWeight, _mkTag("fo", "font-style"): self._fontStyle, - _mkTag("fo", "font-size"): self._fSizeText, + _mkTag("fo", "font-size"): textSize, }) # Add Default Heading Style @@ -824,8 +755,8 @@ def _defaultStyles(self) -> None: _mkTag("style", "class"): "text", }) ET.SubElement(xStyl, _mkTag("style", "paragraph-properties"), attrib={ - _mkTag("fo", "margin-top"): self._mTopHead, - _mkTag("fo", "margin-bottom"): self._mBotHead, + _mkTag("fo", "margin-top"): self._emToCm(self._marginHead4[0]), + _mkTag("fo", "margin-bottom"): self._emToCm(self._marginHead4[1]), _mkTag("fo", "keep-with-next"): "always", }) ET.SubElement(xStyl, _mkTag("style", "text-properties"), attrib={ @@ -833,7 +764,7 @@ def _defaultStyles(self) -> None: _mkTag("fo", "font-family"): self._fontFamily, _mkTag("fo", "font-weight"): self._fontWeight, _mkTag("fo", "font-style"): self._fontStyle, - _mkTag("fo", "font-size"): self._fSizeHead, + _mkTag("fo", "font-size"): self._emToPt(nwStyles.H_SIZES[4] if hScale else 1.0), }) # Add Header and Footer Styles @@ -857,20 +788,24 @@ def _defaultStyles(self) -> None: def _useableStyles(self) -> None: """Set the usable styles.""" + hScale = self._scaleHeads hColor = self._theme.head if self._colorHeads else None + textSize = self._emToPt(nwStyles.T_NORMAL) + lineHeight = f"{round(100 * self._lineHeight):d}%" + # Add Text Body Style style = ODTParagraphStyle(S_TEXT) style.setDisplayName("Text body") style.setParentStyleName("Standard") style.setClass("text") - style.setMarginTop(self._mTopText) - style.setMarginBottom(self._mBotText) - style.setLineHeight(self._fLineHeight) + style.setMarginTop(self._emToCm(self._marginText[0])) + style.setMarginBottom(self._emToCm(self._marginText[1])) + style.setLineHeight(lineHeight) style.setTextAlign(self._defaultAlign) style.setFontName(self._fontFamily) style.setFontFamily(self._fontFamily) - style.setFontSize(self._fSizeText) + style.setFontSize(textSize) style.setFontWeight(self._fontWeight) style.packXML(self._xStyl) self._mainPara[style.name] = style @@ -880,7 +815,7 @@ def _useableStyles(self) -> None: style.setDisplayName("First line indent") style.setParentStyleName(S_TEXT) style.setClass("text") - style.setTextIndent(self._fTextIndent) + style.setTextIndent(self._emToCm(self._firstWidth)) style.packXML(self._xStyl) self._mainPara[style.name] = style @@ -889,12 +824,12 @@ def _useableStyles(self) -> None: style.setDisplayName("Text Meta") style.setParentStyleName("Standard") style.setClass("text") - style.setMarginTop(self._mTopMeta) - style.setMarginBottom(self._mBotMeta) - style.setLineHeight(self._fLineHeight) + style.setMarginTop(self._emToCm(self._marginMeta[0])) + style.setMarginBottom(self._emToCm(self._marginMeta[1])) + style.setLineHeight(lineHeight) style.setFontName(self._fontFamily) style.setFontFamily(self._fontFamily) - style.setFontSize(self._fSizeText) + style.setFontSize(textSize) style.setFontWeight(self._fontWeight) style.packXML(self._xStyl) self._mainPara[style.name] = style @@ -905,12 +840,12 @@ def _useableStyles(self) -> None: style.setParentStyleName("Heading") style.setNextStyleName(S_TEXT) style.setClass("chapter") - style.setMarginTop(self._mTopTitle) - style.setMarginBottom(self._mBotTitle) + style.setMarginTop(self._emToCm(self._marginTitle[0])) + style.setMarginBottom(self._emToCm(self._marginTitle[1])) style.setTextAlign("center") style.setFontName(self._fontFamily) style.setFontFamily(self._fontFamily) - style.setFontSize(self._fSizeTitle) + style.setFontSize(self._emToPt(nwStyles.H_SIZES[0] if hScale else 1.0)) style.setFontWeight(self._headWeight) style.packXML(self._xStyl) self._mainPara[style.name] = style @@ -921,13 +856,13 @@ def _useableStyles(self) -> None: style.setParentStyleName("Standard") style.setNextStyleName(S_TEXT) style.setClass("text") - style.setMarginTop(self._mTopSep) - style.setMarginBottom(self._mBotSep) - style.setLineHeight(self._fLineHeight) + style.setMarginTop(self._emToCm(self._marginSep[0])) + style.setMarginBottom(self._emToCm(self._marginSep[1])) + style.setLineHeight(lineHeight) style.setTextAlign("center") style.setFontName(self._fontFamily) style.setFontFamily(self._fontFamily) - style.setFontSize(self._fSizeText) + style.setFontSize(textSize) style.setFontWeight(self._fontWeight) style.packXML(self._xStyl) self._mainPara[style.name] = style @@ -939,11 +874,11 @@ def _useableStyles(self) -> None: style.setNextStyleName(S_TEXT) style.setOutlineLevel("1") style.setClass("text") - style.setMarginTop(self._mTopHead1) - style.setMarginBottom(self._mBotHead1) + style.setMarginTop(self._emToCm(self._marginTitle[1])) + style.setMarginBottom(self._emToCm(self._marginHead1[1])) style.setFontName(self._fontFamily) style.setFontFamily(self._fontFamily) - style.setFontSize(self._fSizeHead1) + style.setFontSize(self._emToPt(nwStyles.H_SIZES[1] if hScale else 1.0)) style.setFontWeight(self._headWeight) style.setColor(hColor) style.packXML(self._xStyl) @@ -956,11 +891,11 @@ def _useableStyles(self) -> None: style.setNextStyleName(S_TEXT) style.setOutlineLevel("2") style.setClass("text") - style.setMarginTop(self._mTopHead2) - style.setMarginBottom(self._mBotHead2) + style.setMarginTop(self._emToCm(self._marginHead2[0])) + style.setMarginBottom(self._emToCm(self._marginHead2[1])) style.setFontName(self._fontFamily) style.setFontFamily(self._fontFamily) - style.setFontSize(self._fSizeHead2) + style.setFontSize(self._emToPt(nwStyles.H_SIZES[2] if hScale else 1.0)) style.setFontWeight(self._headWeight) style.setColor(hColor) style.packXML(self._xStyl) @@ -973,11 +908,11 @@ def _useableStyles(self) -> None: style.setNextStyleName(S_TEXT) style.setOutlineLevel("3") style.setClass("text") - style.setMarginTop(self._mTopHead3) - style.setMarginBottom(self._mBotHead3) + style.setMarginTop(self._emToCm(self._marginHead3[0])) + style.setMarginBottom(self._emToCm(self._marginHead3[1])) style.setFontName(self._fontFamily) style.setFontFamily(self._fontFamily) - style.setFontSize(self._fSizeHead3) + style.setFontSize(self._emToPt(nwStyles.H_SIZES[3] if hScale else 1.0)) style.setFontWeight(self._headWeight) style.setColor(hColor) style.packXML(self._xStyl) @@ -990,11 +925,11 @@ def _useableStyles(self) -> None: style.setNextStyleName(S_TEXT) style.setOutlineLevel("4") style.setClass("text") - style.setMarginTop(self._mTopHead4) - style.setMarginBottom(self._mBotHead4) + style.setMarginTop(self._emToCm(self._marginHead4[0])) + style.setMarginBottom(self._emToCm(self._marginHead4[1])) style.setFontName(self._fontFamily) style.setFontFamily(self._fontFamily) - style.setFontSize(self._fSizeHead4) + style.setFontSize(self._emToPt(nwStyles.H_SIZES[4] if hScale else 1.0)) style.setFontWeight(self._headWeight) style.setColor(hColor) style.packXML(self._xStyl) @@ -1013,10 +948,10 @@ def _useableStyles(self) -> None: style.setDisplayName("Footnote") style.setParentStyleName("Standard") style.setClass("extra") - style.setMarginLeft(self._mLeftFoot) - style.setMarginBottom(self._mBotFoot) - style.setTextIndent("-"+self._mLeftFoot) - style.setFontSize(self._fSizeFoot) + style.setMarginLeft(self._emToCm(self._marginFoot[0])) + style.setMarginBottom(self._emToCm(self._marginFoot[1])) + style.setTextIndent("-"+self._emToCm(self._marginFoot[0])) + style.setFontSize(self._emToPt(nwStyles.T_SMALL)) style.packXML(self._xStyl) self._mainPara[style.name] = style From 220be06631ef9e004b26904b2e6ec0971ef05e52 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 13 Nov 2024 20:05:03 +0100 Subject: [PATCH 3/7] Make HTML margins scale to em units --- novelwriter/formats/tohtml.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/novelwriter/formats/tohtml.py b/novelwriter/formats/tohtml.py index 69a48ac2d..c71dbafd2 100644 --- a/novelwriter/formats/tohtml.py +++ b/novelwriter/formats/tohtml.py @@ -339,26 +339,25 @@ def getStyleSheet(self) -> list[str]: if not self._cssStyles: return [] - mScale = self._lineHeight/1.15 tColor = self._theme.text.name(QtHexRgb) hColor = self._theme.head.name(QtHexRgb) if self._colorHeads else tColor lColor = self._theme.head.name(QtHexRgb) mColor = self._theme.highlight.name(QtHexRgb) - mtH0 = mScale * self._marginTitle[0] - mbH0 = mScale * self._marginTitle[1] - mtH1 = mScale * self._marginHead1[0] - mbH1 = mScale * self._marginHead1[1] - mtH2 = mScale * self._marginHead2[0] - mbH2 = mScale * self._marginHead2[1] - mtH3 = mScale * self._marginHead3[0] - mbH3 = mScale * self._marginHead3[1] - mtH4 = mScale * self._marginHead4[0] - mbH4 = mScale * self._marginHead4[1] - mtTT = mScale * self._marginText[0] - mbTT = mScale * self._marginText[1] - mtSP = mScale * self._marginSep[0] - mbSP = mScale * self._marginSep[1] + mtH0 = self._marginTitle[0] + mbH0 = self._marginTitle[1] + mtH1 = self._marginHead1[0] + mbH1 = self._marginHead1[1] + mtH2 = self._marginHead2[0] + mbH2 = self._marginHead2[1] + mtH3 = self._marginHead3[0] + mbH3 = self._marginHead3[1] + mtH4 = self._marginHead4[0] + mbH4 = self._marginHead4[1] + mtTT = self._marginText[0] + mbTT = self._marginText[1] + mtSP = self._marginSep[0] + mbSP = self._marginSep[1] font = self._textFont fFam = font.family() From 7a111bb1730565e27f69c55621f866ec7710035d Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 13 Nov 2024 20:24:10 +0100 Subject: [PATCH 4/7] Update default margins --- novelwriter/constants.py | 18 +++++++++--------- novelwriter/formats/toodt.py | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/novelwriter/constants.py b/novelwriter/constants.py index bd5efac5f..2c54ad257 100644 --- a/novelwriter/constants.py +++ b/novelwriter/constants.py @@ -118,15 +118,15 @@ class nwStyles: "SP": QT_TRANSLATE_NOOP("Constant", "Scene Separator"), } T_MARGIN = { - "H0": (1.42, 0.50), # Title margins - "H1": (1.42, 0.50), # Heading 1 margins - "H2": (1.67, 0.50), # Heading 2 margins - "H3": (1.17, 0.50), # Heading 3 margins - "H4": (1.17, 0.50), # Heading 4 margins - "TT": (0.00, 0.58), # Text margins - "SP": (1.17, 1.17), # Separator margins - "MT": (0.00, 0.58), # Meta margins - "FT": (1.42, 0.47), # Footnote margins + "H0": (1.50, 0.60), # Title margins (top, bottom) + "H1": (1.50, 0.60), # Heading 1 margins (top, bottom) + "H2": (1.50, 0.60), # Heading 2 margins (top, bottom) + "H3": (1.20, 0.60), # Heading 3 margins (top, bottom) + "H4": (1.20, 0.60), # Heading 4 margins (top, bottom) + "TT": (0.00, 0.60), # Text margins (top, bottom) + "SP": (1.20, 1.20), # Separator margins (top, bottom) + "MT": (0.00, 0.60), # Meta margins (top, bottom) + "FT": (1.20, 0.40), # Footnote margins (left, bottom) } diff --git a/novelwriter/formats/toodt.py b/novelwriter/formats/toodt.py index 750e05796..37ba5943e 100644 --- a/novelwriter/formats/toodt.py +++ b/novelwriter/formats/toodt.py @@ -874,7 +874,7 @@ def _useableStyles(self) -> None: style.setNextStyleName(S_TEXT) style.setOutlineLevel("1") style.setClass("text") - style.setMarginTop(self._emToCm(self._marginTitle[1])) + style.setMarginTop(self._emToCm(self._marginHead1[0])) style.setMarginBottom(self._emToCm(self._marginHead1[1])) style.setFontName(self._fontFamily) style.setFontFamily(self._fontFamily) From ed431aa30fee68551b3dcaf6c8879a9d39d0ec7b Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 13 Nov 2024 20:40:44 +0100 Subject: [PATCH 5/7] Update tests --- novelwriter/constants.py | 2 +- novelwriter/formats/todocx.py | 1 + .../fmtToDocX_SaveDocument_document.xml | 46 +++++++++---------- .../fmtToDocX_SaveDocument_styles.xml | 22 ++++----- .../reference/fmtToOdt_SaveFlat_document.fodt | 26 +++++------ tests/reference/fmtToOdt_SaveFull_styles.xml | 20 ++++---- .../mBuildDocBuild_HTML5_Lorem_Ipsum.htm | 14 +++--- .../mBuildDocBuild_HTML5_Lorem_Ipsum.json | 18 ++++---- ...uildDocBuild_OpenDocument_Lorem_Ipsum.fodt | 26 +++++------ tests/test_formats/test_fmt_todocx.py | 2 +- tests/test_formats/test_fmt_toodt.py | 4 -- 11 files changed, 89 insertions(+), 92 deletions(-) diff --git a/novelwriter/constants.py b/novelwriter/constants.py index 2c54ad257..dc4a44ebe 100644 --- a/novelwriter/constants.py +++ b/novelwriter/constants.py @@ -126,7 +126,7 @@ class nwStyles: "TT": (0.00, 0.60), # Text margins (top, bottom) "SP": (1.20, 1.20), # Separator margins (top, bottom) "MT": (0.00, 0.60), # Meta margins (top, bottom) - "FT": (1.20, 0.40), # Footnote margins (left, bottom) + "FT": (1.40, 0.40), # Footnote margins (left, bottom) } diff --git a/novelwriter/formats/todocx.py b/novelwriter/formats/todocx.py index 6410a5e99..42d42bc54 100644 --- a/novelwriter/formats/todocx.py +++ b/novelwriter/formats/todocx.py @@ -1166,6 +1166,7 @@ def toXml(self, body: ET.Element) -> None: _wTag("before"): str(int(20.0 * firstFloat(self._topMargin, style.before))), _wTag("after"): str(int(20.0 * firstFloat(self._bottomMargin, style.after))), _wTag("line"): str(int(20.0 * firstFloat(style.line, style.size))), + _wTag("lineRule"): "auto", }) if indent: xmlSubElem(pPr, _wTag("ind"), attrib=indent) diff --git a/tests/reference/fmtToDocX_SaveDocument_document.xml b/tests/reference/fmtToDocX_SaveDocument_document.xml index 132468c6f..4f4be68fe 100644 --- a/tests/reference/fmtToDocX_SaveDocument_document.xml +++ b/tests/reference/fmtToDocX_SaveDocument_document.xml @@ -231,7 +231,7 @@ - + @@ -254,7 +254,7 @@ - + @@ -277,7 +277,7 @@ - + @@ -331,7 +331,7 @@ - + @@ -354,7 +354,7 @@ - + @@ -377,7 +377,7 @@ - + @@ -472,7 +472,7 @@ - + @@ -495,7 +495,7 @@ - + @@ -518,7 +518,7 @@ - + @@ -634,7 +634,7 @@ - + @@ -657,7 +657,7 @@ - + @@ -680,7 +680,7 @@ - + @@ -734,7 +734,7 @@ - + @@ -757,7 +757,7 @@ - + @@ -780,7 +780,7 @@ - + @@ -875,7 +875,7 @@ - + @@ -898,7 +898,7 @@ - + @@ -921,7 +921,7 @@ - + @@ -1035,7 +1035,7 @@ - + @@ -1058,7 +1058,7 @@ - + @@ -1081,7 +1081,7 @@ - + @@ -1197,7 +1197,7 @@ - + @@ -1230,7 +1230,7 @@ - + diff --git a/tests/reference/fmtToDocX_SaveDocument_styles.xml b/tests/reference/fmtToDocX_SaveDocument_styles.xml index f730b33ab..112ea3ba4 100644 --- a/tests/reference/fmtToDocX_SaveDocument_styles.xml +++ b/tests/reference/fmtToDocX_SaveDocument_styles.xml @@ -18,7 +18,7 @@ - + @@ -31,7 +31,7 @@ - + @@ -45,7 +45,7 @@ - + @@ -60,7 +60,7 @@ - + @@ -75,7 +75,7 @@ - + @@ -90,7 +90,7 @@ - + @@ -105,7 +105,7 @@ - + @@ -118,7 +118,7 @@ - + @@ -129,7 +129,7 @@ - + @@ -141,8 +141,8 @@ - - + + diff --git a/tests/reference/fmtToOdt_SaveFlat_document.fodt b/tests/reference/fmtToOdt_SaveFlat_document.fodt index 0b500e35b..a8cc3808b 100644 --- a/tests/reference/fmtToOdt_SaveFlat_document.fodt +++ b/tests/reference/fmtToOdt_SaveFlat_document.fodt @@ -1,13 +1,13 @@ - 2024-10-29T23:24:19 - novelWriter/2.6a3 + 2024-11-13T20:28:36 + novelWriter/2.6b1 Jane Smith 1234 P42DT12H34M56S Test Project - 2024-10-29T23:24:19 + 2024-11-13T20:28:36 Jane Smith @@ -22,7 +22,7 @@ - + @@ -30,45 +30,45 @@ - + - + - + - + - + - + - + - + - + diff --git a/tests/reference/fmtToOdt_SaveFull_styles.xml b/tests/reference/fmtToOdt_SaveFull_styles.xml index 9b34773aa..87323ee18 100644 --- a/tests/reference/fmtToOdt_SaveFull_styles.xml +++ b/tests/reference/fmtToOdt_SaveFull_styles.xml @@ -12,7 +12,7 @@ - + @@ -20,45 +20,45 @@ - + - + - + - + - + - + - + - + - + diff --git a/tests/reference/mBuildDocBuild_HTML5_Lorem_Ipsum.htm b/tests/reference/mBuildDocBuild_HTML5_Lorem_Ipsum.htm index 8e9a6b321..8632ec974 100644 --- a/tests/reference/mBuildDocBuild_HTML5_Lorem_Ipsum.htm +++ b/tests/reference/mBuildDocBuild_HTML5_Lorem_Ipsum.htm @@ -5,16 +5,16 @@ Lorem Ipsum diff --git a/tests/reference/mBuildDocBuild_HTML5_Lorem_Ipsum.json b/tests/reference/mBuildDocBuild_HTML5_Lorem_Ipsum.json index b4a31f8db..8ad0ccc8e 100644 --- a/tests/reference/mBuildDocBuild_HTML5_Lorem_Ipsum.json +++ b/tests/reference/mBuildDocBuild_HTML5_Lorem_Ipsum.json @@ -2,22 +2,22 @@ "meta": { "projectName": "Lorem Ipsum", "novelAuthor": "lipsum.com", - "buildTime": 1730136403, - "buildTimeStr": "2024-10-28 18:26:43" + "buildTime": 1731526420, + "buildTimeStr": "2024-11-13 20:33:40" }, "text": { "css": [ "body {color: #000000; font-family: 'Arial'; font-size: 12pt; font-weight: 400; font-style: normal;}", - "p {text-align: left; line-height: 150%; margin-top: 0.00em; margin-bottom: 0.76em;}", + "p {text-align: left; line-height: 150%; margin-top: 0.00em; margin-bottom: 0.60em;}", "a {color: #4271ae;}", "mark {background: #ffffa6;}", "h1, h2, h3, h4 {color: #4271ae; page-break-after: avoid;}", - "h1 {margin-top: 1.85em; margin-bottom: 0.65em;}", - "h2 {margin-top: 2.18em; margin-bottom: 0.65em;}", - "h3 {margin-top: 1.53em; margin-bottom: 0.65em;}", - "h4 {margin-top: 1.53em; margin-bottom: 0.65em;}", - ".title {font-size: 2.5em; margin-top: 1.85em; margin-bottom: 0.65em;}", - ".sep {text-align: center; margin-top: 1.53em; margin-bottom: 1.53em;}" + "h1 {margin-top: 1.50em; margin-bottom: 0.60em;}", + "h2 {margin-top: 1.50em; margin-bottom: 0.60em;}", + "h3 {margin-top: 1.20em; margin-bottom: 0.60em;}", + "h4 {margin-top: 1.20em; margin-bottom: 0.60em;}", + ".title {font-size: 2.5em; margin-top: 1.50em; margin-bottom: 0.60em;}", + ".sep {text-align: center; margin-top: 1.20em; margin-bottom: 1.20em;}" ], "html": [ [ diff --git a/tests/reference/mBuildDocBuild_OpenDocument_Lorem_Ipsum.fodt b/tests/reference/mBuildDocBuild_OpenDocument_Lorem_Ipsum.fodt index 9f61c7a4b..c95b67ee6 100644 --- a/tests/reference/mBuildDocBuild_OpenDocument_Lorem_Ipsum.fodt +++ b/tests/reference/mBuildDocBuild_OpenDocument_Lorem_Ipsum.fodt @@ -1,13 +1,13 @@ - 2024-10-29T09:41:30 - novelWriter/2.6a3 + 2024-11-13T20:33:59 + novelWriter/2.6b1 lipsum.com 50 P0DT0H40M48S Lorem Ipsum - 2024-10-29T09:41:30 + 2024-11-13T20:33:59 lipsum.com @@ -22,7 +22,7 @@ - + @@ -30,45 +30,45 @@ - + - + - + - + - + - + - + - + - + diff --git a/tests/test_formats/test_fmt_todocx.py b/tests/test_formats/test_fmt_todocx.py index 2ae740baa..53e9fd588 100644 --- a/tests/test_formats/test_fmt_todocx.py +++ b/tests/test_formats/test_fmt_todocx.py @@ -395,7 +395,7 @@ def testFmtToDocX_ParagraphFormatting(mockGUI): doc._pars[-1].toXml(xTest) assert xmlToText(xTest) == ( '' - '' + '' 'Hello World' ) diff --git a/tests/test_formats/test_fmt_toodt.py b/tests/test_formats/test_fmt_toodt.py index 3c9aa8f70..7267bf3a0 100644 --- a/tests/test_formats/test_fmt_toodt.py +++ b/tests/test_formats/test_fmt_toodt.py @@ -803,10 +803,6 @@ def testFmtToOdt_SaveFlat(mockGUI, fncPath, tstPaths, ipsumText): odt._isNovel = True odt.setHeaderFormat(nwHeadFmt.DOC_AUTO, 1) assert odt._headerFormat == nwHeadFmt.DOC_AUTO - odt.setFirstLineIndent(True, 1.4, False) - assert odt._firstIndent is True - assert odt._fTextIndent == "0.499cm" - assert odt._indentFirst is False odt.setPageLayout(148, 210, 20, 18, 17, 15) assert odt._mDocWidth == "14.800cm" From 57641ecd7d7a7d5d6d48fbb46ec0f88fb55e967d Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 13 Nov 2024 20:50:47 +0100 Subject: [PATCH 6/7] Make page number work with Office 365 --- novelwriter/formats/todocx.py | 4 +--- tests/reference/fmtToDocX_SaveDocument_header1.xml | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/novelwriter/formats/todocx.py b/novelwriter/formats/todocx.py index 42d42bc54..1a9af220f 100644 --- a/novelwriter/formats/todocx.py +++ b/novelwriter/formats/todocx.py @@ -855,12 +855,10 @@ def _defaultHeaderXml(self) -> str: xR = xmlSubElem(xP, _wTag("r")) xmlSubElem(xR, _wTag("fldChar"), attrib={wFldCT: "begin"}) xR = xmlSubElem(xP, _wTag("r")) - _wText(xR, " PAGE ") + xmlSubElem(xR, _wTag("instrText"), "PAGE", attrib={_mkTag("xml", "space"): "preserve"}) xR = xmlSubElem(xP, _wTag("r")) xmlSubElem(xR, _wTag("fldChar"), attrib={wFldCT: "separate"}) xR = xmlSubElem(xP, _wTag("r")) - _wText(xR, "0") - xR = xmlSubElem(xP, _wTag("r")) xmlSubElem(xR, _wTag("fldChar"), attrib={wFldCT: "end"}) if post: xR = xmlSubElem(xP, _wTag("r")) diff --git a/tests/reference/fmtToDocX_SaveDocument_header1.xml b/tests/reference/fmtToDocX_SaveDocument_header1.xml index 1135d8539..4acc8f9ef 100644 --- a/tests/reference/fmtToDocX_SaveDocument_header1.xml +++ b/tests/reference/fmtToDocX_SaveDocument_header1.xml @@ -13,14 +13,11 @@ - PAGE + PAGE - - 0 - From a96ccf84222a944b7a24a5265ee4de00fd83e486 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Wed, 13 Nov 2024 23:16:54 +0100 Subject: [PATCH 7/7] Add icons for text margins --- .../assets/icons/typicons_dark/icons.conf | 6 +++ .../typicons_dark/mixed_margin-bottom.svg | 6 +++ .../icons/typicons_dark/mixed_margin-left.svg | 6 +++ .../typicons_dark/mixed_margin-right.svg | 6 +++ .../icons/typicons_dark/mixed_margin-top.svg | 6 +++ .../icons/typicons_dark/mixed_size-height.svg | 6 +++ .../icons/typicons_dark/mixed_size-width.svg | 6 +++ .../assets/icons/typicons_light/icons.conf | 6 +++ .../typicons_light/mixed_margin-bottom.svg | 6 +++ .../typicons_light/mixed_margin-left.svg | 6 +++ .../typicons_light/mixed_margin-right.svg | 6 +++ .../icons/typicons_light/mixed_margin-top.svg | 6 +++ .../typicons_light/mixed_size-height.svg | 6 +++ .../icons/typicons_light/mixed_size-width.svg | 6 +++ novelwriter/extensions/configlayout.py | 8 +++- novelwriter/gui/theme.py | 3 +- novelwriter/tools/manussettings.py | 43 +++++++++++-------- 17 files changed, 116 insertions(+), 22 deletions(-) create mode 100644 novelwriter/assets/icons/typicons_dark/mixed_margin-bottom.svg create mode 100644 novelwriter/assets/icons/typicons_dark/mixed_margin-left.svg create mode 100644 novelwriter/assets/icons/typicons_dark/mixed_margin-right.svg create mode 100644 novelwriter/assets/icons/typicons_dark/mixed_margin-top.svg create mode 100644 novelwriter/assets/icons/typicons_dark/mixed_size-height.svg create mode 100644 novelwriter/assets/icons/typicons_dark/mixed_size-width.svg create mode 100644 novelwriter/assets/icons/typicons_light/mixed_margin-bottom.svg create mode 100644 novelwriter/assets/icons/typicons_light/mixed_margin-left.svg create mode 100644 novelwriter/assets/icons/typicons_light/mixed_margin-right.svg create mode 100644 novelwriter/assets/icons/typicons_light/mixed_margin-top.svg create mode 100644 novelwriter/assets/icons/typicons_light/mixed_size-height.svg create mode 100644 novelwriter/assets/icons/typicons_light/mixed_size-width.svg diff --git a/novelwriter/assets/icons/typicons_dark/icons.conf b/novelwriter/assets/icons/typicons_dark/icons.conf index b70c1da51..c9f7a5461 100644 --- a/novelwriter/assets/icons/typicons_dark/icons.conf +++ b/novelwriter/assets/icons/typicons_dark/icons.conf @@ -64,6 +64,10 @@ font = nw_font.svg forward = typ_chevron-right.svg import = mixed_import.svg list = typ_th-list.svg +margin_bottom = mixed_margin-bottom.svg +margin_left = mixed_margin-left.svg +margin_right = mixed_margin-right.svg +margin_top = mixed_margin-top.svg maximise = typ_arrow-maximise.svg menu = typ_th-dot-menu.svg minimise = typ_arrow-minimise.svg @@ -94,6 +98,8 @@ search_regex = nw_search-regex.svg search_replace = mixed_search-replace.svg search_word = nw_search-word.svg settings = typ_cog.svg +size_height = mixed_size-height.svg +size_width = mixed_size-width.svg star = typ_star.svg status_idle = typ_media-pause-grey.svg status_lang = typ_globe-grey.svg diff --git a/novelwriter/assets/icons/typicons_dark/mixed_margin-bottom.svg b/novelwriter/assets/icons/typicons_dark/mixed_margin-bottom.svg new file mode 100644 index 000000000..986b19e2e --- /dev/null +++ b/novelwriter/assets/icons/typicons_dark/mixed_margin-bottom.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/novelwriter/assets/icons/typicons_dark/mixed_margin-left.svg b/novelwriter/assets/icons/typicons_dark/mixed_margin-left.svg new file mode 100644 index 000000000..84358b19c --- /dev/null +++ b/novelwriter/assets/icons/typicons_dark/mixed_margin-left.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/novelwriter/assets/icons/typicons_dark/mixed_margin-right.svg b/novelwriter/assets/icons/typicons_dark/mixed_margin-right.svg new file mode 100644 index 000000000..a828f7c20 --- /dev/null +++ b/novelwriter/assets/icons/typicons_dark/mixed_margin-right.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/novelwriter/assets/icons/typicons_dark/mixed_margin-top.svg b/novelwriter/assets/icons/typicons_dark/mixed_margin-top.svg new file mode 100644 index 000000000..a7e3933cd --- /dev/null +++ b/novelwriter/assets/icons/typicons_dark/mixed_margin-top.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/novelwriter/assets/icons/typicons_dark/mixed_size-height.svg b/novelwriter/assets/icons/typicons_dark/mixed_size-height.svg new file mode 100644 index 000000000..0c05bcff7 --- /dev/null +++ b/novelwriter/assets/icons/typicons_dark/mixed_size-height.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/novelwriter/assets/icons/typicons_dark/mixed_size-width.svg b/novelwriter/assets/icons/typicons_dark/mixed_size-width.svg new file mode 100644 index 000000000..6c8c76226 --- /dev/null +++ b/novelwriter/assets/icons/typicons_dark/mixed_size-width.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/novelwriter/assets/icons/typicons_light/icons.conf b/novelwriter/assets/icons/typicons_light/icons.conf index cf18d9660..c3cc9b766 100644 --- a/novelwriter/assets/icons/typicons_light/icons.conf +++ b/novelwriter/assets/icons/typicons_light/icons.conf @@ -64,6 +64,10 @@ font = nw_font.svg forward = typ_chevron-right.svg import = mixed_import.svg list = typ_th-list.svg +margin_bottom = mixed_margin-bottom.svg +margin_left = mixed_margin-left.svg +margin_right = mixed_margin-right.svg +margin_top = mixed_margin-top.svg maximise = typ_arrow-maximise.svg menu = typ_th-dot-menu.svg minimise = typ_arrow-minimise.svg @@ -94,6 +98,8 @@ search_regex = nw_search-regex.svg search_replace = mixed_search-replace.svg search_word = nw_search-word.svg settings = typ_cog.svg +size_height = mixed_size-height.svg +size_width = mixed_size-width.svg star = typ_star.svg status_idle = typ_media-pause-grey.svg status_lang = typ_globe-grey.svg diff --git a/novelwriter/assets/icons/typicons_light/mixed_margin-bottom.svg b/novelwriter/assets/icons/typicons_light/mixed_margin-bottom.svg new file mode 100644 index 000000000..863472968 --- /dev/null +++ b/novelwriter/assets/icons/typicons_light/mixed_margin-bottom.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/novelwriter/assets/icons/typicons_light/mixed_margin-left.svg b/novelwriter/assets/icons/typicons_light/mixed_margin-left.svg new file mode 100644 index 000000000..436f8f8d9 --- /dev/null +++ b/novelwriter/assets/icons/typicons_light/mixed_margin-left.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/novelwriter/assets/icons/typicons_light/mixed_margin-right.svg b/novelwriter/assets/icons/typicons_light/mixed_margin-right.svg new file mode 100644 index 000000000..4462801c6 --- /dev/null +++ b/novelwriter/assets/icons/typicons_light/mixed_margin-right.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/novelwriter/assets/icons/typicons_light/mixed_margin-top.svg b/novelwriter/assets/icons/typicons_light/mixed_margin-top.svg new file mode 100644 index 000000000..4eb684f94 --- /dev/null +++ b/novelwriter/assets/icons/typicons_light/mixed_margin-top.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/novelwriter/assets/icons/typicons_light/mixed_size-height.svg b/novelwriter/assets/icons/typicons_light/mixed_size-height.svg new file mode 100644 index 000000000..4deb1a4c5 --- /dev/null +++ b/novelwriter/assets/icons/typicons_light/mixed_size-height.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/novelwriter/assets/icons/typicons_light/mixed_size-width.svg b/novelwriter/assets/icons/typicons_light/mixed_size-width.svg new file mode 100644 index 000000000..b63fe98d8 --- /dev/null +++ b/novelwriter/assets/icons/typicons_light/mixed_size-width.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/novelwriter/extensions/configlayout.py b/novelwriter/extensions/configlayout.py index a34b7cdea..2bd48032a 100644 --- a/novelwriter/extensions/configlayout.py +++ b/novelwriter/extensions/configlayout.py @@ -27,7 +27,7 @@ """ from __future__ import annotations -from PyQt5.QtGui import QColor, QFont, QPalette +from PyQt5.QtGui import QColor, QFont, QPalette, QPixmap from PyQt5.QtWidgets import ( QAbstractButton, QFrame, QHBoxLayout, QLabel, QLayout, QScrollArea, QVBoxLayout, QWidget @@ -183,7 +183,7 @@ def addGroupLabel(self, label: str, identifier: int | None = None) -> None: def addRow( self, label: str | None, - widget: QWidget | list[QWidget | str | int], + widget: QWidget | list[QWidget | QPixmap | str | int], helpText: str = "", unit: str | None = None, button: QWidget | None = None, @@ -200,6 +200,10 @@ def addRow( for item in widget: if isinstance(item, QWidget): wBox.addWidget(item) + elif isinstance(item, QPixmap): + icon = QLabel(self) + icon.setPixmap(item) + wBox.addWidget(icon) elif isinstance(item, str): wBox.addWidget(QLabel(item, self)) elif isinstance(item, int): diff --git a/novelwriter/gui/theme.py b/novelwriter/gui/theme.py index 340951cfa..b4ef50566 100644 --- a/novelwriter/gui/theme.py +++ b/novelwriter/gui/theme.py @@ -500,7 +500,8 @@ class GuiIcons: # Format Icons "fmt_bold", "fmt_bold-md", "fmt_italic", "fmt_italic-md", "fmt_mark", "fmt_strike", - "fmt_strike-md", "fmt_subscript", "fmt_superscript", "fmt_underline", + "fmt_strike-md", "fmt_subscript", "fmt_superscript", "fmt_underline", "margin_bottom", + "margin_left", "margin_right", "margin_top", "size_height", "size_width", # General Button Icons "add", "add_document", "backward", "bookmark", "browse", "checked", "close", "copy", diff --git a/novelwriter/tools/manussettings.py b/novelwriter/tools/manussettings.py index 098b1ce7c..f4c658e79 100644 --- a/novelwriter/tools/manussettings.py +++ b/novelwriter/tools/manussettings.py @@ -964,15 +964,6 @@ def buildForm(self) -> None: spW = 6*SHARED.theme.textNWidth dbW = 8*SHARED.theme.textNWidth - # Common Translations - - trW = self.tr("W:") # Width - trH = self.tr("H:") # Height - trT = self.tr("T:") # Top - trB = self.tr("B:") # Bottom - trL = self.tr("L:") # Left - trR = self.tr("R:") # Right - # Text Content # ============ @@ -1084,6 +1075,13 @@ def buildForm(self) -> None: self._sidebar.addButton(title, section) self.addGroupLabel(title, section) + pixT = SHARED.theme.getPixmap("margin_top", (iPx, iPx)) + pixB = SHARED.theme.getPixmap("margin_bottom", (iPx, iPx)) + pixL = SHARED.theme.getPixmap("margin_left", (iPx, iPx)) + pixR = SHARED.theme.getPixmap("margin_right", (iPx, iPx)) + pixH = SHARED.theme.getPixmap("size_height", (iPx, iPx)) + pixW = SHARED.theme.getPixmap("size_width", (iPx, iPx)) + # Title self.titleMarginT = NDoubleSpinBox(self) self.titleMarginT.setFixedWidth(dbW) @@ -1093,7 +1091,8 @@ def buildForm(self) -> None: self.addRow( trConst(nwStyles.T_LABEL["H0"]), - [trT, self.titleMarginT, 6, trB, self.titleMarginB], + [pixT, self.titleMarginT, 6, pixB, self.titleMarginB], + unit="em", ) # Heading 1 @@ -1105,7 +1104,8 @@ def buildForm(self) -> None: self.addRow( trConst(nwStyles.T_LABEL["H1"]), - [trT, self.h1MarginT, 6, trB, self.h1MarginB], + [pixT, self.h1MarginT, 6, pixB, self.h1MarginB], + unit="em", ) # Heading 2 @@ -1117,7 +1117,8 @@ def buildForm(self) -> None: self.addRow( trConst(nwStyles.T_LABEL["H2"]), - [trT, self.h2MarginT, 6, trB, self.h2MarginB], + [pixT, self.h2MarginT, 6, pixB, self.h2MarginB], + unit="em", ) # Heading 3 @@ -1129,7 +1130,8 @@ def buildForm(self) -> None: self.addRow( trConst(nwStyles.T_LABEL["H3"]), - [trT, self.h3MarginT, 6, trB, self.h3MarginB], + [pixT, self.h3MarginT, 6, pixB, self.h3MarginB], + unit="em", ) # Heading 4 @@ -1141,7 +1143,8 @@ def buildForm(self) -> None: self.addRow( trConst(nwStyles.T_LABEL["H4"]), - [trT, self.h4MarginT, 6, trB, self.h4MarginB], + [pixT, self.h4MarginT, 6, pixB, self.h4MarginB], + unit="em", ) # Text @@ -1153,7 +1156,8 @@ def buildForm(self) -> None: self.addRow( trConst(nwStyles.T_LABEL["TT"]), - [trT, self.textMarginT, 6, trB, self.textMarginB], + [pixT, self.textMarginT, 6, pixB, self.textMarginB], + unit="em", ) # Separator @@ -1165,7 +1169,8 @@ def buildForm(self) -> None: self.addRow( trConst(nwStyles.T_LABEL["SP"]), - [trT, self.sepMarginT, 6, trB, self.sepMarginB], + [pixT, self.sepMarginT, 6, pixB, self.sepMarginB], + unit="em", ) # Page Layout @@ -1198,7 +1203,7 @@ def buildForm(self) -> None: self.addRow( self._build.getLabel("format.pageSize"), - [self.pageSize, 6, trW, self.pageWidth, 6, trH, self.pageHeight], + [self.pageSize, 6, pixW, self.pageWidth, 6, pixH, self.pageHeight], ) # Page Margins @@ -1216,11 +1221,11 @@ def buildForm(self) -> None: self.addRow( self._build.getLabel("format.pageMargins"), - [trT, self.topMargin, 6, trB, self.bottomMargin], + [pixT, self.topMargin, 6, pixB, self.bottomMargin], ) self.addRow( "", - [trL, self.leftMargin, 6, trR, self.rightMargin], + [pixL, self.leftMargin, 6, pixR, self.rightMargin], ) # Open Document