Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faux italic and bold in build preview and pdf build on some(?) Linux distributions #2110

Closed
HeyMyian opened this issue Nov 18, 2024 · 7 comments
Labels
minor issue Issue: Mostly harmless qt issue Issue: Upstream issue in Qt user interface Component: General user interface

Comments

@HeyMyian
Copy link
Contributor

HeyMyian commented Nov 18, 2024

This is for 2.6 Beta 1 but it probably applies to older novelWriter versions too. I tested the AppImage and deb on Ubuntu, and the AppImage on KDE neon. I've used the freshest versions of Ubuntu and KDE neon, both fresh installs in a VM.

Works as expected on Ubuntu. I'm guessing it's the same as you're seeing on Debian.

But on KDE neon, the build preview and the pdf build use faux italic and faux bold. I don't quite understand why: If I select "Serif" in the font family dialog, it will select a standard serif font as specified by the operating system (is my guess). This will put "Noto Serif Regular" into the MBS and this will render true italic and true bold. But if I explicitly select the font "Noto Serif Regular", faux italic and faux bold are used. Any other explicitly set font will also use faux italic and faux bold.

The fonts are installed correctly, as selecting e.g. "Noto Serif Italic" will render the whole build preview and pdf build in true italic, as expected.

I hope that this makes sense to you and this can be fixed in the novelWriter code.


(True italics in most fonts can be easily seen in a more nicely shaped letter f. Faux bold either doubles-up the letters, which can be seen when zoomed in on the letter i, or it puts a less noticeable outline around the letters.)

(Issue discussed also in #2100)

@HeyMyian
Copy link
Contributor Author

It just occured to me that the novelWriter UI on KDE neon probably also uses faux bold. I've never noticed because there is nothing italic, which is more easily distinguishable than bold, in the UI. Can verify that by activating "Emphasize partition and chapter labels", and selecting a large font, e.g. "48pt Noto Serif Regular". Faux bold simply doesn't get applied at all at larger font sizes.

@HeyMyian
Copy link
Contributor Author

The editor uses true italic and true bold. The document viewer uses faux. 🙈

@vkbo
Copy link
Owner

vkbo commented Nov 21, 2024

I'll look into whether I need to manually change font styles. The viewer/preview/pdf all uses the ToQTextDocument class in the formats folder, and it changes between styles by setting the bold/italic/underline flags. That may not be sufficient? I will investigate.

Seems like there will be a 2.6 Beta 2 release before the RC 1 anyway, as I've spent the last week completely rewriting the project tree and how it is loaded and handled at runtime. This definitely needs testing in the wild before release. The new implementation should be more robust though, but there may be interaction bugs with the UI.

@vkbo vkbo added user interface Component: General user interface minor issue Issue: Mostly harmless labels Nov 21, 2024
@vkbo vkbo added this to the Release 2.6 Beta 2 milestone Nov 21, 2024
@vkbo
Copy link
Owner

vkbo commented Nov 25, 2024

Just dropping by to say that maybe one of these will give some clues.

@vkbo
Copy link
Owner

vkbo commented Nov 25, 2024

It just occured to me that the novelWriter UI on KDE neon probably also uses faux bold. I've never noticed because there is nothing italic, which is more easily distinguishable than bold, in the UI. Can verify that by activating "Emphasize partition and chapter labels", and selecting a large font, e.g. "48pt Noto Serif Regular". Faux bold simply doesn't get applied at all at larger font sizes.

Hmm. these issues may actually be KDE-specific. See comments in QTBUG-75027. See also QTBUG-63792.

I think the problem arose when I added the option to allow selecting font style in novelWriter from #1733. As far as I can tell from the Qt docs, when I call setFontWeight() on a character format, it should pick the correct weight. So I will revert the code to not try to determine what weight to use on its own. When I implemented the above feature, I also added code to calculate what weight to use relative to the selected style weight, so thin style would render bold as normal, and bold style would use extra bold for bold.

I'm removing those modifications and instead saving the default style of the selected font, and reverting to that when the bold, italic, underline, etc, styles in the text are reset to normal. This seems to work as expected for thin fonts in the preview, but testing on ODT output, I think LibreOffice uses fixed weights for normal and bold (i.e. 400 and 700), so relative weight may be needed. At least LibreOffice shows bolder bold for extra thin than manuscript preview does.

@vkbo
Copy link
Owner

vkbo commented Nov 25, 2024

Ok, looking into how LibreOffice handles bold/italic/etc with non-regular fonts, it simply uses the default bold and italic flags, like here for Raleway ExtraLight. No need for the specific font weight numerical values.

 <office:automatic-styles>
  <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard">
   <style:text-properties style:font-name="Raleway ExtraLight" officeooo:rsid="0009fcb5" officeooo:paragraph-rsid="0009fcb5"/>
  </style:style>
  <style:style style:name="T1" style:family="text">
   <style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
  </style:style>
  <style:style style:name="T2" style:family="text">
   <style:text-properties fo:font-weight="normal" style:font-weight-asian="normal" style:font-weight-complex="normal"/>
  </style:style>
  <style:style style:name="T3" style:family="text">
   <style:text-properties fo:font-style="italic" fo:font-weight="normal" style:font-style-asian="italic" style:font-weight-asian="normal" style:font-style-complex="italic" style:font-weight-complex="normal"/>
  </style:style>
  <style:style style:name="T4" style:family="text">
   <style:text-properties fo:font-style="normal" fo:font-weight="normal" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-style-complex="normal" style:font-weight-complex="normal"/>
  </style:style>
  <style:style style:name="T5" style:family="text">
   <style:text-properties fo:font-style="normal" style:text-underline-style="solid" style:text-underline-width="auto" style:text-underline-color="font-color" fo:font-weight="normal" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-style-complex="normal" style:font-weight-complex="normal"/>
  </style:style>
  <style:style style:name="T6" style:family="text">
   <style:text-properties fo:font-style="normal" style:text-underline-style="none" fo:font-weight="normal" style:font-style-asian="normal" style:font-weight-asian="normal" style:font-style-complex="normal" style:font-weight-complex="normal"/>
  </style:style>
 </office:automatic-styles>

@vkbo vkbo added the qt issue Issue: Upstream issue in Qt label Dec 3, 2024
@vkbo
Copy link
Owner

vkbo commented Dec 3, 2024

With the changes made in #2122 that ensures standard font emphasis is used, I don't think there's more I can do on this. The KDE-specific issues seem to be Qt-related, and nothing to do with novelWriter. Let's see how this goes when we move to Qt6.

@vkbo vkbo closed this as completed Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor issue Issue: Mostly harmless qt issue Issue: Upstream issue in Qt user interface Component: General user interface
Projects
None yet
Development

No branches or pull requests

2 participants