Using Editor to diagnose and/or fix badly kerned text

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
DIV
User
Posts: 252
Joined: Fri Jun 23, 2017 1:47 am

Using Editor to diagnose and/or fix badly kerned text

Post by DIV »

Hello, all.
There are some smart people here who might be able to solve a mystery for me.

I have a Word document that I have edited (updated) a number of times, over several years, and created PDF files from by exporting using the engine built into MS Word 2013.
Suddenly in 2021 there was a problem. I subsequently noticed that the two most recently exported PDF files had horrible text kerning — worse than no kerning at all, I would say. So maybe I should describe it as ugly character spacing instead.
Malformatted screenshot:
Malformatted screenshot
Malformatted screenshot
Reprinted screenshot:
Reprinted screenshot
Reprinted screenshot
The spacing issue seems most noticeable with the positioning of the (thin) letters "i" and "l". Compare e.g. the word "simulation" in both screenshots, in the last line of the 2nd and 3rd paragraphs.
UPDATE: I've just noticed that even the size of the serif text is slightly different in the two screenshots. I don't have much sans serif text in the document, but it also seems to be a slightly different size, although perhaps not suffering from the ugly character spacing within words (but with different spacing between words). I forgot to mention that the blue ruled line under the heading also seems to have a different thickness in the two documents.


At first I wondered whether maybe the PDF file was OK, and it was just the display/rendering in Editor that had suddenly somehow messed up. But no, the same issue was found in other PDF viewers too. So it was definitely a problem within the PDF file. But I couldn't find an indication of the issue from looking over the respective document properties. Both files contained embedded fonts, and were created on the same computer using the same software, with access to the same installed fonts.

Could it be a problem with the Word documents? Maybe. But they displayed fine within MS Word.

Maybe an issue with inappropriate PDF exporting settings, or perhaps incompatibility with new formatting in the documents? After recognising the issue I tried re-exporting individual pages with different settings (still using the MS engine in Word), and could not reproduce the same malformed character spacing.

Eventually I just exported the entire documents again (in 2022; as per second screenshot, above), and this time the ugly spacing was gone.

I have a vague recollection of seeing some similar poorly spaced characters within text of PDF files found online on the odd occasion, and just assumed it was due to an 'incompatibility' or a 'bug' in the PDF creation tool.

Questions:
  • Any ideas (in general) as to what causes this type of issue? And hence how to avoid it?
  • Besides looking at the text carefully, is there a way to diagnose this — using PDF-XChange Editor or some other tool?
    (For instance something in the metadata???)
  • Is there a convenient way to fix this in existing PDF files — using PDF-XChange Editor or some other tool — rather than starting from scratch and exporting a fresh PDF file from the source document (which might not be available)?
Thanks,
DIV

P.S. Sorry that this post is not 100% on-topic, but I've tried to wrangle the subject to keep relevant to the forum.

P.P.S. In extracting sample pages I set the options to 'copy' a single page within Editor, then manually edited to remove entire 'blocks' of text, and finally redacted a few words. Off-topic: I was interested to note that none of the source document's metadata were copied across into the new document.
Attachments
20220119_PDF-export_Reprinted.pdf
Reprinted extract
(136.34 KiB) Downloaded 25 times
20220119_PDF-export_Malformatted.pdf
Malformatted extract
(136.31 KiB) Downloaded 27 times
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Using Editor to diagnose and/or fix badly kerned text

Post by Tracker Supp-Stefan »

Hello DIV,

Thanks for the detailed problem description and the sample files.
This is likely caused by the font itself and how Word interprets that. Some fonts are provided by windows itself, and I believe TimesNewRoman is one of those. So a windows update could have affected this font as well.
Did you maybe e.g. upgrade to Win11 or did some other major windows update between the 'good' and 'bad' results?
I see that both files were created with build 358 of the Editor. Are the new correct ones created with build 359 or are you still at 358?

Kind regards,
Stefan
DIV
User
Posts: 252
Joined: Fri Jun 23, 2017 1:47 am

Re: Using Editor to diagnose and/or fix badly kerned text

Post by DIV »

Hi, Stefan.

