Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

superscript and underline at the same time

 
Michelle Kyamo
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a StyledDocument where I want one whole line to be underlined, and a few characters in the line are also in superscript. What happens is that the underline that runs under the superscripted characters is raised compared to the underline under the regular characters. I want the underline to be continuous under the whole line. Is there a way to fix this?
 
Campbell Ritchie
Sheriff
Pie
Posts: 50246
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult a question for us beginners. Moving thread.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know but I'm going to speculate.

What you are seeing is superscripted underlined characters. (Which is something that I have seen in print.) What you want to see is underlined superscripted characters. (I haven't seen that in print but it seems like a reasonable thing to want.) Perhaps the order in which you set up the styling makes a difference? Perhaps not, that's just a guess.
 
Darryl Burke
Bartender
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If all else fails, you could try applying the UNDERLINE_LOW_ONE_PIXEL / UNDERLINE_LOW_TWO_PIXEL attribute to the superscripted text.
 
Michelle Kyamo
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:I don't know but I'm going to speculate.

What you are seeing is superscripted underlined characters. (Which is something that I have seen in print.) What you want to see is underlined superscripted characters. (I haven't seen that in print but it seems like a reasonable thing to want.) Perhaps the order in which you set up the styling makes a difference? Perhaps not, that's just a guess.


Thanks for the idea, but the switching the order didn't change anything.
 
Michelle Kyamo
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:If all else fails, you could try applying the UNDERLINE_LOW_ONE_PIXEL / UNDERLINE_LOW_TWO_PIXEL attribute to the superscripted text.


Trying to do this but it doesn't seem to be working (I mean I can't seem to apply the attribute at all, not that it doesn't fix my problem).

doc2 = textpane2.getStyledDocument();
superscript = doc2.addStyle("superscript",null);
StyleConstants.setSuperscript(superscript,true);
undersuper = doc2.addStyle("undersuper", superscript);
undersuper.addAttribute(TextAttribute.UNDERLINE,TextAttribute.UNDERLINE_LOW_TWO_PIXEL);

I then use undersuper in the insertString method of StyledDocument (have also tried setCharacterAttributes) and the text appears superscripted with no underline.
 
Michelle Kyamo
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems I can only make the attributes in StyleConstants work, not anything in TextAttribute.

I reduced the font size of the superscript a little, which makes the problem a little less (the underlines are offset still, but less so).
 
Michelle Kyamo
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michelle Kyamo wrote:It seems I can only make the attributes in StyleConstants work, not anything in TextAttribute.

I reduced the font size of the superscript a little, which makes the problem a little less (the underlines are offset still, but less so).


Does anyone know how to make the TextAttribute work so I can use UNDERLINE_LOW_ONE_PIXEL?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic