Can I set font properties for a string in java.
You can use AttributedString
. Here is some examples: JavaDocExamples
Font font = new Font("LucidaSans", Font.PLAIN, 14);
AttributedString messageAS = new AttributedString(textMessage);
...
messageAS.addAttribute(TextAttribute.FONT, font);
AttributedCharacterIterator messageIterator = messageAS.getIterator();
FontRenderContext messageFRC = graphics2D.getFontRenderContext();
LineBreakMeasurer messageLBM = new LineBreakMeasurer(messageIterator, messageFRC);