Bug 138475 - Asian and Complex font-size / font weight / font posture in Calc default styles are not the same as Western fonts
Summary: Asian and Complex font-size / font weight / font posture in Calc default styl...
Status: VERIFIED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.1.0.0.alpha1+
Hardware: All All
: medium trivial
Assignee: Kevin Suo
URL:
Whiteboard: target:7.3.0 target:7.2.3
Keywords:
Depends on:
Blocks:
 
Reported: 2020-11-25 03:47 UTC by Kevin Suo
Modified: 2022-01-23 10:22 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
pdf file showing the issue (144.19 KB, application/pdf)
2020-11-25 03:49 UTC, Kevin Suo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Suo 2020-11-25 03:47:36 UTC
Steps to Reproduce:
1. Copy paste "This is 汉字" in Calc.
2. Apply Heading, Heading 1 or Heading 2 style.

Current Result:
Heading: 24pt for Western fonts but 10pt for Asian.
Heading 1: 18pt for Western, still 10pt for Asian.
Heading 2: 12pt for Western, still 10pt for Asian.

Expected:
Asian font size should be the same as Western, otherwise the texts shown in the cells will look ugly.

Version 7.1
Comment 1 Kevin Suo 2020-11-25 03:48:19 UTC
I will try to change this, but could someone give me some code pointer where the default Calc template is located?
Comment 2 Kevin Suo 2020-11-25 03:49:47 UTC
Created attachment 167548 [details]
pdf file showing the issue
Comment 3 Ming Hua 2020-11-25 15:49:57 UTC
Confirmed, I was thinking of reporting the same thing.

I am by no means familiar with the code, but my cursory investigation seems to indicate that the default Calc styles are specified in core/sc/res/xml/styles.xml, which gets installed as $BASE_DIR/$LIBO_SHARE_FOLDER/calc/styles.xml, according to /core/sc/source/core/tool/stylehelper.cxx line #63:
https://opengrok.libreoffice.org/xref/core/sc/source/core/tool/stylehelper.cxx?r=a5b3211f#63

