Change font weight of the first specific letters?

Answered

Hi,

is it possible to change the font weight of specific parts of my document?

I think of something like this:

    ChangeFontWeight.apply(document, TextRange.of(100,110), Weight.Bold);

 

Also important is that this is permanent (or i rerender each frame/on code update)

0
2 comments

Hi,

Please take a look at com.intellij.lang.annotation.Annotator and AnnotationHolder.newSilentAnnotation().

If it's not suitable for your case, please clarify what feature/behavior you want to implement.

1

Thanks for the tip, this is super close to what i want.

I wonder if it is possible to specify the FontWeight (eg make something  bold or italic) while keeping the color of the textrange.

 

EDIT: to be a bit more specific, i can construct any fontweight via the TextAttributes constructor, but i need to know the existing colors, or else i hardcode this stuff. 

Is it possible to request the textAttributes of an existing psi element?

 

EDIT2: i know i can pass in "null" to keep the color, but i would for example like to change the color slightly, so i need to get the original color first. 

I already have the TextAttributesKey but iam missing on how to get from such a key to a TextAttribute

 

EDIT3: Sometimes i dont even have a TextAttributesKey so iam lost here

 

EDIT4: 

For example "JAVA_CODE_REFERENCE", has an empty array

syntaxHighlighter.getTokenHighlights(element.getNode().getElementType());

Not sure how i can resolve stuff like this?

0

Please sign in to leave a comment.