Bug Hunting Session
Bug 104403 - Support multi-colored fonts using COLR/CPAL tables
Summary: Support multi-colored fonts using COLR/CPAL tables
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: graphics stack (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
: 115848 (view as bug list)
Depends on: HarfBuzz
Blocks: Font-Rendering
  Show dependency treegraph
 
Reported: 2016-12-05 06:09 UTC by Khaled Hosny
Modified: 2019-11-10 12:23 UTC (History)
14 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 2016-12-05 06:09:43 UTC
Description:
The latest version of the OpenType specification introduced few tables that allow for having multi-colored glyphs.

The simplest of them is COLR/CPAL (https://www.microsoft.com/typography/otspec/colr.htm, https://www.microsoft.com/typography/otspec/cpal.htm) which uses layers of normal glyphs and color palettes to assign colors to each.

It shouldn’s be hard to parse the tables in SalGraphics::DrawTextLayout() and draw each layer glyph with its assigned color. We might want to wait until HarfBuzz supports these fonts to avoid parsing the tables on our own.

This would allow supporting fonts like Amiri Quran Colored or several of the new Emoji fonts cross-platform (Windows 8.1+ already supports this format, though I don’t think we make use of that support).

Steps to Reproduce:
Try using Amiri Quran Colored font with Arabic text.

Actual Results:  
Text comes out using the foreground color.

Expected Results:
Text should use the colors defined in the font.


Reproducible: Always

User Profile Reset: 

Additional Info:


User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0
Comment 1 Volga 2016-12-05 10:02:49 UTC Comment hidden (obsolete)
Comment 2 Volga 2017-01-23 04:07:41 UTC Comment hidden (obsolete)
Comment 3 V Stuart Foote 2018-02-19 18:21:57 UTC
*** Bug 115848 has been marked as a duplicate of this bug. ***
Comment 4 Volga 2018-02-28 15:05:03 UTC Comment hidden (no-value)
Comment 5 Volga 2018-03-01 02:53:30 UTC Comment hidden (no-value)
Comment 6 Volga 2018-03-01 14:40:05 UTC
They has an issue for discussing the API, so we can track it to see the results.
https://github.com/harfbuzz/harfbuzz/issues/849
Comment 7 Volga 2018-03-08 01:30:15 UTC Comment hidden (no-value)
Comment 8 Volga 2018-03-10 02:34:29 UTC Comment hidden (obsolete)
Comment 9 Volga 2018-11-06 00:34:16 UTC
This feature is already available in HarfBuzz since 2.1.0.
Comment 10 Aleksandr Andreev 2019-04-06 19:32:36 UTC
What's the status with this? How difficult would it be to support this now that it is supported by HarfBuzz?
Comment 11 Khaled Hosny 2019-04-06 20:05:50 UTC
(In reply to Aleksandr Andreev from comment #10)
> What's the status with this? How difficult would it be to support this now
> that it is supported by HarfBuzz?

For screen rendering they should already supported on Linux if you have FreeType 2.10.x and Cairo 1.16.x, and should be supported on recent enough macOS systems (disdn’t test that, though). On Windows it would require calling the relevant DirectWrite APIs (https://docs.microsoft.com/en-us/windows/desktop/directwrite/color-fonts#using-color-fonts-with-directwrite-and-direct2d)

For PDF, we would need to call HarfBuzz to decompose the color glyph layers before writing them to the PDF, should be a couple of days work or so if someone is interested.