Skip to content

Commit

Permalink
Correct pixel units
Browse files Browse the repository at this point in the history
  • Loading branch information
vkbo committed Nov 15, 2024
1 parent 22ca004 commit e480c93
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions novelwriter/formats/toqdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def initDocument(self) -> None:
self._document.setDefaultFont(self._textFont)

fPt = self._textFont.pointSizeF()
mPx = fPt*90.0/72.0 # 1 em in pixels
mPx = fPt*96.0/72.0 # 1 em in pixels

# Scaled Sizes
# ============
Expand Down Expand Up @@ -245,12 +245,8 @@ def saveDocument(self, path: Path) -> None:
writer.setPageMargins(self._pageMargins, QPageLayout.Unit.Millimeter)
writer.setResolution(1200)

# We need to correct for a discrepancy between screen resolution
# (96 DPI) and the one used for font size (72 DPI). See #2100.
adjustedSize = writer.pageLayout().paintRect(QPageLayout.Unit.Point).size()*96.0/72.0

self._document.setDocumentMargin(0.0)
self._document.setPageSize(adjustedSize)
# The document needs size in pixels. See #2100.
self._document.setPageSize(QSizeF(writer.pageLayout().paintRectPixels(96).size()))
self._document.print(writer)

return
Expand Down

0 comments on commit e480c93

Please sign in to comment.