Skip to content

Fix BL-15558 preserve bloompub font simulation#7644

Merged
andrew-polk merged 1 commit intoVersion6.3from
BL-15558FixFontEmbedding
Feb 5, 2026
Merged

Fix BL-15558 preserve bloompub font simulation#7644
andrew-polk merged 1 commit intoVersion6.3from
BL-15558FixFontEmbedding

Conversation

@hatton
Copy link
Member

@hatton hatton commented Jan 31, 2026

Also, give the user a chance to read notes like ones about font embedding.


This change is Reviewable


Open with Devin

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View issue and 5 additional flags in Devin Review.

Open in Devin Review

@hatton hatton force-pushed the BL-15558FixFontEmbedding branch from 087af99 to 76fe486 Compare January 31, 2026 23:39
@hatton hatton force-pushed the BL-15558FixFontEmbedding branch from 76fe486 to cb97b21 Compare February 1, 2026 00:01
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View issue and 8 additional flags in Devin Review.

Open in Devin Review

@hatton hatton force-pushed the BL-15558FixFontEmbedding branch 2 times, most recently from 41a1936 to aebe807 Compare February 2, 2026 18:12
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View issue and 8 additional flags in Devin Review.

Open in Devin Review

@hatton hatton force-pushed the BL-15558FixFontEmbedding branch from aebe807 to f0c394b Compare February 3, 2026 00:21
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

View issue and 8 additional flags in Devin Review.

Open in Devin Review

@hatton hatton force-pushed the BL-15558FixFontEmbedding branch from f0c394b to 7dd1877 Compare February 3, 2026 21:12
Copy link
Contributor

@JohnThomson JohnThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JohnThomson reviewed 4 files and all commit messages, and made 3 comments.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @hatton).


a discussion (no related file):
Already a big improvement. I think it could go as-is, but I'll let you consider a couple of suggestions.


src/BloomBrowserUI/publish/commonPublish/PublishProgressDialog.tsx line 140 at r6 (raw file):

                        if (progressEvent.progressKind === "Note") {
                            setInterestingMessageEncountered(true);
                        }

Sort of messy. How about
case "Warning":
setErrorEncountered(true);
// fall-through
case "Note":
setInterestingMessageEncountered(true);
// fall-through
case "Progress":


src/BloomExe/Publish/Epub/EpubMaker.cs line 3005 at r6 (raw file):

            // missing styles, matching what happens in Bloom's editor (See BL-15558).
            if (string.IsNullOrEmpty(group.Normal))
                return;

A few fonts exist only in Italic versions (AI noted 'Baron') or only in Bold (Google Fonts Alfa Slab One). Presumably the browser will attempt to synthesize normal from italic or bold if it must? Does that mean we need to include the group.Italic or group.Bold paths (with the appropriate weight/style values) if those are all that exist? (Might unfortunately complicate what you're doing with normalFacesAdded...I'm not sure).

Copy link
Contributor

@andrew-polk andrew-polk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrew-polk reviewed 3 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @hatton).


src/BloomBrowserUI/publish/commonPublish/PublishProgressDialog.tsx line 128 at r6 (raw file):

            const html = `<span class='${progressEvent.progressKind}'>${e.message}</span><br/>`;
            if (e.id == "message") {
                switch (progressEvent.progressKind) {

I think this is clearer:

                switch (progressEvent.progressKind) {
                    case "Error":
                    case "Warning":
                        setErrorEncountered(true);
                    // deliberately fall through
                    case "Note":
                        setInterestingMessageEncountered(true);
                    // deliberately fall through
                    case "Progress":
                        setAccumulatedMessages(
                            (oldMessages) => oldMessages + html,
                        );
                        break;
                    case "Instruction":
                        setInstructionMessage(e.message);
                }

src/BloomExe/Publish/Epub/EpubMaker.cs line 3001 at r6 (raw file):

            }

            // Step 4: no exact face. Don't fake a bold/italic face by pointing at some other file.

I think this is step 3, not 4.
Note that we refer to it above. So that comment should also be changed to "3".

Copy link
Contributor

@andrew-polk andrew-polk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrew-polk reviewed 1 file.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @hatton).

