我知道我可以在這樣的一個AttributeSet中設置字體系列:字符串插入文檔用指定的字體
SimpleAttributeSet set = new SimpleAttributeSet();
StyleConstants.setFontFamily(set, "Monospace");
doc.insertString(
caretPosition, text, set);
但我真正想要做的是設置字體:
StyleConstants.setFont(set, "Courier New");
但是,沒有StyleConstants.setFont()方法。
那麼,如何設置一個AttributeSet中的字體? (請注意,我可以自由使用除SimpleAttributeSet之外的AttributeSet實現,我只是碰巧使用了那個)。
(請注意,我的真正目標是使用指定字體將字符串插入到Document中)。
工作正常,我。發佈證明問題的SSCCE。的 – camickr 2011-05-10 19:49:38
可能重複的[復位插入字符串之後在文檔屬性(http://stackoverflow.com/questions/5955324/resetting-attributes-in-a-document-after-inserting-a-string) – trashgod 2011-05-10 21:32:14