gpt4 book ai didi

java.awt.font 字母间距

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:14:23 37 4
gpt4 key购买 nike

使用 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);

最佳答案

您可以派生一种新字体,具有更新的跟踪属性:

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);

关于java.awt.font 字母间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13229725/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com