I believe you're right about TimesNewRoman being provided with Windows. (I didn't mention before, but I'm still using Windows 8.1 x64). The current version of this installed on my system is 6.89 (stamped 06 August 1990), and is in TTF format, rather than OTF.
On the other hand, it did seem as though some of the other content was also affected, even if not quite in the same way.

There was no memorable 'major' update, but — as you know — there are multiple Windows updates throughout the year, and occasional updates to Office too.
I did have a suspicion of some sort of rogue update being responsible. Mainly because I seem to have eliminated most of the other alternatives that aren't date-dependent.
The other alternative is that it was an unreproducible fluke. Even though it happened for two separate PDF files (created from the progressively updated Word document) ~3 days apart, maybe I had not rebooted my computer in between, so maybe some weird memory corruption (say) occurred in that period.

I run a portable 'installation' of Editor, and am still on build 358.
In any case, the original PDF files were all generated in MS Word.
Malformatted properties.
Malformatted properties.
image.png (32.33 KiB) Viewed 581 times
Reprinted properties.
Reprinted properties.
image1.png (34.75 KiB) Viewed 581 times
(As I mentioned, the properties didn't get copied when I extracted the pages.)

—DIV
DIV
User
Posts: 252
Joined: Fri Jun 23, 2017 1:47 am

Re: Using Editor to diagnose and/or fix badly kerned text

Post by DIV »

It's not easy to provide the original properties without uploading the original file.
Here are some more screenshots for the original malformatted PDF.
image1.png
image.png
image.png
image1.png
I cannot see any obvious differences in the metadata or other properties between the two exported files. I just see the visual effect. As mentioned, the discrepancy between the two files does not seem to be caused by Editor.

—DIV
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Using Editor to diagnose and/or fix badly kerned text

Post by Tracker Supp-Stefan »

Hello DIV,

When a font is embedded inside a PDF file - there is a lot of information that needs to be recorded (e.g. how much space should be left on each side of the glyph - so a single letter is not just the black part we see, but also some small space around it). If when this particular version of your file was being created, those spaced were not recorded correctly - it could result in the file appearing with the incorrect/irregular letter spacing. As you have noticed - this is not an issue with just how we display it, but is rather an issue with how the font was recorded in the file. So the problem occurred at creation time. Whether it was Word/Windows that processed the font information incorrectly and passed it to the tool that created the PDF, or if the tool itself did not to it 100% right is hard to tell from your samples and without seeing the source, all exact steps (maybe with some logs), and the final result together, but something at that point 'messed up' the letters in your file.

There is no quick or easy way to fix this - as the problem is now recorded in the embedded font inside that particular PDF file.
Also - technically there is nothing 'wrong' with the file itself. It is a correct file as far as the PDF spec is concerned. The fact that the letters of that embedded font look "crooked" to us does not make them incorrect in terms of what's stored in the document.
You might be able to 'fix' it by e.g. replacing this font with another one in the Editor, but this will need to be done one text block at a time and is definitely not ideal and should probably only be used as a last resort.

If you have the source document and can now produce correct copies of the file - I'd recommend that we just leave those older ones be as there is little that can be done for them, and as you already have newer better versions - there is also no point.

Kind regards,
Stefan
DIV
User
Posts: 252
Joined: Fri Jun 23, 2017 1:47 am

Re: Using Editor to diagnose and/or fix badly kerned text

Post by DIV »

Thanks for the additional explanation, Stefan.

You're right that (somehow) I was able to go back to the source documents and make new, 'correct' PDF files on this occasion. So in large measure my enquiry was prospective, to deal with (or avoid) future occurrence.

I did think that perhaps unembedding the presumed-corrupt font definition from the malformatted PDF file might be a sensible starting point. I'll keep it in mind in case the need arises. I agree that it would be extremely laborious to go through block-by-block though. (Possibly some clever JavaScript code could be written to handle it.)

—DIV

P.S. I agree with you that the "malformatted" PDF is likely fully compliant with the relevant specifications. Sorry if that wasn't clear to all from my description.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Using Editor to diagnose and/or fix badly kerned text

Post by Tracker Supp-Stefan »

Hello DIV,

Glad I could provide some clarity on what's happening when fonts are stored in a PDF file, and happy that you managed to get a correct copy of your file.

Kind regards,
Stefan
Post Reply