protected Object configureValue(Object value) {
if (value instanceof Font) {
Font font = (Font)value;
if ("MS Sans Serif".equals(font.getName())) {
int size = font.getSize();
// 4950968: Workaround to mimic the way Windows maps the default
// font size of 6 pts to the smallest available bitmap font size.
// This happens mostly on Win 98/Me & NT.
int dpi;
try {
dpi = Toolkit.getDefaultToolkit().getScreenResolution();
} catch (HeadlessException ex) {
dpi = 96;
}
if (Math.round(size * 72F / dpi) < 8) {
size = Math.round(8 * dpi / 72F);
}
Font msFont = new FontUIResource("Microsoft Sans Serif",
font.getStyle(), size);
if (msFont.getName() != null &&
msFont.getName().equals(msFont.getFamily())) {
font = msFont;
} else if (size != font.getSize()) {
font = new FontUIResource("MS Sans Serif",
font.getStyle(), size);
}
}
if (FontUtilities.fontSupportsDefaultEncoding(font)) {
if (!(font instanceof UIResource)) {
font = new FontUIResource(font);
}
}
else {
font = FontUtilities.getCompositeFontUIResource(font);
}
return font;
}
return super.configureValue(value);
}
|