0
작동하지 이모티콘 디스플레이 단지로되도록Graphics2D에 대해서 drawString 내가 그렇게하기 위해 내가 <a href="https://github.com/vdurmont/emoji-java" rel="nofollow noreferrer">this library</a>하고 다음 클래스를 사용하고 스윙 객체 (JLabel의 등)에 이모티콘을 표시하려고 색 글꼴
jLabel.setIcon(new EmojiIcon(":poop:"));
착색되는 것을 제외 이모티콘 지원을 모든 글꼴 (예 :
EmojiOne 및
Noto Color Emoji)
단색 이모티콘의 포인트는 무엇입니까 작동
?
public class EmojiIcon implements Icon {
private Font font;
private final static int DEFAULT_SIZE = 32;
private int width = DEFAULT_SIZE;
private int height = DEFAULT_SIZE;
private String emoji;
public EmojiIcon (String iconString){
this.emoji = EmojiParser.parseToUnicode(iconString);
setFont("emojione-android");
recalculateIconWidth(emoji);
}
public void setFont(String strFont){
try {
font = Font.createFont(Font.TRUETYPE_FONT, new File("fonts/"+strFont+".ttf")).deriveFont(48f);
} catch (FontFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
private void recalculateIconWidth(String iconString){
FontRenderContext frc = new FontRenderContext(null, true, true);
Rectangle2D bounds = font.getStringBounds(iconString, frc);
width = (int) bounds.getWidth();
height = (int) bounds.getHeight();
}
@Override
public void paintIcon(Component c, Graphics g, int x, int y){
Graphics2D g2d = (Graphics2D) g;
g2d.setFont(font);
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawString(emoji, 0, height);
}
}
내가 온라인 거세한 숫양을 찾고 있었어요 그것도 법적 그래서 난이 (적어도 .TTF 글꼴) standarised되지 않는다는 here을 발견 글꼴 색상을 가지고 할 수있다. 해결 방법이 있습니까? 정말 부하 글꼴 EmojiOne font