2012-11-05 38 views
8

Có thể tăng khoảng cách chữ cái khi sử dụng java.awt.font không? Something như thế này:Khoảng cách giữa các chữ java.awt.font

Font font = new Font("serif", Font.PLAIN, 21); 
//Increase the spacing - perhaps with deriveFont()? 

BufferedImage image = new BufferedImage(400, 600, BufferedImage.TYPE_INT_RGB); 
Graphics2D graphics = image.createGraphics(); 
graphics.setFont(font); 
graphics.drawString("testing",0,0); 

Trả lời

10

Bạn có thể lấy được một phông chữ mới, với một thuộc tính theo dõi cập nhật:

Map<TextAttribute, Object> attributes = new HashMap<TextAttribute, Object>(); 
attributes.put(TextAttribute.TRACKING, 0.5); 
Font font2 = font.deriveFont(attributes); 
gr.setFont(font2); 
gr.drawString("testing",0,20); 
+0

Cảm ơn, mà đã làm các trick! – user1031054

Các vấn đề liên quan