On Jul 21, 2007, at 14:07, Andreas L Delmelle wrote:
<snip />
As to then further addressing the font-family fallback/font-
selection issue, ...
<snip />
Change the getFontState() signature:
- either make it
public Font[] getFontStates()
- or add an extra char parameter to getFontState(), that would
allow CommonFont to seek a Font in its list that contains a mapping
for the given char
Which strategy is preferred? I'm even thinking that maybe it would
even be better design not to store/create Font instances in
CommonFont at all, and instead of doing so, *always* forward the
font-lookup to FontInfo (not only the first time getFontState() is
called, as is the case now).
Anyone have any objections, for instance, to change the default
behaviour of FontInfo.fontLookup(String[], ...) to something like the
below code? Should we add a getFontInstances() method too, or rather,
since the below method is only used by CommonFont, maybe merge it
into such a getFontInstances() method, that would return Font[]?
To Manuel in particular: what would be most convenient from your
point of view? Is it OK if each LM gets a set of Fonts (or mere
triplet-keys), instead of only one, upon the call to getFontState()?
Cheers
Andreas
-- sample FontInfo.fontLookup() --
/**
* Looks up (a set of) font(s).
* <br>
* Locate the font name(s) for the given families, style and
weight.
* The font name(s) can then be used as a key as they are unique
for
* the associated document.
* This also adds the font(s) to the list of used fonts.
* @param families font families (priority list)
* @param style font style
* @param weight font weight
* @return the set of font triplets of the supported font-families
* in the specified style and weight.
*/
public FontTriplet[] fontLookup(String[] families, String style,
int weight) {
FontTriplet triplet;
List tmpTriplets = new ArrayList(families.length);
for (int i = 0; i < families.length; i++) {
triplet = fontLookup(families[i], style, weight, (i >=
families.length - 1));
if (triplet != null) {
tmpTriplets.add(triplet);
}
}
if (tmpTriplets.size() != 0) {
FontTriplet[] triplets =
(FontTriplet[]) tmpTriplets.toArray();
return triplets;
}
throw new IllegalStateException(
"fontLookup must return an array with at least
one "
+ "FontTriplet on the last call.");
}
--