On Wednesday 25 July 2007 05:17, Andreas L Delmelle wrote: > 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()? >
LMs tend to call these methods only once typically in their initialize method. A quick search shows that getCommonFont() is called only 8 times in the LMs and in each case the call is the same: font = <fobj>.getCommonFont().getFontState(<fobj>.getFOEventHandler().getFontInfo(), this); In summary LMs are not really interested in the CommonFont object as such. They only use it to get to the Font object (or now we want a list of Font objects) applicable to them. But the LMs would like a Font object not a Triplet. So, IMO the least impact change is to simply add font[] getFontStates(...) to CommonFont. How it is implemented internally doesn't really worry me. Manuel > > 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."); > } > --