How to "preserve" style data after a font change??

19 views
Skip to first unread message

John Vella

unread,
Jun 3, 2012, 1:03:02 AM6/3/12
to scintilla...@googlegroups.com
I'm not sure what the correct technique is for preserving existing styles after making a change to the font of the default style. My text is styled via one of the built-in lexers. I also have a custom line number margin, which is set to margin type RTEXT. I fill those numbers by listening to the "add/delete" notification. I also tag some of the line numbers with a custom style(showing them in red foreground for example). This all works fine.

My issue is what I should be doing following a change of font in the default style(ie calling SCI_STYLESETFONT STYLE_DEFAULT) so my custom style(s) don't lose their non-font attributes(ie foreground, background, etc). I'm calling SCI_STYLECLEARALL after the font change, which unfortunately resets the attributes of the styles I already have assigned. I can cause the lexer styles to be refreshed by calling SCI_COLOURISE, but this doesn't help with the other non-lexer styles. It seems like I'm forced to manually reassign(ie make the SCI_STYLESET* calls) all over again.

Do I have this sequence correct? Is there a better way of doing this?

Thanks,
-John

Matthew Brush

unread,
Jun 3, 2012, 4:36:03 AM6/3/12
to scintilla...@googlegroups.com
This is what Geany does in `editor_set_font()`:
https://github.com/geany/geany/blob/master/src/editor.c#L4435

It just loops through every style and sets the font for it. It works
well since Geany uses the same font for every style, by design.

Cheers,
Matthew Brush

Reply all
Reply to author
Forward
0 new messages