Hi everyone.
I'd like to specify a larger font size for Swing apps using the default
L&F, since on my high res monitor the text is a bit small for my liking.
I see in the font.properties file references to XFLD font descriptors,
but there is a %d in the font size position. I changing this line would
let me change the font used but not the actual size. Can I somehow
specify a larger default font size?
If this is impossible, I will settle for changing the default font size
just in my app. How can I change the default font size programmatically?
Thanks,
Cameron

Signature
e-mail : cam (at) mcc.id.au icq : 26955922
web : http://mcc.id.au/ msn : cam-msn (at) aka.mcc.id.au
office : +61399055779 jabber : heycam (at) jabber.org
Cameron McCormack - 17 May 2005 12:56 GMT
Oh and another thing: is there any FontConfig support? It would be nice
to get the same fonts used as those in gtk2.
Thanks,
Cameron

Signature
e-mail : cam (at) mcc.id.au icq : 26955922
web : http://mcc.id.au/ msn : cam-msn (at) aka.mcc.id.au
office : +61399055779 jabber : heycam (at) jabber.org
Vova Reznik - 17 May 2005 14:28 GMT
> Oh and another thing: is there any FontConfig support? It would be nice
> to get the same fonts used as those in gtk2.
>
> Thanks,
>
> Cameron
UIManager.put("some key", new FontUIResource(int,int,int));
for JTextField key is "TextField.font";
You should run this line at very beginning or
call SwingUtilities.updateComponentTreeUI(Component);
Larry Barowski - 17 May 2005 21:23 GMT
> Hi everyone.
>
[quoted text clipped - 7 lines]
> If this is impossible, I will settle for changing the default font size
> just in my app. How can I change the default font size programmatically?
This will work for all the standard L&Fs (doesn't work for
GTK L&F, may not work for some arbitrary L&F).
UIDefaults defaults = UIManager.getDefaults();
Enumeration keys = defaults.keys();
while(keys.hasMoreElements()) {
Object key = keys.nextElement();
Object value = defaults.get(key);
if(value != null && value instanceof Font) {
UIManager.put(key, null);
Font font = UIManager.getFont(key);
if(font != null) {
float size = font.getSize2D();
UIManager.put(key, new FontUIResource(font.deriveFont(size *
scale)));
} } }
Depending on your app and system, you may be concerned with:
1) defaults.get(key) may fail with NPE on some Java versions,
because of a "bad" font. Catching and ignoring the NPE will
avoid the problem here.
2) Internal frame title bars will not scale to the font size under
XP L&F. If your app uses internal frames, you should not scale
fonts when "InternalFrame.titleFont".equals(key) and the L&F
is XP.
Cameron McCormack - 18 May 2005 12:10 GMT
> This will work for all the standard L&Fs (doesn't work for
> GTK L&F, may not work for some arbitrary L&F).
Thanks! That's a nice trick, it works fine for me with the default L&F.
cameron

Signature
e-mail : cam (at) mcc.id.au icq : 26955922
web : http://mcc.id.au/ msn : cam-msn (at) aka.mcc.id.au
office : +61399055779 jabber : heycam (at) jabber.org
Tommi Johnsson - 29 May 2005 18:46 GMT
Find out what is your default L&F in your platform,
and create theme which uses your favorite fonts.
This works well with Metal L&F themes and
these actually has several `default fonts` for different kind of objects
so extending DefaultMetalTheme and overriding couple methods
gives you easily fonts expected.
[clip]
Class MyMetal extends DefaultMetalTheme {
.....
public FontUIResource getControlTextFont() {... }
public FontUIResource getSystemTextFont() { ... }
public FontUIResource getUserTextFont() { ... }
public FontUIResource getMenuTextFont() { ... }
public FontUIResource getWindowTitleFont() { ... }
public FontUIResource getSubTextFont() {... }
....
}
[/clip]
just don't forget to set it in use before gui is created.
- jt
> Hi everyone.
>
[quoted text clipped - 11 lines]
>
> Cameron