Issue 111054 - formatting borked for expanded text with Graphite fonts (spacing, line width)
Summary: formatting borked for expanded text with Graphite fonts (spacing, line width)
Status: CLOSED FIXED
Alias: None
Product: Writer
Classification: Application
Component: formatting (show other issues)
Version: OOo 3.2
Hardware: PC Windows, all
: P3 Trivial (vote)
Target Milestone: ---
Assignee: eric.savary
QA Contact: issues@sw
URL:
Keywords: oooqa, regression
: 111277 (view as issue list)
Depends on:
Blocks: 111272
  Show dependency tree
 
Reported: 2010-04-21 21:59 UTC by fallenguru
Modified: 2017-05-20 11:42 UTC (History)
5 users (show)

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


Attachments
sample file that exhibits the problem (excerpt) (31.57 KB, application/vnd.oasis.opendocument.text)
2010-04-21 22:00 UTC, fallenguru
no flags Details
that's how it should (used to) render (54.95 KB, application/pdf)
2010-04-21 22:01 UTC, fallenguru
no flags Details
that's how it renders in 3.2 (44.74 KB, application/pdf)
2010-04-21 22:02 UTC, fallenguru
no flags Details
Line breaking patch for expanded condensed graphite text (16.58 KB, patch)
2010-04-26 18:10 UTC, devel
no flags Details | Diff
Revised patch fixing justification regression, includes fix for issue 111272 (21.40 KB, patch)
2010-05-03 07:08 UTC, devel
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description fallenguru 2010-04-21 21:59:21 UTC
(Feel free to come up with a more descriptive title.)

A lot of my documents that were originally written using the 3.0 and 3.1 series
have totally broken formatting when opened in 3.2.
Specifically the line length seems to get incrementally shorter with every line
in a paragraph down to about the middle, then it gets longer again. So the shape
of the right border of each paragraph looks like this: <

The effect carries over when printing or exporting as PDF.

This doesn't happen with all documents but seems to be related to the Gentium
family of fonts and / or the fact that I like to use wider spacing (+1/2 point).

See attachments.
Comment 1 fallenguru 2010-04-21 22:00:44 UTC
Created attachment 69036 [details]
sample file that exhibits the problem (excerpt)
Comment 2 fallenguru 2010-04-21 22:01:54 UTC
Created attachment 69037 [details]
that's how it should (used to) render
Comment 3 fallenguru 2010-04-21 22:02:31 UTC
Created attachment 69038 [details]
that's how it renders in 3.2
Comment 4 Regina Henschel 2010-04-21 22:30:14 UTC
I can reproduce the error with a new document and the font "Gentium Book Basic"
in DEV300m76. It does not occur with other fonts, for example "Palatino
Linotype", "Garamond", or "Dejavu Serif".
Comment 5 eric.savary 2010-04-21 22:44:09 UTC
@Regina: Thank you for your quick analyze! :)

@HDU: a consequence of issue 89682 implementation?
Comment 6 fallenguru 2010-04-21 23:14:29 UTC
Some more testing:
Gentium / GentiumAlt - OK
Gentium Basic / Gentium Book Basic - FAIL

The only fundamental difference between these two fonts seems to be that the
latter do have Graphite tables while the former do not (as of yet). So I tried
another Graphite font:

Charis SIL - FAIL

Since a lot of "plain" TTF and OTF fonts (both formats) are fine that would
indicate there is either
- something wrong with SIL's Graphite enabled fonts or
- something wrong with 3.2's Graphite implementation.

Does anyone know which font the Graphite support was tested against?
Comment 7 fallenguru 2010-04-21 23:25:43 UTC
Setting

SAL_DISABLE_GRAPHITE=1

helps. Personally I can live without Granite but it's still an ugly workaround.
Comment 8 hdu@apache.org 2010-04-22 07:50:00 UTC
adjusted summary
Comment 9 devel 2010-04-22 13:12:33 UTC
It seems to be the Spacing expanded by 0.5pt (on the Position tab) which is
doing it. If Spacing is Normal it goes back to rendering correctly. To be
honest, I don't think I ever tested this combination. I will look into in more
detail, but it may take several days.

I notice that if the font is changed to Padauk, which is another Graphite font,
it does render sensibly. Padauk isn't a good font for German since it doesn't
have umlauts, but perhaps it is related to Graphite's line breaking algorithm,
which will depend on the rules in the font.
Comment 10 devel 2010-04-22 13:15:26 UTC
It seems to be the Spacing expanded by 0.5pt (on the Position tab) which is
doing it. If Spacing is Normal it goes back to rendering correctly. To be
honest, I don't think I ever tested this combination. I will look into in more
detail, but it may take several days.

I notice that if the font is changed to Padauk, which is another Graphite font,
it does render sensibly. Padauk isn't a good font for German since it doesn't
have umlauts, but perhaps it is related to Graphite's line breaking algorithm,
which will depend on the rules in the individual font.
Comment 11 hdu@apache.org 2010-04-22 14:08:45 UTC
@kstribley: thanks for looking into this! Indeed, text breaking for expanded or condensed spacing already 
caused enough trouble for other layout engines in OOo. The severity of this issue is reduced by the small 
percentage of documents using such non-zero horizontal extra-spacing.
Comment 12 devel 2010-04-26 18:10:58 UTC
Created attachment 69132 [details]
Line breaking patch for expanded condensed graphite text
Comment 13 devel 2010-04-26 18:24:44 UTC
The problem was in the GraphiteLayout::GetTextBreak method. It subtracted the
extra character spacing for all glyphs in a run before computing where the Line
Break point lay. If the number of characters being tested was much more than the
number that could fit, this resulted in line breaking occurring in a much
narrower width than it should have been.

