mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
show fonts which cannot display latin characters in font selection combobox (following IDEA-154927)
This commit is contained in:
@@ -21,8 +21,8 @@ import com.intellij.util.ui.FontInfo;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
import java.awt.Font;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* @author Sergey.Malenkov
|
||||
@@ -31,15 +31,17 @@ public class FontInfoRenderer extends ListCellRendererWrapper {
|
||||
@Override
|
||||
public void customize(JList list, Object value, int index, boolean selected, boolean focused) {
|
||||
Font font = list.getFont();
|
||||
String text = value == null ? "" : value.toString();
|
||||
setText(text);
|
||||
if (value instanceof FontInfo) {
|
||||
FontInfo info = (FontInfo)value;
|
||||
Integer size = getFontSize();
|
||||
setFont(info.getFont(size != null ? size : font.getSize()));
|
||||
Font f = info.getFont(size != null ? size : font.getSize());
|
||||
if (f.canDisplayUpTo(text) == -1) {
|
||||
font = f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
setFont(list.getFont());
|
||||
}
|
||||
setText(value == null ? "" : value.toString());
|
||||
setFont(font);
|
||||
setForeground(list.isEnabled()
|
||||
? UIUtil.getListForeground(selected)
|
||||
: UIUtil.getLabelDisabledForeground());
|
||||
|
||||
@@ -215,7 +215,7 @@ public final class FontInfo {
|
||||
Rectangle bounds = font.getStringBounds(new char[]{ch}, 0, 1, DEFAULT_CONTEXT).getBounds();
|
||||
if (!bounds.isEmpty()) return bounds.width;
|
||||
}
|
||||
throw new IllegalArgumentException(Integer.toHexString(ch) + " cannot be rendered by " + font);
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static final class LazyListByName {
|
||||
|
||||
Reference in New Issue
Block a user