Skip to content

Add custom fonts for screenplay and novel modes#197

Open
manorajesh wants to merge 3 commits into
lmparppei:mainfrom
manorajesh:main
Open

Add custom fonts for screenplay and novel modes#197
manorajesh wants to merge 3 commits into
lmparppei:mainfrom
manorajesh:main

Conversation

@manorajesh

Copy link
Copy Markdown

Adds separate custom font preferences for screenplay and novel modes on macOS and iOS.

The editor and renderer now use the selected font for the matching mode while keeping screenplay pagination warnings for non-monospaced fonts. This also updates caret/selection font metrics so custom fonts align correctly in the editor.

@lmparppei

Copy link
Copy Markdown
Owner

Wow, thank you!

Could you walk me through what this actually changes in the big picture? Font manager is still used everywhere to provide the font based on the multiple custom settings, right?

@manorajesh

Copy link
Copy Markdown
Author

Yes, the font manager is still the source of truth. The change adds a custom-font path alongside the existing built-in font paths.

In practice, the editor/export code still ends up with a BeatFontSet. If a custom screenplay/novel font is configured, loadFontsWithScale: asks BeatFontManager to create/cache a custom BeatFontSet; otherwise it falls back to the existing fontsWith:self.fontType behavior.

The preferences/settings UI only saves the selected font name. The actual font objects are still created through BeatFontManager when the editor/export loads fonts.

The extra layout changes are mostly to handle arbitrary font metrics: custom fonts may be taller than the built-in Courier fonts, so line height is adjusted when fonts.custom is true to avoid clipping.

@lmparppei

Copy link
Copy Markdown
Owner

The renderer will clip anything though, and in fact, that's an intended behavior, because of some kanji font weirdness.

I wonder if there should be an overall warning about using a custom font altogether. Your implementation is a little cleaner than what I tried to do back in the day, but I think pagination code has to be adjusted to always squeeze fonts into the given line height, before this can be merged. I'll take a look at that when I can!

@manorajesh

Copy link
Copy Markdown
Author

Got it, that makes sense. I was treating the editor and renderer similarly, but I see why renderer should be clipping.

I can adjust this so the editor avoids clipping for readability while the renderer keeps the fixed line height and scales custom fonts to fit instead of expanding the layout. I can also add a general warning that custom fonts may affect pagination/standard formatting.

@manorajesh

Copy link
Copy Markdown
Author

Custom fonts still go through the existing font rendering path, but pagination applies the same fixed-line-height fitting as the renderer. So the renderer can keep clipping while pagination measures against the same fitted font metrics.

I also added a visible warning in Preferences whenever either screenplay or novel mode uses a custom font.

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.

2 participants