Skip to content

Preserve font face and size for bold/italic/underline runs#568

Open
LeonarddeR wants to merge 1 commit into
trypsynth:masterfrom
LeonarddeR:fix/formatting-markers-font-reset
Open

Preserve font face and size for bold/italic/underline runs#568
LeonarddeR wants to merge 1 commit into
trypsynth:masterfrom
LeonarddeR:fix/formatting-markers-font-reset

Conversation

@LeonarddeR

Copy link
Copy Markdown
Contributor

Follow-up / fixup for #557.

Problem

On Windows, bold/italic/underline runs rendered in Arial 10pt instead of
the reader's font. wxMSW's wxTextCtrl::SetStyle rewrites the entire
font of a range whenever the wxTextAttr carries any font attribute — it
masks CFM_FACE | CFM_SIZE | ... unconditionally and fills unset fields
from a default font (Arial 10pt). Applying each marker as a
single-attribute wxTextAttr therefore reset the run's face/size, and
overlapping markers (e.g. a bold word inside an italic sentence) clobbered
each other's styles.

Fix

Merge the (possibly overlapping) markers into non-overlapping segments
carrying the union of active styles, then apply one full font per
segment (current control font + the segment's styles). Preserves face/size
and composes overlapping styles correctly on every platform.

Added unit tests for the marker-merge logic.

Verification

Built and opened a document with bold/italic/underline and combined
bold+italic runs — all render in the reader font at the correct size, and
the bold+italic run shows both styles.

🤖 Generated with Claude Code

wxMSW's wxTextCtrl::SetStyle rewrites the entire font of a range
whenever the wxTextAttr carries any font attribute: it masks
CFM_FACE | CFM_SIZE | ... unconditionally and fills unset fields from a
default font (Arial 10pt). Applying bold/italic/underline markers as
single-attribute wxTextAttrs therefore reset the run's face to Arial and
size to 10, and overlapping markers clobbered each other's styles.

Merge the (possibly overlapping) markers into non-overlapping segments
carrying the union of active styles, then apply one full font per
segment (current control font + the segment's styles). This preserves
face/size and composes overlapping styles correctly on every platform.

Add unit tests for the marker-merge logic.
@LeonarddeR

Copy link
Copy Markdown
Contributor Author

Cc @aryanchoudharypro

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