diff --git a/platform/platform-impl/src/com/intellij/ui/FontInfoRenderer.java b/platform/platform-impl/src/com/intellij/ui/FontInfoRenderer.java index 3fbc8c61cbb4..6239af145c41 100644 --- a/platform/platform-impl/src/com/intellij/ui/FontInfoRenderer.java +++ b/platform/platform-impl/src/com/intellij/ui/FontInfoRenderer.java @@ -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()); diff --git a/platform/util/src/com/intellij/util/ui/FontInfo.java b/platform/util/src/com/intellij/util/ui/FontInfo.java index 1c73bf03628c..6fb58afb962e 100644 --- a/platform/util/src/com/intellij/util/ui/FontInfo.java +++ b/platform/util/src/com/intellij/util/ui/FontInfo.java @@ -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 {