[jsword-devel] FontChooser bugs
DM Smith
jsword-devel@crosswire.org
Wed, 10 Mar 2004 10:01:25 -0500
In setStyle, font.isBold() throws a NPE.
In tracing this, it turns out it is because the "desktop" property
Looks.Configurable.Font has no value.
Also in setStyle, name.setSelectedItem(font) does not work unless the font
being set is 16pt, PLAIN (since setSelectedItem does a scan using equals()
for the first match in the list)
In FontChooser, the member variable "font" starts out as Serif, and nothing
is selected in the combo box to start out with. (Seems that the intention
was that "font" was to be a cached representation of the four widgets.)
However, with nothing selected, in getStyle the call selected.getName()
generates a NPE.
In LookAndFeelUtil there is a comment that winlaf is being used to provide a
better rendition of text on large monitors. And in FontChooser,
defaultFont.getFont will return Tahoma, 11pt, plain. I think the intention
is to use Tahoma as the default font when nothing else is picked.
Anyway, I have modified FontChooser to do the following:
1) Use defaultFont.getFont as the initial pick in the combo box.
2) Conditionally replace the pick with a new pick if it is valid.
3) Use font.deriveFont rather than new Font where possible.
4) Use symbolic constants for magic numbers (i.e. Font.PLAIN rather than 0
and RENDERER_FONT_SIZE rather than 16).
This leaves two problems to solve:
1) The default needs to be established in another part of the code so that
it can be used. I have not looked into it but it appears that property
change events are to propagate the selection, but unless the options dialog
is brought up, it can't propagate it. From a design perspective, this has
defaults being set in two locations, which is not ideal.
2) Some of the fonts in the combo box do not render the name of the font in
a readable fashion. Some of the fonts are for symbols or other languages'
character set and do not contain the ASCII character set. I think the
solution to this is fairly simple: have a label whose font is changed to
match the selection and just give the name in the list. I think that using
the text from Gen 1.1, would be appropriate.
_________________________________________________________________
Get a FREE online computer virus scan from McAfee when you click here.
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963