Bug 112805 - Support for "size" (optical size) OpenType table
Summary: Support for "size" (optical size) OpenType table
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
5.4.1.2 release
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Font-Rendering
  Show dependency treegraph
 
Reported: 2017-10-01 21:46 UTC by RGB
Modified: 2023-02-04 07:49 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Character properties for Coelacanth font (46.57 KB, image/png)
2017-10-01 21:46 UTC, RGB
Details

Note You need to log in before you can comment on or make changes to this bug.
Description RGB 2017-10-01 21:46:19 UTC
Created attachment 136670 [details]
Character properties for Coelacanth font

There are fonts like Latin Modern(1) or the still in development Coelacanth(2) that offers "optical sizes"(3): variants of the font designed to be used for different point sizes (broader, less detailed for small point sizes, taller and with higher contrast for big headings). 

This feature is governed by the "size" OpenType table. Systems like XeTeX automatically pick the right font file to be used on the appropriate size, but it seems that LibreOffice gets confused by that table: not only it do not switch between variants, it's not even possible to select which variant is being used as you can see on the attached screenshot. In fact Coelacanth consist of 37 font files tied together by the "size" OT feature, but LibO only offers a small and rather arbitrary selection.

------
(1) http://www.gust.org.pl/projects/e-foundry/latin-modern/download
(2) https://github.com/Fuzzypeg/Coelacanth
(3) https://en.wikipedia.org/wiki/Font#Optical_size
Comment 1 Buovjaga 2017-11-02 17:26:08 UTC
Sounds relevant -> NEW
Comment 3 Volga 2018-02-19 17:43:29 UTC
Hi Khaled, 

What do you think about that?
Comment 4 ⁨خالد حسني⁩ 2018-02-19 18:29:15 UTC
(In reply to Volga from comment #3)
> Hi Khaled, 
> 
> What do you think about that?

Patches are welcome.
Comment 5 Volga 2018-06-27 02:44:38 UTC
This can be activated via Font Size parameter in Character dialog.
Comment 6 RGB 2018-06-27 08:35:28 UTC
(In reply to Volga from comment #5)
> This can be activated via Font Size parameter in Character dialog.

No, it cannot be activated there. If on Writer I set some text on Latin Modern at 6pts and zoom in to 600% and then another text on Latin Modern but at 12pts and zoom in to 300% I get the same visual effect, while if I do that on XeTeX the result is completely different, as you can see on this screenshot

https://elpinguinotolkiano.files.wordpress.com/2015/12/lm-1.png

(to be precise, the screenshot was done with text on 10pts zoomed at 400% -top- and 5pts zoomed at 800% -bottom- but the idea is the same, and after all Writer does not allow 5pts text)

In the case of Latin Modern, Writer seems to always use the shape designed for 10pts, no matter which font size is selected.
Comment 7 Volga 2018-06-28 14:24:01 UTC
So LibreOffice should add a function to handle "size" feature via font size option.
Comment 8 LibreTraining 2018-06-29 17:29:33 UTC
(In reply to Volga from comment #7)
> So LibreOffice should add a function to handle "size" feature via font size
> option.

No. When the "size" feature is enabled the font substitution should happen automatically based on the font size selected.
Each font has a range of sizes for which it should be used.

Coelacanth font family for example: 

Coelacanth has Optical Size features

Pearl
Design Size: 5.0
Range: 4.0 – 5.5

Subcapt
Design Size: 6.0
Range: 5.6 – 6.9

Caption
Design Size: 9.0
Range: 7.0 – 10.9

Regular
Design Size: 14.0
Range: 11.0 – 17.2

Subhd
Design Size: 24.0
Range: 17.3 – 32.9

Display
Design Size: 60.0
Range: 33.0 – 72.0


The actual font file used depends on the size the user selects.
If the user select 12pts as the size, the Regular font file will be used.
If the user select 18pts as the size, the Subhd font file will be used.
If the user select 48pts as the size, the Display font file will be used.

Apparently Harfbuzz does have this feature, but I did not see it anywhere in Pango the text rendering engine docs.


======
(In reply to RGB from comment #0)
> ... 
> This feature is governed by the "size" OpenType table. Systems like XeTeX
> automatically pick the right font file to be used on the appropriate size,
> but it seems that LibreOffice gets confused by that table: not only it do
> not switch between variants, it's not even possible to select which variant
> is being used as you can see on the attached screenshot. In fact Coelacanth
> consist of 37 font files tied together by the "size" OT feature, but LibO
> only offers a small and rather arbitrary selection.
> 

This inability to properly select the different font weights in a font family is a known problem.
That is why there is a "small and rather arbitrary selection" of the fonts installed.
See:
Bug 69254 - Correct handling of font families (weight, style, stretches) on Mac 
https://bugs.documentfoundation.org/show_bug.cgi?id=69254
Bug 98596 - Correct handling of font families (weight, style, stretches) on Linux
https://bugs.documentfoundation.org/show_bug.cgi?id=98596

Because of that problem it is doubtful this feature can be implemented.
That problem would have to be solved first.

For example in Coelacanth there are multiple weights for each optical size.
Which weight would be used would be random/broken like any other font family.
The same problem with most SemiBold fonts, even the ones included with LibreOffice.

Until LibreOffice can fix the font families problems, this feature has no chance.