Issue 102911 - kerning fails for "DejaVu Serif" on Windows
Summary: kerning fails for "DejaVu Serif" on Windows
Status: CLOSED NOT_AN_OOO_ISSUE
Alias: None
Product: gsl
Classification: Code
Component: code (show other issues)
Version: OOo 3.1
Hardware: PC Windows XP
: P3 Trivial (vote)
Target Milestone: OOo 3.3
Assignee: hdu@apache.org
QA Contact: issues@gsl
URL:
Keywords:
Depends on:
Blocks: 103157
  Show dependency tree
 
Reported: 2009-06-18 14:48 UTC by anieden
Modified: 2009-11-09 08:04 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
The ODF file showing the problem (7.57 KB, application/vnd.oasis.opendocument.text)
2009-06-18 14:49 UTC, anieden
no flags Details
WV screenshot (7.76 KB, image/png)
2009-06-25 22:03 UTC, bormant
no flags Details
fixed DejaVuSerif with kerning fix for WIN32 (248.88 KB, application/octet-stream)
2009-06-30 16:21 UTC, hdu@apache.org
no flags Details
patch for FontForge (1.18 KB, patch)
2009-07-01 07:10 UTC, hdu@apache.org
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description anieden 2009-06-18 14:48:22 UTC
When using the DejaVu Serif font, kerning works on Ubuntu Linux 9.04, but not on
Windows XP. I will attach an ODT file with two identical lines, the upper one
with kerning disabled, the lower one with kerning enabled.

When you open the attached file on a Windows XP system, both lines have the same
length. When you open it on a Linux system, the lower line is shortened by kerning.

I would like kerning to work on Windows, too.

DejaVu is a set of fonts that can be obtained here: http://dejavu-fonts.org/
Comment 1 anieden 2009-06-18 14:49:34 UTC
Created attachment 63068 [details]
The ODF file showing the problem
Comment 2 philipp.lohmann 2009-06-18 14:54:23 UTC
please have a look
Comment 3 philipp.lohmann 2009-06-18 15:05:35 UTC
reassign
Comment 4 bormant 2009-06-25 22:02:05 UTC
Windows XP Prof SP3, DejaVu Serif v2.21 (from OS), v2.29 from dejavu-fonts.org

It seems to be a Windows--DejaVu trouble. Ms word viewer can't render this case 
too, but both OOo and WV can render Times New Roman with and without kerning.
Comment 5 bormant 2009-06-25 22:03:23 UTC
Created attachment 63217 [details]
WV screenshot
Comment 6 hdu@apache.org 2009-06-26 06:09:00 UTC
DejaVu has both GPOS.kern and SFNT.kern tables. OOo currently only supports SFNT.kerning, but since 
both tables are available and both are expected to provide the same pairs they should work... unless the 
information they provide is different. Or the kerning is not expressible in SFNT.kern, which can only cover 
horizontal pair kerning.
Comment 7 anieden 2009-06-26 07:43:16 UTC
Would that mean that OpenOffice does the exact same thing on Linux (where it
works) and Windows (where it doesn’t)? In that case, the problem would be the
font, Ubuntu maybe having modified the SFNT.kern tables.
Comment 8 kpalagin 2009-06-26 08:21:05 UTC
Confirming as per bormant.
Comment 9 hdu@apache.org 2009-06-30 12:48:37 UTC
On WinXP GetKerningPairsA() returns 0 when "DejaVu Serif" or DejaVu Serif Condensed" are selected into 
the HDC. The same call works for "DejaVu Sans" "DejaVu Sans Condensed" and ""DejaVu Sans Light". 
Analyzing...
Comment 10 hdu@apache.org 2009-06-30 14:18:10 UTC
Interestingly GetKerningPairsW() works for the problematic fonts when it is asked for the number of pairs, 
but if fails when asked for the actual pairs.
Comment 11 hdu@apache.org 2009-06-30 15:45:16 UTC
Maybe the WIN GDI call GetKerningPairs() fails because it cannot map every glyph pair referenced in the 
SFNT.kern.fmt1 array back to a unicode pair.

E.g. "DejaVu Serif 2.2.1" has 1316 kerning pairs, two of which are problematic. They reference glyph 2408 
("Circumflex") which is not covered in the CMAP tables, so GDI cannot map that glyph back to its code 
point. The pairs are "CircumFlex"+"Comma"-73 and "CircumFlex"+"Period"-73. Could someone 
experienced with fontforge remove these two pairs and test with the fixed fonts?
Comment 12 hdu@apache.org 2009-06-30 16:21:20 UTC
Created attachment 63292 [details]
fixed DejaVuSerif with kerning fix for WIN32
Comment 13 hdu@apache.org 2009-06-30 16:32:57 UTC
With the font I attached above WIN GDI is happy. For the test I just assigned a random unicode point to 
glyph2008 and GetKerningPairs() now works as expected. WordViewer seems to trust this API too and so 
has the same problem as OOo with the original "DejaVu Serif".

If GetKerningPairs() would only return the pairs it knows about everything would be fine too. I guess 
nobody would complain if a circumflex+comma or period wouldn't kern perfectly. The only way work 
around problematic fonts of this kind is is to parse the kern tables ourselves on Windows too, like we do 
on UNX... darn. The much simpler way is to get the most important FOSS fonts checked. Maybe fontforge 
should warn in this case.
Comment 14 hdu@apache.org 2009-07-01 07:10:33 UTC
Created attachment 63298 [details]
patch for FontForge
Comment 15 hdu@apache.org 2009-07-01 07:50:05 UTC
Every windows application that relies on the GDI call GetKerningPairs() will fail with these problematic 
fonts. On the other hand the font's kern table is valid and OOo is right that it trusts GDI to provide the 
kerning pairs. There are four ways to fix it:
1. fix Windows so that GetKerningPairs() ignores pairs it cannot handle
2. remove the problematic kernings from the DejaVu Serif fonts
3. make sure that every glyph mentioned in the kern table has a (proper or dummy) unicode inside the 
baseplane
4. make OOo and all other Windows applications avoid GDI calls and parse all font tables themselves

Fixing the problematic fonts seems to be the best way. To identify them I sent a patch for fontforge 
which warns when such a problematic font is being generated. The mail should show up in 
http://sourceforge.net/mailarchive/forum.php?forum_name=fontforge-
devel&max_rows=25&style=ultimate&viewmonth=200907 soon.
Comment 16 Mechtilde 2009-07-12 18:52:33 UTC
invalid -> closed
Comment 17 nmailhot 2009-11-07 13:35:22 UTC
@hdu: when OO.o cares about something in fonts *please make sure it is detected
by fontforge's fontlint* (and with a message people can actually understand)

There are thousands of ways fonts can differ, some of them are detected but do
not matter because apps learned how to workaround them, others do matter but are
not detected (or hidden behind black vodoo messages)

If you don't give people the means to detect problems that affect OO.o, you'll
continue to get fed problem fonts
Comment 18 hdu@apache.org 2009-11-09 08:04:49 UTC
Fontforge itself now warns about the problematic fonts:
See http://thread.gmane.org/gmane.comp.fonts.fontforge.devel/6359/focus=640
and http://fontforge.cvs.sourceforge.net/viewvc/fontforge/fontforge/fontforge/tottfaat.c?
r1=1.41&r2=1.42

> and with a message people can actually understand

I'm not a native speaker so I apologize that I just came up with this message
"Kerning is likely to fail on Windows" "On Windows many apps will have problems with this font's 
kerning, because %d of its glyph kern pairs cannot be mapped to unicode-BMP  kern pairs"

Suggestions on a new wording that make the problem much clearer are very welcome.