Issue 85422 - Text-to-text alignment Middle does not lay Asian characters in the middle.
Summary: Text-to-text alignment Middle does not lay Asian characters in the middle.
Status: CONFIRMED
Alias: None
Product: Writer
Classification: Application
Component: formatting (show other issues)
Version: OOo 2.3
Hardware: All Windows, all
: P3 Trivial with 1 vote (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
: 85430 98209 (view as issue list)
Depends on: 85991
Blocks: 85430
  Show dependency tree
 
Reported: 2008-01-21 06:35 UTC by tora3
Modified: 2017-05-20 11:15 UTC (History)
6 users (show)

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


Attachments
A sample bugdoc (10.33 KB, application/vnd.oasis.opendocument.text)
2008-01-21 06:41 UTC, tora3
no flags Details
Snapshots with 2.3.0 plus patch, 2.3.0, and 680m242 (237.22 KB, application/pdf)
2008-01-21 06:43 UTC, tora3
no flags Details
An experimental patch for the module vcl (1.87 KB, patch)
2008-01-21 06:51 UTC, tora3
no flags Details | Diff
Patch for both issue 85422 and issue 85430 (25.11 KB, patch)
2008-01-25 08:58 UTC, tora3
no flags Details | Diff
Patch revison 2008-02-11, which requires i85991-2008-02-11.patch (2.26 KB, patch)
2008-02-11 06:17 UTC, tora3
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description tora3 2008-01-21 06:35:55 UTC
Phenomenon: 
 With OpenOffice.org 2.3 Asian characters in various font size are not laid 
 in the middle of line under Text-to-text alignment Middle in vertical writing. 
 Additionally, Text-to-text alignment Top or Bottom does not work appropriately. 

 For details, see a snapshot.

Quick investigation:
 When the module vcl provides information on geometrics of a glyph, the vcl 
 seems to return an artificial leading for Asian glyphs, which is calculated 
 with an equation like "0.30 * (Ascent + Decent)." 

   vcl/win/source/gdi/salgdi3.cxx
   void WinSalGraphics::GetFontMetric( ImplFontMetricData* pMetric )
   {
        ...
        // #110641# external leading for Asian fonts.
        // The factor 0.3 has been confirmed with experiments.
        long nCJKExtLeading = static_cast<long>(0.30 * (pMetric->mnAscent +
pMetric->mnDescent));
        nCJKExtLeading -= pMetric->mnExtLeading;
        pMetric->mnExtLeading = (nCJKExtLeading > 0) ? nCJKExtLeading : 0;

   The following source files also have the similar code fragments:
     vcl/aqua/source/gdi/salgdi.cxx
     vcl/source/glyphs/gcach_ftyp.cxx

Quick experiment:
 Applying a patch to some methods in the module vcl in order to cancel the 
 artificial leading, Writer becomes to lay Asian characters in an appropriate way. 

 For details, see an experimental patch for the module vcl.

 The patch, however, has a side effect. Distances between lines become smaller 
 than before applying the patch. But, it could be said that having no artificial 
 leading is better than having such a somewhat unexpected leading because the 
 amount of leading is designed by font designers. 

Solution:
 Further discussion might be needed to have better specifications and
implementation.
Comment 1 tora3 2008-01-21 06:41:47 UTC
Created attachment 51033 [details]
A sample bugdoc
Comment 2 tora3 2008-01-21 06:43:44 UTC
Created attachment 51034 [details]
Snapshots with 2.3.0 plus patch, 2.3.0, and 680m242
Comment 3 tora3 2008-01-21 06:51:33 UTC
Created attachment 51037 [details]
An experimental patch for the module vcl
Comment 4 frank.meies 2008-01-21 13:36:09 UTC
fme->tora: Thank you for your patch. I think this needs some more work for two
reasons:

1. This patch also sets the leading values for non-Asian text to 0 and
2. For Asian text, the changed leading values would result in layout changes for
existing documents.

Please discuss this with the vcl team. 
Comment 5 hdu@apache.org 2008-01-21 16:11:26 UTC
The magic with the factor 0.3 was introduced for issue #110641# with
http://gsl.openoffice.org/source/browse/gsl/vcl/win/source/gdi/salgdi3.cxx?
r1=1.47.14.2&r2=1.47.14.5
I agree that the font's metrics should always be preferred, so it was implemented like this originally. 
But legacy apps obviously used the 30% heuristic and CJK-fonts were designed for these mainstream 
apps...

Anyway, as far as I know nothing in VCL changed for top-/bottom-alignment between OOG680 and 
SRC680_m242. @FME: weren't some grid-layout changes in SW in this timeframe?

That the small latin characters in the bugdoc seem to move downwards come from the fact, that top-
alignment means alignment of the "logical top" as opposed to "ink-top". Do any other productivity 
suites use the other method?
Comment 6 frank.meies 2008-01-22 08:03:46 UTC
@HDU: [...] weren't some grid-layout changes in SW in this timeframe? [...] No.

@Tora: What about taking the external leading into consideration while
calculating the line height, but ignoring the external leading for the vertical
alignment of (Asian) text portions?
Comment 7 tora3 2008-01-22 08:33:41 UTC
@fme: That is a good idea. So, how about the following approach?

  1. Determine the maximum value of leading within a line. 
  2. The height of line will be changed from ascent+decent+leading to 
     only ascent+decent. The maximum value of leading will be kept separately.
  3. At the very end of process for calculating a position of line, the 
     separately kept maximum value of leading will be inserted after most 
     of the calculations for text layout is accomplished. 
Comment 8 frank.meies 2008-01-22 08:58:17 UTC
fme->tora: The important point is that the line size is *not* allowed to change
because of layout compatibility. So the line size calculation may not change!
But the alignment calculation of the text portions can be adjusted. Please check
if this is feasible.

Comment 9 tora3 2008-01-25 08:52:41 UTC
tora->fme: I see. You have a point. 

Here is an experimental patch that I have created following your suggestion. 
In short, the patch is designed in the following way:

 1. Adds GetLeading() and similar method besides existing Height() and 
    GetAscent() in the class SwLinePortion and some relevant classes.

 2. Keeps the value of external leading in an object instance that holds: 
     * line height (= external leading + ascent + descent)
     * its ascent  (= external leading + ascent)

 3. In a method in which the position of base line will be adjusted with 
    the amount of line height and its ascent based on a type of alignment, 
    the value of external leading will be also taken into consideration. 

Since the patch is created during efforts for the issue 85430 that depends 
on this issue, the patch includes code fragments for both issues. 
Although I do try to work for them separately, merging two separated 
patches that are closely related each other has a risk of conflicts. 

Please use a shell command like this for your evaluation. 
build debug=1 'envcflagscxx="-DTORA_PATCH_ADJUSTING_RUBY_LINE_85430 -DTORA_DEBUG
-DTORA_PATCH_ALIGNMENT_MIDDLE_85422"'

tora->hdu: Thank you for your interests. The value of magic, 0.30, might 
be needed further discussion in the near future. Many Japanese word processors 
are capable to have a leading between lines from 0.5, 1, 1.5, 2, and so on. 
The value 0.5 means half a size of ordinal line height! 

FYI. The patch does not include any code for vcl, but solely sw.
Comment 10 tora3 2008-01-25 08:58:50 UTC
Created attachment 51150 [details]
Patch for both issue 85422 and issue 85430
Comment 11 michael.ruess 2008-01-28 12:55:20 UTC
Reassigned to SBA.
Comment 12 frank.meies 2008-01-30 14:06:51 UTC
fme->tora: Thank you for your patch. I'll have a look...
Comment 13 tora3 2008-01-31 02:31:53 UTC
tora->fme: Thank you for your consideration.

The patch 85422_Alinment_Middle_and_85430_Position_of_Ruby_Text.patch is a little 
bit obsolete. I have worked on the another issue 85430 and have also refined code 
fragments for this issue. I am submitting the latest patch next week, which would 
successfully separate code fragments from another issue 85430. 
Comment 14 tora3 2008-02-11 06:17:05 UTC
Created attachment 51456 [details]
Patch revison 2008-02-11, which requires i85991-2008-02-11.patch
Comment 15 tora3 2008-02-11 06:31:44 UTC
tora->fme: Here is the latest one.

 Patch i85422-2008-02-11.patch
  - tries to solve this issue.
  - requires i85991-2008-02-11.patch from the issue 85991.
  - does not include any code fragment for the issue 85430. 
Comment 16 frank.meies 2008-03-01 08:06:24 UTC
fme->tora: I created a cws (fmepatches02) for this issue.
Comment 17 tora3 2008-03-03 12:29:36 UTC
*** Issue 85430 has been marked as a duplicate of this issue. ***
Comment 18 frank.meies 2008-04-08 09:42:16 UTC
fme->tora: Is your work on this finished? Did you make sure that this does not
interfere with pflin's new grid implementation? If so, please make sure to have
your patch based on a recent DEV300 version and send this issue back to be, I'll
review issue 85991 and issue 85422 together and integrate them.
Comment 19 tora3 2008-04-08 10:44:30 UTC
tora->fme: I have started working on this and related issues with DEV300_m6. 
The patch file attached in February was based on OOo 2.3.0. A new, up-to-date 
patch that might cover issue 85991 and issue 85422 would be available soon. 
Comment 20 tora3 2008-05-01 00:46:26 UTC
tora->fme: I am submitting a patch to BEA300_m1 in a few days. 
Comment 21 tora3 2008-05-06 02:02:11 UTC
tora->fme: Thank you for waiting. A patch has been submitted to the issue 85991.
Comment 22 eric.savary 2009-01-23 14:33:33 UTC
*** Issue 98209 has been marked as a duplicate of this issue. ***
Comment 23 Rob Weir 2013-03-11 15:01:57 UTC
I'm adding this comment to all open issues with Issue Type == PATCH.  We have 220 such issues, many of them quite old.  I apologize for that.  

We need your help in prioritizing which patches should be integrated into our next release, Apache OpenOffice 4.0.

If you have submitted a patch and think it is applicable for AOO 4.0, please respond with a comment to let us know.

On the other hand, if the patch is no longer relevant, please let us know that as well.

If you have any general questions or want to discuss this further, please send a note to our dev mailing list:  dev@openoffice.apache.org

Thanks!

-Rob
Comment 24 Marcus 2017-05-20 11:15:45 UTC
Reset assigne to the default "issues@openoffice.apache.org".