{
return cached;
}
final FontRegistry registry = getFontRegistry();
FontFamily family = registry.getFontFamily(fontFamily);
if (family == null)
{
AbstractOutputMetaData.logger.warn("Unable to lookup the font family: " + fontFamily);
// Get the default font name
final CSSValue fallBack = getDefaultFontFamily();
if (fallBack == null)
{
// If this case happens, the output-processor meta-data does not provide a sensible
// fall-back value. As we cannot continue without a font, we fail here instead of
// waiting for a NullPointer or other weird error later.
throw new IllegalArgumentException("No default family defined, aborting.");
}
if (fallBack instanceof CSSStringValue)
{
final CSSStringValue svalue = (CSSStringValue) fallBack;
family = registry.getFontFamily(svalue.getValue());
}
else
{
family = registry.getFontFamily(fallBack.getCSSText());
}
if (family == null)
{
// If this case happens, the output-processor meta-data does not provide a sensible
// fall-back value. As we cannot continue without a font, we fail here instead of
// waiting for a NullPointer or other weird error later.
throw new IllegalArgumentException("Default family is invalid. Aborting.");
}
}
reusableFontContext.setAntiAliased(antiAliasing);
reusableFontContext.setFontSize(fontSize);
reusableFontContext.setEncoding(encoding);
reusableFontContext.setEmbedded(embedded);
final FontRecord record = family.getFontRecord(bold, italics);
final FontMetrics fm = getFontStorage().getFontMetrics(record.getIdentifier(), reusableFontContext);
if (fm == null)
{
// If this case happens, then the previous steps of mapping the font name into sensible
// defaults failed. The font-system's font-registry is not in sync with the actual font-metrics