Skip to content

feat: choose the font and its size from the panel - #107

Merged
xAlcahest merged 2 commits into
mainfrom
font-list
Sep 6, 2026
Merged

feat: choose the font and its size from the panel#107
xAlcahest merged 2 commits into
mainfrom
font-list

Conversation

@xAlcahest

Copy link
Copy Markdown
Owner

Summary

Row three's font button, which is the last control of that row Sublore did not have. It sits with the four style flags and not with the colours, because that is where the reference's own sizer puts it, and it opens a picker holding the families installed on this machine, a field to type one into, and a size. Choosing writes \fn and \fs as one step.

The enumeration behind it is new and it asks nothing of a toolkit or a subprocess. WebKitGTK implements no way for the page to list local fonts, fc-list is a command a minimal system need not have installed even where the library is, and a crate would be a dependency for one table, so src-tauri/src/fonts.rs walks the directories a font is installed into and reads the name table out of each file. It found 290 families here. Everything in it treats the file as hostile, because a font is a binary somebody else wrote: every read is bounds-checked, a malformed file costs that file and nothing else, and the walk is capped in depth, in files opened and in bytes read.

Writing two tags as one step needed a planner, Edit::SetOverrideTags, which BACKLOG N39 said both the font and the colour's alpha wanted. One thing was tried inside it and taken back out: moving the caret by each write's shift. No line could be found where it changed the result, because set_tag writes where the caret is and the block it just made is what the next write finds there. Keeping it would have been dead code, and the comment where it stood says what was tried.

Changes

  • src-tauri/src/fonts.rs: the families installed on this machine, read from the name table of every font file, with the walk capped and eight tests including a sweep over every prefix of a real font.
  • src-tauri/src/subtitle/mod.rs: subtitle_set_override_tags, several tags at one caret.
  • src-tauri/src/lib.rs: both commands registered.
  • crates/sublore-edit/src/plan.rs: Edit::SetOverrideTags and plan_set_override_tags, with the name and value check now shared with the single-tag write.
  • crates/sublore-edit/tests/session.rs: two tags as one undo step, a list with one bad entry writing nothing, and a pick at a caret sitting on a note staying in one block.
  • src/hooks/useFonts.ts: the list, asked for once and only when the picker opens.
  • src/hooks/useSubtitleFile.ts: setOverrideTags.
  • src/components/CurrentLine.tsx: the font button in the style group, and the picker over it.
  • src/App.tsx: the hook, the caret it writes at, and the panel wired to both.
  • src/i18n/en.ts and src/styles/tools.css: the picker's words and its shape.
  • e2e/specs/current-line-bands.spec.js: the family and the size written at the caret in one step, taken back in one undo.
  • e2e/wdio.conf.js: the count the guard holds.
  • BACKLOG.md: N39 narrowed to the colour picker's own two halves, and N40 given what changed about it.

How to verify it by using the app

  1. Open fixtures/subtitles/ass/clean/speakers.ass and click a row. After B I U S there is an F, greyed, because there is no caret to write at yet.
  2. Click in the text box. F wakes up.
  3. Click it. A panel opens with a field, a list of the fonts installed on your machine, and a size.
  4. Type a few letters into the field: the list narrows to the families whose names carry them. Click one and the field takes it.
  5. Type 48 into the size and press Use this font. The line now begins {\fnYour Font\fs48}, and the video shows it drawn that way.
  6. Press Ctrl+Z once. Both the family and the size go together, because choosing a font is one thing you did.
  7. Open the picker again on a machine with no readable font directories and the list is empty; the field still takes a name and the write still works.

Verified on Linux: full gate green step by step, and the battery green at 35 spec files of 35 with 292 checks. One mutation, a planner that writes only the first tag of the list, reddened this check and only this one. A second mutation, moving the caret by each write's shift, reddened nothing at all, and that is why the shift is not in the code.

@xAlcahest
xAlcahest merged commit 45d03db into main Sep 6, 2026
14 checks passed
@xAlcahest
xAlcahest deleted the font-list branch September 6, 2026 22:59
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.

1 participant