Sublime Forum

Arbitrarily Color Text?

#1

Hi all,

I’m working on a plugin that requires changing the coloring and font style (bold and italicized) of text arbitrarily. My plan was to have a color scheme file which would associate unique scopes with all the possible colors and font styles I’d be using, and then use view.add_regions to associate a region of text with the appropriate scope and thus color/font_style.

However, I’m running into a few issues. First, I’ve noticed that if I specify just the foreground or just the background of a scope in the color scheme, any regions added with that scope are not colored correctly. This same incorrect coloring occurs if the scope’s foreground or background color matches that of the color scheme’s global settings. The only way I’ve figured to get around this issue is to specify a foreground or background color which is off by 1 from the one in the color scheme’s global settings. Only in this case is the text is colored “correctly”. In addition, specifying a font style of bold or italic seems to have no effect.

Can anyone shed some light on this issue?

Thanks!

1 Like

#2

Are you able to share any code that will reproduce the problem? Also, I think it can be important to restart ST (and even close and re-open affected files) after changing any values in the color scheme file - I was doing some work with syntax definitions and color schemes simultaneously yesterday and became perplexed when the results made no sense until I did those actions…

0 Likes