Bug 166627 - Emdedding fonts ignores fonts in header
Summary: Emdedding fonts ignores fonts in header
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
24.8.0.0 alpha0+
Hardware: All All
: medium normal
Assignee: Mike Kaganski
URL:
Whiteboard: target:25.8.0
Keywords: bibisected, bisected, regression
Depends on:
Blocks:
 
Reported: 2025-05-18 18:08 UTC by win
Modified: 2025-05-27 16:11 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
File with font in header only, embedded font missing. Bloated with unneeded font. (11.89 MB, application/vnd.oasis.opendocument.text)
2025-05-18 18:09 UTC, win
Details
File with font in body, font is correctly embedded. Additional unnecessary font also included. (11.96 MB, application/vnd.oasis.opendocument.text)
2025-05-18 18:10 UTC, win
Details
Second font in body not being embedded. (84.38 KB, application/vnd.oasis.opendocument.text)
2025-05-27 16:00 UTC, win
Details

Note You need to log in before you can comment on or make changes to this bug.
Description win 2025-05-18 18:08:09 UTC
Description:
Enabling "font embedding" with "only used fonts" works, if the used fonts appear in the main document body (see use_in_body.odt).
It does not work, if the fonts only appear in the header of footer. In this case, these fonts are not included in the file. (see use_in_header_only.odt).
Additionally, the files are immensely bloated due to the inclusion of the font "Fonts\Font_NSimSun_1.ttf" which is a Chinese font not included in the document at all.

Steps to Reproduce:
1. create a file with a non-standard font in the header
2. enable "embedding fonts" in document settings
3. safe file. re-open on device without the specified font (or unzip the *.odt and check the folder "Fonts".

Actual Results:
Font if used only in header is not embedded.

Expected Results:
Font should be embedded, so the file is displayed correctly on other systems.


Reproducible: Always


User Profile Reset: Yes

Additional Info:
Version: 25.2.2.2 (X86_64) / LibreOffice Community
Build ID: 7370d4be9e3cf6031a51beef54ff3bda878e3fac
CPU threads: 8; OS: Windows 10 X86_64 (10.0 build 19045); UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: threaded
Comment 1 win 2025-05-18 18:09:45 UTC
Created attachment 200851 [details]
File with font in header only, embedded font missing. Bloated with unneeded font.
Comment 2 win 2025-05-18 18:10:44 UTC
Created attachment 200853 [details]
File with font in body, font is correctly embedded. Additional unnecessary font also included.
Comment 3 win 2025-05-18 20:13:10 UTC
I repeated the procedure on another computer, where it behaved flawlessly and as expected.

Version: 7.5.1.2 (X86_64) / LibreOffice Community
Build ID: fcbaee479e84c6cd81291587d2ee68cba099e129
CPU threads: 8; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: CL threaded
Comment 4 Saburo 2025-05-22 08:16:59 UTC
I confirmed. and bisected
Version: 24.8.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: 69ed893087f89d176a5ec4b263ce8d75774be72b
CPU threads: 4; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: ja-JP (ja_JP); UI: ja-JP
Calc: CL threaded

author	Mike Kaganski
commit 69ed893087f89d176a5ec4b263ce8d75774be72b

tdf#160253: fix list identifier export decision code

> Additionally, the files are immensely bloated due to the inclusion of the font
> "Fonts\Font_NSimSun_1.ttf" which is a Chinese font not included in the document at all.
please try uncheck asian font.
Comment 5 Mike Kaganski 2025-05-23 08:55:03 UTC
https://gerrit.libreoffice.org/c/core/+/185704
Comment 6 Mike Kaganski 2025-05-23 09:26:33 UTC
(In reply to win from comment #0)
> Additionally, the files are immensely bloated due to the inclusion of the
> font "Fonts\Font_NSimSun_1.ttf" which is a Chinese font not included in the
> document at all.

The inclusion of NSimSun is correct, because it *is used* in your files - it is set as Asian font in the *used* styles. The bug was that it wasn't included previously, that was bug 155486, and its essence was that when the font didn't specify exact matches for "regular"/"bold"/"italic"/"bold italic" variants (which is fine, and LibreOffice can use that font, and correctly synthetize the variants), then embedding failed. That was fixed in 7.6. As Saburo suggested, the proper procedure is to exclude Asian fonts, if you don't need them.
Comment 7 Commit Notification 2025-05-23 20:49:11 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/e61a179b4ff8ce2072c3c0780628eb38c7a43529

tdf#166627: embed fonts everywhere we emit font data

It will be available in 25.8.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 8 Commit Notification 2025-05-23 21:59:20 UTC
Mike Kaganski committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/8ebe1e51ea9be20dd3e2279359ca0bebc9beb05c

Related: tdf#166627 Write font-face-src for each mention of embedded font

It will be available in 25.8.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 9 win 2025-05-27 15:59:09 UTC
Thanks for looking into the issue.
Using the latest daily build (25.8.0.0.alpha1) on Windows: 
I confirm unchecking "Embed Asian fonts" solved the unnecessary inclusion of the Asian font .
The problem with fonts occuring only in the header not being embedded persists. I now observed that from the two fonts in the body, only the second font is included (see use_in_body_25.8.0.0.a1.odt).
Comment 10 win 2025-05-27 16:00:45 UTC
Created attachment 200978 [details]
Second font in body not being embedded.

I now observed that from the two fonts in the body, only the second font is included (see use_in_body_25.8.0.0.a1.odt).
Comment 11 Mike Kaganski 2025-05-27 16:11:34 UTC
(In reply to win from comment #9)
> Using the latest daily build (25.8.0.0.alpha1) on Windows: 
> I confirm unchecking "Embed Asian fonts" solved the unnecessary inclusion of
> the Asian font .

This was not the issue, and this was working always; confirming this fact does not mean the actual issue is solved. So given that you write later:

> The problem with fonts occuring only in the header not being embedded
> persists.

you should not mark this "VERIFIED".

However, you do not use the "latest" daily. Your version (that you used for authoring attachment 200978 [details]) is marked 3158b14e0b26875300a8098bc117a5e69b76f48f (and its moment is 2025-05-23 06:10:34 UTC+2, i.e. early morning of May 23rd), while the fixing commit e61a179b4ff8ce2072c3c0780628eb38c7a43529 was merged on 2025-05-23 22:48:56 UTC+2 (i.e., that same day, but in evening). So you were nit testing the fix. Please re-test.