@hatton hatton force-pushed the BL-15558FixFontEmbedding branch from 7dd1877 to cdaecb5 Compare February 3, 2026 23:51
@hatton hatton marked this pull request as ready for review February 3, 2026 23:51
Copilot AI review requested due to automatic review settings February 3, 2026 23:51
Copy link
Member Author

@hatton hatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hatton made 5 comments.
Reviewable status: 2 of 4 files reviewed, 5 unresolved discussions (waiting on @andrew-polk and @JohnThomson).


a discussion (no related file):

Previously, JohnThomson (John Thomson) wrote…

Already a big improvement. I think it could go as-is, but I'll let you consider a couple of suggestions.

Done. I'd actually rather reviews just merge though rather than get into polishing. Making things a little clearer, when no human will probably ever read this, isn't really worth the time it takes to write up and change.


src/BloomBrowserUI/publish/commonPublish/PublishProgressDialog.tsx line 128 at r6 (raw file):

Previously, andrew-polk wrote…

I think this is clearer:

                switch (progressEvent.progressKind) {
                    case "Error":
                    case "Warning":
                        setErrorEncountered(true);
                    // deliberately fall through
                    case "Note":
                        setInterestingMessageEncountered(true);
                    // deliberately fall through
                    case "Progress":
                        setAccumulatedMessages(
                            (oldMessages) => oldMessages + html,
                        );
                        break;
                    case "Instruction":
                        setInstructionMessage(e.message);
                }

Done


src/BloomBrowserUI/publish/commonPublish/PublishProgressDialog.tsx line 140 at r6 (raw file):

Previously, JohnThomson (John Thomson) wrote…

Sort of messy. How about
case "Warning":
setErrorEncountered(true);
// fall-through
case "Note":
setInterestingMessageEncountered(true);
// fall-through
case "Progress":

went with Andrews. Sigh this is a waste of time.


src/BloomExe/Publish/Epub/EpubMaker.cs line 3001 at r6 (raw file):

Previously, andrew-polk wrote…

I think this is step 3, not 4.
Note that we refer to it above. So that comment should also be changed to "3".

Done.


src/BloomExe/Publish/Epub/EpubMaker.cs line 3005 at r6 (raw file):

Previously, JohnThomson (John Thomson) wrote…

A few fonts exist only in Italic versions (AI noted 'Baron') or only in Bold (Google Fonts Alfa Slab One). Presumably the browser will attempt to synthesize normal from italic or bold if it must? Does that mean we need to include the group.Italic or group.Bold paths (with the appropriate weight/style values) if those are all that exist? (Might unfortunately complicate what you're doing with normalFacesAdded...I'm not sure).

I don't know. I've done all here that want to do, this is dragging on far beyond its benefit.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates font-face generation to better preserve Bloom/BloomReader font synthesis behavior when specific faces are missing, and keeps publish progress dialogs open when notes/warnings should be visible to the user.

Changes:

  • Adjust EpubMaker.AddFontFace to choose embedded font files in a way that allows browsers/readers to synthesize missing bold/italic axes (and dedupe normal/normal faces).
  • Add unit tests covering the new face-selection behavior for missing bold/italic combinations.
  • Update publish progress dialog behavior so “Note” messages prevent auto-close (giving users time to read important notes).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
src/BloomTests/Publish/Epub/ExportEpubTests.cs Adds tests for new AddFontFace face-selection/synthesis behavior.
src/BloomExe/Publish/Epub/EpubMaker.cs Implements new font-face selection logic and introduces normalFacesAdded tracking.
src/BloomExe/Publish/BloomPub/BloomPubMaker.cs Updates BloomPUB font embedding to use the new AddFontFace signature.
src/BloomBrowserUI/publish/commonPublish/PublishProgressDialog.tsx Prevents auto-close when “Note” messages occur; refines progress-state handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +2939 to +2948
else if (!string.IsNullOrEmpty(group.Italic))
{
chosenPath = group.Italic;
declaredWeight = "normal";
declaredStyle = "italic";
}
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AddFontFace can select group.Italic as the embedded face for a bold+italic request when BoldItalic is missing. However the embedding/copy step (PublishHelper.CheckFontsForEmbedding -> FontFileFinder.GetFileForFont) currently prefers group.Bold over group.Italic for bold+italic requests, so the EPUB can end up embedding only the bold file while fonts.css references the italic file (missing in the package). Please make the embedding selection logic match this chosenPath (e.g., change GetFileForFont ordering for bold+italic or embed both Bold and Italic when BoldItalic is unavailable).

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK fixed in the FontFileFinder as per Andrew's suggestion.

