Bug report #3345

Bug: Spacing is messed up in composer labels

Added by Alister Hood almost 10 years ago. Updated over 9 years ago.

Status:Closed
Priority:Low
Assignee:Marco Hugentobler
Category:-
Affected QGIS version: Regression?:No
Operating System:All Easy fix?:No
Pull Request or Patch supplied: Resolution:
Crashes QGIS or corrupts data: Copied to github as #:13405

Description

(Maybe this should be priority="critical" as you could say the printed output is "corrupted")

When printing from the composer (either to paper or to a virtual PDF printer) the letter spacing is messed up in some composer labels.
See attached screenshot.
Exporting to SVG is OK.

I haven't seen the same problem in legend text or map labels, but maybe I just haven't tested enough (I always export to SVG due to this problem and others).

I'm guessing this bug could be related to r7364 or even #2937

title_messed_up.PNG - screenshot of composer label with messed up font spacing (3.72 KB) Alister Hood, 2010-12-16 02:37 PM

faulty_composer_label.qgs - example project with faulty composer labels (2.69 KB) Alister Hood, 2010-12-19 02:27 AM

document1.pdf - example output with faulty composer label (12.8 KB) Alister Hood, 2010-12-19 02:28 AM

qgis.pdf (5.29 KB) Alister Hood, 2011-03-02 08:54 PM

document1.2.pdf (10.4 KB) Alister Hood, 2011-03-02 08:55 PM

document7.zip (7.61 KB) Alister Hood, 2011-03-02 09:00 PM

calibri.PNG (18.2 KB) Alister Hood, 2011-03-02 09:01 PM

History

#1 Updated by Alister Hood almost 10 years ago

Sorry, #2937 is a duplicate of #2796

#2 Updated by Alister Hood almost 10 years ago

I guess this could be caused by a library, not by QGIS itself...

#3 Updated by Marco Hugentobler almost 10 years ago

It is a bug in the Qt library. However, in the composer, we use a workaround for it (request larger fonts and downscale the painter). So maybe the workaround needs to be improved or fixed for the label.

#4 Updated by Marco Hugentobler almost 10 years ago

Hm, difficult to reproduce. Maybe it only happens with some fonts / fontsizes?
Could you attach an empty project that contains no layer, just one composer with one label where the problem occures? Also, do you use the composer pdf export or the pdf printer in the print dialog (and which one on which OS)?

#5 Updated by Alister Hood almost 10 years ago

Maybe it only happens with some fonts / fontsizes?

Ah, yes. It occurs with Calibri, but not with a couple of other fonts I've tested now. It does not seem to depend on font size.

It looks like there may actually be a couple of separate issues:

1. Spaces being inserted (This can be demonstrated by printing to PDF, opening the output file and copying into a text editor).

2. Some characters missing (The question mark ? on the first line of this example).

3. Some characters being too close together.

Also, do you use the composer pdf export or the pdf printer

A separate pdf printer, from the print dialogue. This is in Windows XP, and the problem occurs with both the Adobe printer and the PdFill printer (which uses ghostscript). But it also occurs if I use a real printer to print to paper.

#6 Updated by Alister Hood almost 10 years ago

It isn't just Calibri - I've now found another couple of fonts that also exhibit the problem. These ones are called "Candara" and "Constantia".

#7 Updated by Marco Hugentobler almost 10 years ago

I tested it with the Qt pdf export and the system pdf printer on ubuntu. Both produce output as expected. Don't know if it might be a problem in the gdi print engine of Qt.

The Qt pdf export should give the same results on all platforms. It does however rasterize the text (I guess that's why you use a gdi pdf printer instead).

#8 Updated by Alister Hood over 9 years ago

Both produce output as expected.

Interesting. Do you actually have the Calibri font installed?

The Qt pdf export should give the same results on all platforms. It does however rasterize the text (I guess that's why you use a gdi pdf printer instead).

Yes. There were also a number of bugs with the built-in pdf export, but I can't remember if any are still open.
Note that this is not a PDF problem - it also occurs when I print to a real printer.

#9 Updated by Alister Hood over 9 years ago

Interesting.

I no longer get the same results with the test file. But there is still a problem. The f in the first line is stretched and joined to the i. I get the same result in Windows and Linux, whether using the button to export to PDF, or printing. I'll attach some new examples.

#10 Updated by Alister Hood over 9 years ago

I think this is probably a different bug from what I originally reported, because I can actually see it in the composer (see calibri.PNG), not just in the printouts.

The top of the f is stretched if there is an l or a k to the right, and the middle is stretched if there is an i or a j to the right.

This occurs only with fonts that exhibited the original bug (e.g. "Calibri", "Candara" and "Constantia").

#11 Updated by Alister Hood over 9 years ago

  • Status changed from Open to Closed
  • Resolution set to upstream

The same effect shows up using these fonts in Gnumeric in Linux, so I assume this is a freetype issue.

If the original problem shows up again I'll reopen.

#12 Updated by Alister Hood over 9 years ago

Sorry, I meant abiword, not gnumeric :)

Testing with ftview and ftstring does not show the same problem, so I guess it is something about the way QT (and GTK for abiword) are using freetype.

#13 Updated by Alister Hood over 9 years ago

Hmmm, I'm guessing this is something to do with opentype kerning:
http://web.archiveorange.com/archive/v/QpqYzHxnWiKoob2ztzE9

FT_Get_Kerning only has access to the old "kern" TrueType table, which
Calibri does not include. Kerning in Calibri is realized only using the
modern "kern" feature implemented in the "GPOS" OpenType table. To
access that table, you should use an OpenType Layout engine such as
HarfBuzz, Pango, ICU Layout, Uniscribe, Bitstream Panorama or Monotype
WorldType, before you use FreeType to perform the glyph imaging.

This is a good idea anyway. FreeType is useful to perform glyph imaging,
but its text layout abilities are very limited.

Also available in: Atom PDF