First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 11785
Product:
Component:
Status: RESOLVED
Resolution: FIXED
Assigned To: Marc Maurer <uwog@uwog.net>
Hardware:
OS:
Version:
Priority:
Severity:
Target Milestone:
Reporter: Sayamindu Dasgupta <sayamindu@laptop.org>
Add CC:
CC:
Remove selected CCs
QA Contact:
URL:
Summary:
Status Whiteboard:
Keywords:

Attachment Type Creator Created Size Flags Actions
Screenshot of garbled rendering image/png Sayamindu Dasgupta 2008-10-09 16:26 20.85 KB none Details
Sample document application/x-abiword Marc Maurer 2010-04-12 22:41 3.76 KB none Details
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 11785 depends on: Show dependency tree
Show dependency graph
Bug 11785 blocks:

Additional Comments:







View Bug Activity   |   Format For Printing   |   XML   |   Clone This Bug


Description:   Opened: 2008-10-09 16:25
The Write activity in OLPC XO sometimes shows strange characters instead of
Arabic characters. Forcing a re-render (like selecting the text and changing
the font) seems to get the correct rendering back.

This is not reproducible always - sometimes it works fine, and sometimes it
does not.

I have seen the exact same symptoms with other scripts as well (eg: Amharic).

------- Comment #1 From Sayamindu Dasgupta 2008-10-09 16:26:12 -------
Created an attachment (id=4685) [details]
Screenshot of garbled rendering

------- Comment #2 From msevior@physics.unimelb.edu.au 2008-11-03 04:44:55 -------
Could you please repeat this test with the DejaVu sans font? In my tests DejaVu
Serif does not contain glyphs for Arabic. The bug appears to be caused by
incorrect font substitution.


In any case please let me know if you can trigger the bug with the DejAVu Sans
font.

Thanks!

Martin

------- Comment #3 From Sayamindu Dasgupta 2010-03-22 23:02:00 -------
I finally got a chance to look into this deeply. Here's what I think is
happening. (All the methods I refer to are in
src/af/gr/xp/gr_CairoGraphics.cpp, as in Abiword trunk)

The font substitution is happening properly (eg: if the user selected font is
Deja Vu Sans, but the glyph is present in Mothanna, Mothanna does get selected
by GR_CairoGraphics::shape)

However, in GR_CairoGraphics::renderChars the rendering (on-screen drawing) is
done with the user selected font instead (to be exact, the previously selected
font). Since GR_CairoGraphics::renderChars handles GlyphIds instead of
characters, and since GlyphIds will differ from font to font (especially for
complex script fonts), the resultant output is garbage.

Some more investigation makes me believe that
GR_CairoGraphics::_adjustedPangoFont is to blame here. I simply comment out

        if (pFont == m_pAdjustedPangoFontSource &&
                m_iAdjustedPangoFontZoom == getZoomPercentage())
        {
                return m_pAdjustedPangoFont;
        }

and it seems to work fine both for trunk as well as the version of Abiword we
ship with the stable XO builds (the filename was different for the older
abiword).
I'm not at all familiar with the Abiword code and coding standards - so could
you possibly look into this ?

This affects all CTL languages and not just Arabic - I did most of the testing
with Bengali, which is my native language.

------- Comment #4 From Marc Maurer 2010-03-28 17:36:33 -------
Some of us needs to review this. Would be awesome to have it working in 2.8.3.

------- Comment #5 From Marc Maurer 2010-04-12 00:13:42 -------
I'll take this.

------- Comment #6 From Marc Maurer 2010-04-12 22:41:56 -------
Created an attachment (id=5241) [details]
Sample document

For future reference on how to reproduce this:

1. Load the attached document (it came from bug 6987)
2. At the very beginning of this document, insert the character "1"
3. Save the document, close it, and reopen it.

=> The document will look all garbled, similiar to the screenshot attached to
this report.

------- Comment #7 From Marc Maurer 2010-04-12 23:39:44 -------
Fixed in trunk, and will be backported to 2.8.4 soonish. Please test it.

The problem was indeed in GR_CairoGraphics::_adjustedPangoFont() and
_adjustedLayoutPangoFont(), but in a slightly different way than mentioned in
comment #3.

What was really going on is the following:

1. _adjustedPangoFont (GR_PangoFont * pFont, PangoFont * pf) is supposed to
return the correct PangoFont given A) the font of the textrun (pFont) that is
selected in the document, and B) the font (pf) that Pango substituted in its
place. Given that a substituted font pf is always returned by pango as a 12pt
font, we have to scale it to the proper size depending on the zoom. This
function will do that, and cache the result.

2. It is in this caching that lies the problem. If we create the sample
document as described in comment 6, trap the calls to _adjustedPangoFont(), and
print the name of the pFont and pf, we get for the first line of text:

Requesting adjusted font for "Loma", pango selected font is "DejaVu Sans 72"
Requesting adjusted font for "Loma", pango selected font is "Waree 72"
Requesting adjusted font for "Loma", pango selected font is "Waree 72"
Requesting adjusted font for "Loma", pango selected font is "Waree 72"

3. What we see here is that the first line of output is for the "1" character
in the document. The other 3 lines are for the 3 Thai textruns in the document.
Because of the first output line, the old font caching mechanism now cached for
font "Loma" at size X and zoom Y, the font "DejaVu Sans 72" at size X and zoom
Y. As soon as it needed to render the Thai textruns, the wrong cached font was
returned (the DejaVu one).

4. As an additional test, remove the "1" from the document, save it, and reopen
it. You can see that the output is correct now. Only "Waree 72" fonts are
substituted in the document now, which hides the caching bug.

=> The proper way of caching is the font is obviously NOT caching the pango
font belonging to "source" font at size X and zoom Y, but caching the pango
font belonging to the *replaced pango font* at size X and zoom Y.

First Last Prev Next    No search results available      Search page      Enter new bug