Comment on lines 937 to +941
var group = fontFileFinder.GetGroupForFont(font.fontFamily);
if (group != null)
{
EpubMaker.AddFontFace(sb, font, group);
EpubMaker.AddFontFace(sb, font, group, normalFacesAdded);
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BloomPubMaker embeds font files using PublishHelper.CheckFontsForEmbedding (which uses FontFileFinder.GetFileForFont). Since EpubMaker.AddFontFace may now choose a different face file for a bold+italic request (preferring Italic over Bold when BoldItalic is missing), fonts.css can reference a face file that wasn't copied into the BloomPUB folder. Please ensure the file-copy list matches the face that AddFontFace emits (e.g., align GetFileForFont / embedding selection with AddFontFace’s cascade).

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this and the comment in EpubMaker are two sides of the same coin.

I had copilot evaluate these and it agreed this is a bug.
It wants to fix it by swapping the processing order in FontFileFinder.GetFileForFont:
image.png

declaredStyle = "normal";
}
}
else if (wantsItalic && !wantsBold && !string.IsNullOrEmpty(group.Italic))
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Condition is always false because of access to local variable wantsItalic.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hallucination

declaredWeight = "normal";
declaredStyle = "italic";
}
else if (wantsBold && !wantsItalic && !string.IsNullOrEmpty(group.Bold))
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Condition is always false because of access to local variable wantsBold.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hallucination

Copy link
Contributor

@JohnThomson JohnThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JohnThomson reviewed 2 files and all commit messages, and resolved 3 discussions.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @andrew-polk and @hatton).

Copy link
Contributor

@andrew-polk andrew-polk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrew-polk reviewed 2 files and all commit messages, and resolved 2 discussions.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @hatton).

@andrew-polk
Copy link
Contributor

Copilot review has now chimed in with several bugs (if they are accurate...). I'm trying to grok them now.

Copy link
Contributor

@andrew-polk andrew-polk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrew-polk made 3 comments, resolved 2 discussions, and dismissed @copilot[bot] from 2 discussions.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @hatton).

Comment on lines 937 to +941
var group = fontFileFinder.GetGroupForFont(font.fontFamily);
if (group != null)
{
EpubMaker.AddFontFace(sb, font, group);
EpubMaker.AddFontFace(sb, font, group, normalFacesAdded);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this and the comment in EpubMaker are two sides of the same coin.

I had copilot evaluate these and it agreed this is a bug.
It wants to fix it by swapping the processing order in FontFileFinder.GetFileForFont:
image.png

declaredStyle = "normal";
}
}
else if (wantsItalic && !wantsBold && !string.IsNullOrEmpty(group.Italic))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hallucination

declaredWeight = "normal";
declaredStyle = "italic";
}
else if (wantsBold && !wantsItalic && !string.IsNullOrEmpty(group.Bold))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hallucination

Copy link

Copilot AI commented Feb 4, 2026

@andrew-polk I've opened a new pull request, #7655, to work on those changes. Once the pull request is ready, I'll request review from you.

Also, give the user a chance to read notes like ones about font embedding.
@hatton hatton force-pushed the BL-15558FixFontEmbedding branch from cdaecb5 to 9e858ba Compare February 5, 2026 22:45
Copy link
Member Author

@hatton hatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hatton made 1 comment and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @hatton).

Comment on lines +2939 to +2948
else if (!string.IsNullOrEmpty(group.Italic))
{
chosenPath = group.Italic;
declaredWeight = "normal";
declaredStyle = "italic";
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK fixed in the FontFileFinder as per Andrew's suggestion.

Copy link
Contributor

@andrew-polk andrew-polk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrew-polk reviewed 2 files and all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @hatton).

@andrew-polk andrew-polk merged commit 9fa1ca3 into Version6.3 Feb 5, 2026
1 of 2 checks passed
@andrew-polk andrew-polk deleted the BL-15558FixFontEmbedding branch February 5, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants