Skip to content

fix(textstyle): referenced-style copies, kept typed values, cleaner list and preview - #2437

Merged
HakanSeven12 merged 11 commits into
HakanSeven12:mainfrom
turbuczn:fix/text-style-fixes-1
Nov 2, 2026
Merged

HakanSeven12 merged 11 commits into
HakanSeven12:mainfrom
turbuczn:fix/text-style-fixes-1

Conversation

@turbuczn

@turbuczn turbuczn commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Builds on #2434 — please review the last commit only.

Part of #2413. Fixes found by comparing PRs 1–8 with the design and by a manual test of the PR 8 build. The UI requests from the manual test (font list placement and colours, MTEXT origin marks, info bar, message wording) follow in a separate PR.

What it fixes

  • Copy / New from a referenced style is editable. A copy of PLAN|Notes is now Notes (1), not PLAN|Notes (1), and is no longer marked as referenced, so it can be changed and renamed. A new style started from a referenced one is editable too.
  • A typed value that cannot be applied is no longer dropped. While a field is red, switching styles, New, Copy, Delete, Import and Rename wait (the buttons are off), next to the existing "N fields need fixing before Apply." message.
  • No empty rows in the style list. The nameless shape-file entries (complex linetype symbols) are not listed and not offered under "Compare with", which also fixes the empty Compare field.
  • MTEXT with its own whole-text height keeps it. When a style height changes, an MTEXT that starts with \H…; is no longer updated.
  • Delete is off for Standard, the current style and a style texts use, instead of refusing after the click.
  • Drawing fonts show their SHX file. A style that stores the bare name txt is listed as txt.shx in the font picker.
  • TrueType file name on the web. Picking a common family (Arial, Times New Roman, Verdana, …) stores its usual .ttf file name from a small table when no installed file is known. For other families the file name stays empty and only the family is stored.
  • Preview caption stays inside its box. The caption is now a wrapping text under the drawing instead of being painted into the canvas, and the drawing keeps a wider margin. The pane's 14 px padding is wider than the 10 px floating scrollbar, so the scrollbar does not cover the box. The big font and the bold/italic face were already drawn (the preview resolves the style the same way as the drawing). This is now covered by tests, and the preview code moved into a method so it can be tested.
  • An untouched Apply really changes nothing. The new whole-drawing test showed that syncing the multileader style dictionary moved its entry to the end of the named object dictionary. The entry now keeps its place.
  • Cleanup: removed Message::MTextFont(String). Only a test sent it, and that test now uses the font picker message.

Tests added

  • Rename reaches attribute definitions, block texts and INSERT attributes; Close and one Undo bring them back.
  • Test 1 compares the whole drawing, not only the style.
  • The TrueType test always runs (with the bundled web font) instead of returning early on a machine without fonts.
  • Test 7: after a first fixed height of 2.5, a new TEXT gets 2.5.
  • Picking a font in the MTEXT editor leaves the text style unchanged.
  • Test 10: the window is drawn wide and narrow, in the light and dark themes (simulator snapshot).
  • Plus one test for each fix above.

No new strings, so no locale changes.

Left out on purpose

  • Only the faces a font really has are offered (e.g. ISOCPEUR: Regular and Italic). No synthetic bold.
  • The font list shows one "Font folders" section (downloaded fonts and the support folder together) instead of "Downloaded".
  • "Reset to style" is offered for "Custom" values only, not for "Mixed".
  • "New style from selection" plus switching the text to it are two undo steps.
  • The Big Font field stays a text field. A font picker that lists only SHX files can come later.
  • No shared number field widget (TS-11).
  • The style list counts are recomputed on selection, not only when the window opens. This is fast enough.
  • The Text style data: real font files, no conflicting flags, no stale DXF font record #2426 commit message says "the ACAD font record". Please reword it to "the font xdata record" when squashing.

🤖 Generated with Claude Code

turbuczn and others added 10 commits November 1, 2026 09:27
Oblique, tracking and colour set with nothing selected no longer re-serialise
the whole text through parse_mtext / to_mtext_string. They patch one leading
\Q / \T / \C control in the raw source, the way the object font and width
already do; codes that format only part of the text keep overriding it, and
clearing formatting leaves these whole-text controls in place. Reopening the
editor shows the whole-text oblique and tracking. folded_value and
apply_globals are gone.

The height is saved exactly as opened until its field is edited (the field
still shows it rounded), and the line spacing factor is kept as f64, so an
untouched Apply changes nothing and does not mark the drawing modified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The text style manager parsed its rounded field text back on every Select and
Apply, so a style the user only looked at lost precision and the drawing was
marked modified. The editor now works on a draft: an exact copy of the style
plus the text each number field showed when loaded; only a changed field is
parsed and written. Toggles and font picks edit the draft too.

New, Copy, Delete and starting a rename write the draft first, so a typed
value is copied instead of lost. Renaming rewrites only the texts naming the
style, through get_entity_mut, and the open manager keeps their before-images:
Close restores them and Apply puts them in the same undo step as the style
table. A style merged in as XREF|Name is read-only. The stage re-baselines
after the ribbon sync, so a second untouched Apply changes nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… have

The stroke font list stored its display names ("Simplex", "Standard") as the
font file; it now stores the SHX file each one stands for (simplex.shx,
txt.shx, ...), and still recognises the old names. Picking a stroke font drops
the bold and italic bits and keeps the character set and pitch; picking a
TrueType family stores its regular face file with the family and turns off
vertical text and the big font.

A DXF read keeps the ACAD font record it loaded, and the writer wrote it after
the one it builds from the style: each save added a stale family, and a switch
to a stroke font came back as TrueType after reload. Save preparation now drops
the loaded record when it holds only the font.

A new attribute or attribute definition no longer copies the style's backward
and upside-down flags, which the XOR with the style cancelled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the selected one

A number the text style manager cannot apply used to be dropped silently. The
width factor (0.01 to 100), oblique angle (-85 to 85 degrees) and height (0 or
more) now turn red with the reason under the field, and Apply stays off with
"N fields need fixing before Apply." beside it until they are fixed. The typed
text is kept; a field the user did not touch is never an error, even when the
drawing stores a value outside the range. The shared style frame takes the
reason, so other managers can use it.

A new text style starts as a copy of the selected one, like a new dimension
style. A "Use Big Font" switch, for stroke fonts only, clears the big font when
turned off and gives it back when turned on; picking a TrueType font turns it
off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The text style manager had two long lists (stroke fonts, system fonts) plus
free text fields for the font file and family; the MTEXT toolbar had its own
short list of ten names that it wrote as "\FStandard;", which no other
program can find. Both now use one shared picker (src/ui/font_picker.rs).

The head is the search field: typing filters the list by shown name or file.
The list has sections: the fonts the drawing's text styles use, the bundled
stroke fonts with the real SHX file each one stores (Simplex -> simplex.shx),
the SHX files in the downloaded-fonts and support folders, and the TrueType
families. A font the drawing names but nothing here draws is marked with the
warning icon and "missing - drawn with Standard", in the list and in the
head. A name nobody lists can still be typed and picked ("Use ...").

A pick in the style manager goes through the existing draft rules (a stroke
font drops bold/italic, a TrueType font drops vertical and the big font). A
"Font style" choice (Regular / Bold / Italic / Bold Italic) replaces the two
check boxes; it offers the faces the family has installed, keeps a stored
face this machine lacks, and is off for stroke fonts. In MTEXT a stroke font
is written by its file (\Fsimplex.shx;), a family as before.

The check for a missing SHX file moves out of missing_shx_fonts into
font_repo::shx_file_missing, so the picker and the font download use the
same rule. Ten new strings, in all 23 catalogs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…o its texts

Changing a text style's fixed height, width factor or oblique angle used to
leave the existing texts as they were, because TEXT, ATTRIB and ATTDEF store
their own width and oblique, and every text stores its height. Apply now
writes the new value into each text that still shows the style's old one:
model space, layouts, block definitions and the attributes of inserts.

