Bug 47333 - Wrong glyph positions
Summary: Wrong glyph positions
Status: RESOLVED DUPLICATE of bug 89621
Alias: None
Product: poppler
Classification: Unclassified
Component: splash backend (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Windows (All)
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-14 23:41 UTC by cobra.yu
Modified: 2015-04-17 20:46 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
This file is using some fonts with phonetic symbols. The 7th Chinese glyph on the first vertical line demostrates the issue. (773.78 KB, application/pdf)
2012-03-14 23:41 UTC, cobra.yu
Details
Please see the difference bwt the two readers. (179.87 KB, image/jpeg)
2012-03-16 07:29 UTC, cobra.yu
Details
Please see the circled regions. (184.66 KB, image/jpeg)
2012-03-16 07:41 UTC, cobra.yu
Details
sample PDF with guide rectangle (774.43 KB, application/octet-stream)
2012-05-06 02:08 UTC, suzuki toshiya
Details
experimental patch to fix this issue (478 bytes, patch)
2012-05-06 06:38 UTC, suzuki toshiya
Details | Splinter Review
result by experimental patch (47.66 KB, image/png)
2012-05-06 06:58 UTC, suzuki toshiya
Details

Description cobra.yu 2012-03-14 23:41:39 UTC
Created attachment 58468 [details]
This file is using some fonts with phonetic symbols. The 7th Chinese glyph on the first vertical line demostrates the issue.

PDF files with Chinese characters inside accompanied with phonetic symbols(bopomofo)caused wrong glyph positions.
Comment 1 Albert Astals Cid 2012-03-15 11:22:05 UTC
Could you please attach a screenshot with a marker of which character is wrongly possitioned? As a non chinese speaker it's not trivial for me to recognise what's wrong
Comment 2 cobra.yu 2012-03-16 07:29:24 UTC
Created attachment 58558 [details]
Please see the difference bwt the two readers.
Comment 3 Albert Astals Cid 2012-03-16 07:31:55 UTC
Can you please use gimp, kolourpaint or any program to edit that screenshot and clearly mark where the problem is?
Comment 4 cobra.yu 2012-03-16 07:41:37 UTC
Created attachment 58559 [details]
Please see the circled regions.
Comment 5 Albert Astals Cid 2012-03-16 07:56:48 UTC
Thanks :-)
Comment 6 suzuki toshiya 2012-05-02 08:02:10 UTC
Yet I've not checked the detail, but it seems that the vertical
centerlines of "蘿" and "蔔" are not completely synchronized
(the vertical lines of "艹" are slightly different) even in Adobe
Reader. In addition, I think all texts are rendered in vertical
writing mode (except of the page number, LithosPro?), but pdffonts
find a horizontal font; YenRoundZuinnEG-Md-ETen-B5-H-Identity-H.
I think it's related with this issue. I will check more in detail...
Comment 7 suzuki toshiya 2012-05-06 02:08:34 UTC
Created attachment 61086 [details]
sample PDF with guide rectangle

I attached a slightly modified sample. Please compare the results with
Adobe Reader (or Ghostscript) and poppler/xpdf. I added a rectangle to
show the expected positions. From the comparison, it is known that the
shifted character is NOT "蔔". Contrary, the correctly positioned glyph
is only "蔔", and other glyphs are shifted.

If you select each glyphs on Adobe Reader, you will find how "蔔" is
different from other glyphs. In most glyphs, the bopomofo annotation
is built-in. The fonts named "LinGothicZuinnEG-Bd-ETen-B5-V-Identity-V"
or like that are CID-keyed font, the glyph for one CID is a composite
glyph of Hanzi and annotation Bopomofo. Most texts are drawn by such
"pre-annotated" fonts. But "蔔" is exceptional. "蔔" is drawn by
the fonts like "LinGothic-Bold-ETen-B5-V-Identity-V". It is regular
Hanzi font, the glyph have no Bopomofo annotation.

I guess xpdf & poppler calculates the vertical centerline for the
annotated glyphs mistakenly, because the bounding box of the annotated
glyphs are not square.
Comment 8 suzuki toshiya 2012-05-06 06:38:30 UTC
Created attachment 61102 [details] [review]
experimental patch to fix this issue

Here is an experimental patch to fix this issue.
GfxFont::getNextChar() calculates the vector (vx,vy) to translate
the coordinate system from horizontal writing mode to vertical
writing mode, it uses the default glyph width & height of the font,
and external data to overwrite it. When GfxCIDFont object is created,
the width & height are set to 1.0 & -1.0 by default, and overwritten
if PDF has DW or DW2 values (out of font file stream). It seems that
what kind of FontBBox is written in the font file stream is not used
for the default width & height. I'm not sure if it is appropriate /or
not, but anyway, 1.0 & -1.0 are clearly incorrect if the bounding box
of the glyphs are not square. This patch calculates vx by the FontBBox
instead of default width. There would be 2 options;
vx = fontBBox[2] (right edge) - fontBBox[0] (left edge)
vx = fontBBox[2] (right edge) - 0 (origin)
From the experiment, it seems that former calculation is an
overcompensation.

I think this patch is half-baked. I should check if default width
should be calculated from fontBBox, and, the comment to fontBBox
member "for Type3" is correct (if so, I should not use fontBBox
for CID-keyed Type1!). Anyway, this patch shows a possible way to
fix this issue.
Comment 9 suzuki toshiya 2012-05-06 06:58:14 UTC
Created attachment 61104 [details]
result by experimental patch

The rasterization result with the patch
Comment 10 suzuki toshiya 2012-05-07 07:24:38 UTC
From the earlier PDF spec (1.3), the metrics defined by DW, W, DW2, W2
are requested to be consistent with those in the font file stream (see p.317)
Maybe FontBBox[] for all glyphs is not exact solution, per-glyph width
values should be retrieved via FoFi library, I think.
Comment 11 Jason Crain 2015-04-17 20:46:38 UTC

*** This bug has been marked as a duplicate of bug 89621 ***


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.