In addition to adding CJK properties for Asian text, you probably want to add CTL properties for complex layout text as well, see bug 114746 for some related discussion and example code changes.
Comment 4 Ming Hua 2020-12-24 16:33:35 UTC
(In reply to Ming Hua from comment #3)
> my cursory investigation seems
> to indicate that the default Calc styles are specified in
> core/sc/res/xml/styles.xml, which gets installed as
> $BASE_DIR/$LIBO_SHARE_FOLDER/calc/styles.xml
An attempt to modify $INSTALL_DIR\share\calc\styles.xml in my Windows installation, adding fo:font-size-asian and fo:font-weight-asian properties didn't work, though.
Comment 5 Kevin Suo 2021-10-31 13:13:11 UTC
(In reply to Ming Hua from comment #4)
According to Open Document Format for Office Applications (OpenDocument) Version 1.3. Part 3: OpenDocument Schema:

16.29.29 <style:text-properties>:

The <style:text-properties> element has the following attributes: ... fo:font-size 20.190, ... fo:font-weight 20.193, ... style:font-size-asian 20.284, style:font-size-complex 20.285, ... style:font-weight-asian 20.294, style:font-weight-complex 20.295...

So the correct attribute should be 
style:font-size-asian="18pt" style:font-size-complex="18pt"
Comment 6 Ming Hua 2021-10-31 16:43:04 UTC
(In reply to Kevin Suo from comment #5)
> (In reply to Ming Hua from comment #4)
> According to Open Document Format for Office Applications (OpenDocument)
> Version 1.3. Part 3: OpenDocument Schema:
> 
> 16.29.29 <style:text-properties>:
> 
> The <style:text-properties> element has the following attributes: ...
> fo:font-size 20.190, ... fo:font-weight 20.193, ... style:font-size-asian
> 20.284, style:font-size-complex 20.285, ... style:font-weight-asian 20.294,
> style:font-weight-complex 20.295...
> 
> So the correct attribute should be 
> style:font-size-asian="18pt" style:font-size-complex="18pt"
Ah, silly me.  Even bug 114746 I mentioned in comment #3 have the correct attribute names "style:font-size-asian" and "style:font-weight-asian".

However, directly editing $INSTALL_DIR\share\calc\styles.xml and changing the line
<style:text-properties fo:color="#000000" fo:font-size="24pt" fo:font-style="normal" fo:font-weight="bold"/>
to
<style:text-properties fo:color="#000000" fo:font-size="24pt" fo:font-style="normal" fo:font-weight="bold" style:font-size-asian="24pt" style:font-weight-asian="bold" style:font-size-complex="24pt" style:font-weight-complex="bold"/>
doesn't seem to work either.
Comment 7 Kevin Suo 2021-11-01 01:29:24 UTC
Adding those attributes in source and rebuild does not work either. Need some coding.
Comment 8 Kevin Suo 2021-11-01 03:54:14 UTC
I guess this is due to orcus's handling of the styles:
https://gitlab.com/orcus/orcus/-/blob/master/src/liborcus/odf_styles_context.cpp
Comment 9 Kevin Suo 2021-11-01 04:04:00 UTC
Jaskaran Singh: I see you have worked on commit 2aea6d519ff7e487af0b2a39d78e00c0227799af. Would you please advice whether this bug is due to the missing handling of the asian and complex style attributes in Orcus?
Comment 10 Kevin Suo 2021-11-01 05:19:49 UTC
Ok I see:
https://opengrok.libreoffice.org/xref/core/sc/source/filter/orcus/interface.cxx?r=20f064c1#1359

Here the ATTR_CJK_* and ATTR_CTL_* attributes should also be applied to the itemset.
Comment 11 Kevin Suo 2021-11-01 06:27:02 UTC
@Ming Hua: would you please help to test with this patch:
https://gerrit.libreoffice.org/c/core/+/124536
Comment 12 Ming Hua 2021-11-01 06:41:04 UTC
(In reply to Kevin Suo from comment #11)
> @Ming Hua: would you please help to test with this patch:
> https://gerrit.libreoffice.org/c/core/+/124536
Sorry I don't have an environment to build LO.

If you could provide a built Windows version, I'd be happy to test.
Comment 13 Commit Notification 2021-11-01 12:45:29 UTC
Kevin Suo committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/3b977328dfbe613d925dc52c22e36b7e15a34ada

tdf#138475: also set font size/weight/posture for CJK/CTL languages...

It will be available in 7.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 14 Kevin Suo 2021-11-01 13:07:14 UTC
Fixed on master, backport to 7.2 branch under review in:
https://gerrit.libreoffice.org/c/core/+/124472
Comment 15 Commit Notification 2021-11-01 16:21:52 UTC
Kevin Suo committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/836e37bac767ce6eea4b0e0c9342976e8238cc46

tdf#138475: also set font size/weight/posture for CJK/CTL languages...

It will be available in 7.2.3.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 16 Kevin Suo 2021-11-01 16:32:46 UTC
(In reply to Ming Hua from comment #12)

You can use a daily-build on master branch or 7.2 branch:
https://dev-builds.libreoffice.org/daily/master/Win-x86_64@tb77-TDF/current/

You should wait until there is a build for Nov 2 or later.
Comment 17 Ming Hua 2021-11-02 11:32:58 UTC
(In reply to Kevin Suo from comment #16)
> You can use a daily-build on master branch or 7.2 branch:
> https://dev-builds.libreoffice.org/daily/master/Win-x86_64@tb77-TDF/current/
> 
> You should wait until there is a build for Nov 2 or later.
Sure, I'm aware of the daily-builds server.  I was just saying that there is no practical way for me to test not-yet-committed patches on Gerrit.

Although in this case, since the patch is already backported to 7.2 branch, I think I'll wait a few more days and test 7.2.3 RC1 instead.  Downloading from dev-builds.libreoffice.org is rather slow for me (a ~300MB MSI installer usually takes about 2 hours when connection is good, which means after midnight).
Comment 18 Kevin Suo 2021-11-03 12:07:59 UTC
(In reply to Ming Hua from comment #17)
> Downloading from dev-builds.libreoffice.org is rather slow for me

Due to the serious Internet connection issues in China, I have just now prepare a Python script to mirror the dev-builds to my own server. The downloading is currently in process, you may check some hours later (files marked as "in-process" in its extension names are being downloaded in process):

https://go.suokunlong.cn:88/dl/libreoffice/daily/

My server is located in China, so it is slow to download those files from the dev-builds server on my server, but your download speed from my server will then be quick I suppose.
Comment 19 Ming Hua 2021-11-04 09:06:27 UTC
(In reply to Kevin Suo from comment #18)
> https://go.suokunlong.cn:88/dl/libreoffice/daily/
Thank you for providing this mirror.  Now my download is instantaneous.

Also confirm fixed with:
Version: 7.3.0.0.alpha1+ (x64) / LibreOffice Community
Build ID: c7500945fc5d5bd2130a2d38be0bd4b15445cd90
CPU threads: 2; OS: Windows 10.0 Build 19043; UI render: default; VCL: win
Locale: zh-CN (zh_CN); UI: zh-CN
Calc: threaded

In newly created spreadsheet, Chinese text are now the same font size/weight as the western text when applying predefined styles.