A value set on the text itself stays: a different height or width, or an
MTEXT whole-text \W / \Q code (an MTEXT without one already draws with the
style's width and oblique). A fixed height that was or becomes 0 changes no
existing text. Texts in external references are not changed. The texts go
into the style manager's transaction, so one Undo takes back the style and
the texts together, and closing without Apply leaves them untouched.

Before Apply the window says what will happen, for example "Height: 2.5 →
3.5. 24 texts that follow the style are updated. Inside block definitions: 4.
7 texts with their own value keep them." The texts using the selected style
are listed once when it is selected, so the line follows each keystroke
without walking the drawing again. Six new strings, in all 23 catalogs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lue comes from

The MTEXT editor's first row now shows the style's values and marks where
each one comes from, on all four fields that a style can set:

- Font, Height, Width factor and Oblique carry "By style", "Custom" or
  "Mixed". The height follows a fixed style height (none is shown when the
  style asks for the height of each text); the oblique angle follows unless
  a whole-text \Q sets one. Mixed means the value comes from the style but
  some characters have their own.
- The Oblique field moves from the More menu into the first row and shows
  the style's angle when the text has none of its own. Typing the style's
  angle removes the code; typing 0 under a slanted style writes \Q0;.
- A right click on a Custom field offers "Reset to style (15°)": it removes
  the whole-text \f, \W or \Q, or gives the text the style's fixed height,
  as one undo step. Codes that format only part of the text stay.
- Picking another style brings its oblique angle into the field, and a
  height that followed the old style takes the new style's height; a height
  of the text's own stays.

Builds on the lossless whole-text controls of fix/mtext-lossless-globals
(merged into this branch). One new string, in all 23 catalogs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The MTEXT editor gets a style menu ("…" beside the Style list):

- New style from selection… asks for a name and makes a copy of the
  text's style with the values the selected characters share. The text
  then uses the new style; its whole-text codes that only repeat the
  style go, so every field shows "By style".
- Update "<style>" from selection writes the shared values into the
  text's own style. The change reaches every text that follows the
  style, as an Apply in the style manager does, in one undo step. Off for
  a style from an external reference.
- Text Style Manager… opens the manager on the text's style; after an
  Apply there the open editor shows the style's new values.

Only what a text style stores is read: the font with its bold and
italic, the height, the width factor and the oblique angle (the whole
text when nothing is selected). A value the characters do not share
stays as the style has it, a style that asks for each text's height
keeps asking, and a stroke font goes in as its real SHX file through the
style manager's own draft calls.

Five new strings, in all 23 catalogs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… style is used

The text style manager takes the layout of the approved mockup:

- The properties sit in three framed groups (Font, Size, Effects) with
  short hints, under the style name, its status with a text count and
  the "Compare with" row. A changed number says what is stored
  ("Modified · was 2.5000").
- Beside them: what Apply does to the texts (moved to the top and
  framed), a preview of the draft resolved as the drawing resolves a
  style (SHX file on disk, big font, TrueType face, filled glyphs) with
  a sample text field, and where the style is used by kind and block.
- List rows show how many texts use each style and a lock on
  referenced styles; "Styles in use" works here too.
- In a narrow window the two columns stack, the Apply summary first,
  and the toolbar shows icons only.

All five style managers get toolbar icons (two new SVGs: import,
set current) and a rename hint under the list.

One walk of the drawing gives the list counts and the selected style's
texts, run where the text walk ran before, not on every frame. The tabs
and TextStyleDialogTab are gone; the "Compare with" row is shared.

16 new strings, in all 23 catalogs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ist and preview

- A copy of, or a new style from, a referenced style is the drawing's own:
  the name loses its `XREF|` part and the copy is no longer referenced.
- While a field holds a value that cannot be applied, switching styles,
  New, Copy, Delete, Import and Rename wait, so the typed value stays.
- The nameless shape-file entries are not listed or offered for comparison.
- An MTEXT with a whole-text height code keeps its height on Apply.
- Delete is off for Standard, the current style and a style texts use.
- The font picker lists a bare stroke name (`txt`) as its SHX file.
- A common TrueType family stores its usual file name where no installed
  file is known (the web).
- The preview caption wraps under the drawing instead of running over it.
- The named object dictionary keeps its order when the multileader style
  dictionary is synced, so an untouched Apply changes nothing.
- Removed the unused Message::MTextFont.
- Tests: rename reaches attributes, inserts and block texts; test 1 compares
  the whole drawing; the TrueType test always runs; a new TEXT takes a first
  fixed height; an MTEXT font pick leaves the style alone; the window draws
  wide and narrow in both themes.

Part of HakanSeven12#2413.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@turbuczn
turbuczn force-pushed the fix/text-style-fixes-1 branch from d693be3 to 9b89893 Compare November 1, 2026 18:12
@HakanSeven12
HakanSeven12 merged commit 9b89893 into HakanSeven12:main Nov 2, 2026
6 checks passed
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