Originally, I was using Graphite's LineFillSegment object to calculate the line
break point, however, this is not possible when extra spacing is being applied
per character. I've therefore decided to record the break weights from the
Graphite segment when it is first analyzed in the appendCluster method. These
can then be used to compute an appropriate break point even when there is extra
character spacing. 

The attached patch fixes the issue for me on Linux and I hope to test it some
more on Windows later in the week. It also includes a fix for incorrect
rendering of expanded/condensed Graphite text in the preview window of the
Character dialog (the expansion/condensation wasn't being applied).

PS: I think my previous comment about Padauk being OK was erroneous. Perhaps
fallback was confusing the issue.
Comment 14 hdu@apache.org 2010-04-27 08:21:20 UTC
Thanks! The change looks quite tricky... if it solves both text breaking and displaying non-default spaced 
text all is well.
FWIW, I had a similar problem with text breaking on the Aqua port in the method GetTextBreak() (in 
vcl/aqua/source/gdi/salatslayout.cxx) which uses native OSX text breaking methods to emulate the 
unique text breaking semantics expected by Writer and EditEngine. This was be solved by just adapting 
GetTextBreak(). At the root of the problem there is of course SW and EE having these very un-conventional 
expectations (issue 108684).
Comment 15 devel 2010-05-03 07:08:53 UTC
Created attachment 69248 [details]
Revised patch fixing justification regression, includes fix for issue 111272
Comment 16 devel 2010-05-03 07:59:58 UTC
I've noticed that if expanded text is used with Arabic, then Kashida's are
introduced for large expansions. This seems to affect both the Graphite code and
the ICU code on Linux. Is that actually correct? I don't know any Arabic, but if
I compare it with where they are inserted for justification they don't look to
be the same positions. @hdu are you able to comment on this?
Comment 17 hdu@apache.org 2010-05-03 10:35:07 UTC
> if expanded text is used with Arabic, then Kashida's are introduced for large expansions

Yes, for shaping engines that do not bother with topics such as justification OOo has a layer to emulate it 
on top of the non-justfied layout. This introduces kashidas for scripts that use that method for 
justification. Graphite does justification itself so the justification-emulation layer should become active.

The concept of expanded/condensed spacing in WE/EE itself is a bit dubious and for cursive scripts it 
IMHO does not make any sense at all. WriterEngine/EditEngine should then either disallow it or they 
should accumulate the expanded space into the locations suggested by normal justification for this script, 
i.e. into spaces or into the kashida positions.
Comment 18 hdu@apache.org 2010-05-03 10:37:18 UTC
correction: Graphite does justification itself so the justification-emulation layer should NOT become 
active.
I hope the issue tracker will allow to edit comments one day...
Comment 19 hdu@apache.org 2010-05-03 11:17:56 UTC
I split off issue 111336 for the problem I described above (with cursive scripts and non-zero spacing).
Comment 20 hdu@apache.org 2010-05-04 10:40:24 UTC
The patch looks good to me (for CWS graphite02), thanks!
@kstribley: should I hgpush+commit the latest patch as it is or do you prefer to commit it yourself?

CWS graphite02 should probably also disable the justification emulation layer (described in #desc18) for Graphite 
layouts if graphite prefers to do the justification itself. Due to Writer writer having unusual opinions on the division 
of responsibility between the code layers used for justification (issue 108684) this might become tricky though. 
Feel free to split off an issue for that topic.
Comment 21 hdu@apache.org 2010-05-06 06:10:53 UTC
Regarding the topic of the justification emulation layer I mentioned in #desc18 and #desc21: 
This can be disabled by overriding the AdjustLayout() method from class derived from 
SalLayout.

I saw that GraphiteLayout::AdjustLayout() already does that, but it mostly copied the code 
from the generic SalLayout justification emulation layer. So the kashidas noticed in #desc17 
come from GraphiteLayout::kashidaJustify() instead of the GenericSalLayout::KashidaJustify() 
which I suspected first. If graphite prefers to do the justification itself just forward the 
justification request in AdjustLayout() to e.g. gr::Segment::JustifiedSegment().
Comment 22 hdu@apache.org 2010-05-06 08:38:44 UTC
Applied the second patch into CWS graphite02.
Comment 23 hdu@apache.org 2010-05-12 14:47:17 UTC
@sba: please verify in CWS graphite02
Comment 24 hdu@apache.org 2010-05-19 12:59:44 UTC
*** Issue 111277 has been marked as a duplicate of this issue. ***
Comment 25 stefan.baltzer 2010-05-31 15:46:15 UTC
SBA->ES: Please take over, thx.
Comment 26 eric.savary 2010-06-07 14:11:33 UTC
Verified in CWS graphite02