Bug 166079 - Handle OpenType font features properly at file format level
Summary: Handle OpenType font features properly at file format level
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Font-Rendering
  Show dependency treegraph
 
Reported: 2025-04-08 00:13 UTC by Khaled Hosny
Modified: 2025-04-23 14:05 UTC (History)
9 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Khaled Hosny 2025-04-08 00:13:48 UTC
Currently support for font features is handled by appending a font features string to the font name and parsing it during text layout. This has served us OK, but it is a hack and non-standard and I doubt any other application or tool that supports ODF handles it.

We should instead handle font features like other font attributes, e.g. color, and read it/write properly to the file format, possibly modelling it after CSS’s font-feature-settings (https://developer.mozilla.org/en-US/docs/Web/CSS/font-feature-settings). It can be a LibreOffice ODF extension at first, then proposed for standardization once it is ready.

This would also open the door for importing and exporting OpenType font features  settings from other file formats like DOCX (it should be worth checking how DOCX handles them so the solution that gets developed is not incompatible with it) and SVG.

There seems to have been a proposal for ODF, but I can’t seem to find the proposal text: https://issues.oasis-open.org/browse/OFFICE-3414

See also https://wiki.documentfoundation.org/Smart_font_optional_features_for_Graphite_and_OpenType_fonts
Comment 1 V Stuart Foote 2025-04-08 00:26:28 UTC
+1, overdue.
Comment 2 Iandol 2025-04-08 04:52:22 UTC
For Word, If I edit Normal style to add some OT features (oldstyle, proportional, stylistic set = 1, contextual alternative ON) the XML in styles.xml shows this:


<w:style w:type="paragraph" w:default="1" w:styleId="Normal">
<w:name w:val="Normal"/>
<w:qFormat/>
<w:rsid w:val="004868A2"/>
<w:rPr>
<w:rFonts w:ascii="Libertinus Serif" w:eastAsia="Libertinus Serif" w:hAnsi="Libertinus Serif" w:cs="Libertinus Serif"/>
<w14:numForm w14:val="oldStyle"/>
<w14:numSpacing w14:val="proportional"/>
<w14:stylisticSets><w14:styleSet w14:id="1"/></w14:stylisticSets><
w14:cntxtAlts/>
</w:rPr>
</w:style>


I then edited the direct font formatting to change proportional to tabular and oldstyle to lining, stylistic set to 2 and contextual alternative OFF and the document.xml text is wrapped like so:


<w:p w:rsidR="00692BE2" w:rsidRPr="004868A2" w:rsidRDefault="00692BE2" w:rsidP="004868A2"/>
<w:p w:rsidR="00692BE2" w:rsidRPr="004868A2" w:rsidRDefault="00692BE2" w:rsidP="004868A2">
<w:pPr><w:rPr>
<w14:numForm w14:val="lining"/>
<w14:numSpacing w14:val="tabular"/>
<w14:stylisticSets><w14:styleSet w14:id="2"/></w14:stylisticSets>
<w14:cntxtAlts w14:val="0"/>
</w:rPr></w:pPr>
<w:r w:rsidRPr="004868A2">
<w:rPr>
<w14:numForm w14:val="lining"/>
<w14:numSpacing w14:val="tabular"/>
<w14:stylisticSets><w14:styleSet w14:id="2"/></w14:stylisticSets>
<w14:cntxtAlts w14:val="0"/>
</w:rPr><w:t>Test</w:t></w:r><w:r w:rsidR="001A3266" w:rsidRPr="004868A2">
<w:rPr>
<w14:numForm w14:val="lining"/>
<w14:numSpacing w14:val="tabular"/>
<w14:stylisticSets><w14:styleSet w14:id="2"/></w14:stylisticSets>
<w14:cntxtAlts w14:val="0"/>
</w:rPr><w:t xml:space="preserve"> 012345</w:t></w:r></w:p>


The tags are the same in the styles.xml and intext direct formatting in documents.xml
Comment 3 Volga 2025-04-23 14:05:01 UTC
For SVG this would bring benefits to handle some properties like font-feature-settings and font-variant during import and export processes.