[Beta 23/Technical Proof] How Fonts can get their Look back...in Scrivener

Thoughtfulness keeps my words just to the specifics about this, which leaves a good story to tell.

  • There was such a lot of misinformation, and I felt how over-worked @lee and @tiho_d must be, so in brief, I looked up present states of the Qt framework at the heart of Windows Scrivener, and made the bet of downloading the development environment. And kept adding what’s necessary, as even that is shall we say, tricky.
  • I did this mainly because I’d found there was a styling text editor as one of its demo projects, in effect a mini-model of Scrivener. I got that to build, and tried the same collection of fonts with text that you can find pictures of in the recent Fonts Scrivener postings.
  • The result immediately: the test texts had just the same poor look as in Scrivener 22. Yes. Identical. So the issue isn’t nor following supposed patterns in the Qt software. Points for Lee and Tiho.

Then, Qt has been very well known for years as having, shall we say, issues, about making clean rich text. Miracle solutions have been built and deposed. Their own screenshots always are in mono fonts, and still look rough. We won’t speculate the possible reasons, but we can look into what they seem to have. Or, maybe…

  • What I actually found is that their development environment doesn’t go far – in particular, reading out values in their data structures in active code was going to be pretty much a manual proposition. Somehow in a developed resistive sensibility to this sort of thing, and with growing hunger, I decided instead to plug some values in, see what I got.
  • I arranged this, as the code picture will show, by inserting instructions into menu operation of the Editor. While it was changing a font size, then it was also setting how to handle font hinting, which along with true anti-aliasing gone missing, looked a clear symptom in view well to attack.
  • First I put in what documentation suggested Tiho ‘should have at some much earlier point’: QFont::PreferFullHinting, And guess what? No change, which indicates that he or default wisely taken did this.

Then comes the place that experienced skulduggery gets you somewhere, though. So that I can get back out of this software, regain a faction of my Sunday, and return to the fiction whose scatter of notes the phrases we test arrived from…

  • So, I plugged in an oppositional enum value: QFont::PreferNoHinting. This ‘should’ be exactly the wrong thing to do. Except we may reckon something about real software’s actual ranges of vagaries.
  • The result, you can see below. Remarkable improvement.
  • The rendering may even be as ‘right’ as it’s going to get in small sizing and on Windows, and on non-Mac-level screens. It’s great. It looks like the Word rendering, quite possibly better (and yes, better is possible, as that Word has its own kinks is well known). Both anti-aliasing and hinting are properly in use.

Conclusion. I believe that this value can be set as the application default for font rendering, up front in the program code.

  • I tried it in this model on the most problematic of the test fonts, each turned to looking good, looking readable at a glance. Even the blockiness-helped Calibri is nothing but rather visibly improved.
  • Why it does this can be reckoned at a distance of time, after a successful RC, or dare we speak it, comfort for release.
  • The real reason may turn out to be that this flag releases Windows to do its own job properly again – or, other…
  • But if Tiho finds it does the job for now, as it seems to, why not?

Ok, the pictures.

The first is of this demo Text Editor, with my test text inserted above its default, left for veracity. You should ignore the font name in the UI, as it comes back one off from the one you set - another little pre-packaged fault.

The spindly and uneven top phrase is in Minion Pro, actually a pretty robust font of its nature from Adobe, 12 point size for consistency of all tests, and yes, again, Windows screens show fonts smaller than paper unless you magnify.

The kicker is in the second phrase. It’s exactly the same, 12 point Minion Pro. With the difference that this time it’s antialiased so it has substance to the eye, and yes, it’s also following hinting, so that it places each letter optically where it should be for your smooth reading. Nice, isn’t it. This is what Scrivener deserves, so that in all eyes, it shines, no?

As before, the picture you see here in the forum is also wrong-sized and a bit fuzzy, because of how your browser treats forum images, badly magnifying them. So I’ll give the link to download the real screen image first, which you can then see full truth from, opened in your proper image editor (not MS Photo with its similar problems, thank you).

https://www.dropbox.com/s/d4ip3qqnbu6p1xl/qt-demo-fix-font-render.png?dl=1

Ok, then, here is a link to the place on the Qt documentation page for the flags available, and the one I used to fix this:

https://doc.qt.io/qt-5/qfont.html#HintingPreference-enum

And last, a screenshot of the development editor, showing where i inserted the call in the Font Size menu action, just above the red dots, which were debug points.

It’s re-magnified and fuzzy too, just not so much, having started out larger: So it gets the real image download first also…

https://www.dropbox.com/s/cmesu2s5dbricbc/qt-mod-code.png?dl=1

One observation that may be a clue for later is that in this demo Project, copying and pasting a paragraph repaired by the coded work-around reverted.

The pasted version was back to the rough look.

The fix may well work as an up-front default; then this factor can be applied in any later deeper analysis.

It does seem to indicate copy/cut/paste isn’t picking up all properties of text, though, or is re-defaulting them, which really should never do, so this is something to be watched for as you go for deliverable completeness.

There’s always some or something of the sort, isn’t there, Tiho…

Cheers,
Clive

That’s remarkable. It’s interesting that QT’s hinting algorithms are not helpful.

What are the other consequences of changing that value? Are there any?

Windows is not the best at rendering fonts, either, and your results may depend on the values of settings in Windows.

Thanks, and no, Windows isn’t the cleanest, but it can do an adequate job, I guess we prove most days.

As far as potential issues, professionally of course there are a few that have come to mind.

a. As mentioned above, it’s possible that the repairing move works because Windows native has changed, is fine by itself, and the combination with Qt’s methods actually breaks font rendering back to naïve; hence better not to engage it.

b. It’s also possible that at some point, Qt developers got the meanings of their flags inverted, so that what I did just turned intended operation back on. I don’t have the time here to dig that deeply, and I’m trusting on all matters that Lee and Tiho will do whatever they feel gives confidence, once they see this work in the first place.

c. What i mentioned above about noticing copy/cut-paste not honoring the flag value is worrying, and needs a close look to see if it’s something to patch or code around for releasable Scrivener. It’s not unheard of. This does seem another indication that they at Qt may not have been paying a lot of close attention to Windows operation,

d. The question can come up also as to which versions of Windows this fix is solid on. In corporates, an amount still haven’t changed from Windows 7, and inclusive of small business, that’s probably the essential one to test. The beta ought to be a place to find out about the scattering of versions not up to latest Win10. through the community.

That’s the sort of outline I see, and I’m quite confident of Lee and Tiho knowing what they want to engage with, once they see the simple change first operate on their own code.

The important thing is that it’s now clear, well, that Scrivener 3’s in its fonts and texts can be clear.

As nice looking, attractive, and visually easy to work with in writing, as any other tools out there.

For myself and anyone else who relies on the ability to ‘catch at a glance’ for editing and noticing what you’d like to improve, not to mention favoring eyes to stay fit over long entertainments of getting said what you imagine, it would be great, wouldn’t it?

As far as continued introductions and healthy sales, seems also the better is the more inviting…but the team knows that, and can judge among themselves what degree’s worth the effort…
.