import java.io.IOException;
import java.util.Map;
+
import javax.xml.transform.Source;
/**
}
/**
+ * Return the font family.
+ * @return the font family
+ */
+ public String getFontFamily() {
+ return fontName;
+ }
+
+ /**
+ * Returns the font family name stripped of whitespace.
+ * @return the stripped font family
* @see FontUtil#stripWhiteSpace(String)
*/
public String getStrippedFontName() {
}
}
-
/* ---- MutableFont interface ---- */
/**
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
+import java.util.Collection;
import java.net.URL;
import java.util.List;
private static final String[] BOLD_WORDS = {"bold", "black", "heavy", "ultra", "super"};
/**
- * Attempts to determine FontTriplet from a given CustomFont.
+ * Attempts to determine FontTriplets from a given CustomFont.
* It seems to be fairly accurate but will probably require some tweaking over time
*
* @param customFont CustomFont
- * @return newly created font triplet
+ * @param triplet Collection that will take the generated triplets
*/
- private FontTriplet tripletFromFont(CustomFont customFont) {
+ private void generateTripletsFromFont(CustomFont customFont, Collection triplets) {
// default style and weight triplet vales (fallback)
- String name = customFont.getStrippedFontName();
+ String strippedName = customFont.getStrippedFontName();
String subName = customFont.getFontSubName();
- String searchName = name.toLowerCase();
+ String searchName = strippedName.toLowerCase();
if (subName != null) {
searchName += subName.toLowerCase();
}
break;
}
}
- return new FontTriplet(name, style, weight);
+ triplets.add(new FontTriplet(strippedName, style, weight));
+ String familyName = customFont.getFontFamily();
+ if (!strippedName.equals(familyName)) {
+ triplets.add(new FontTriplet(familyName, style, weight));
+ }
}
/**
*/
private EmbedFontInfo fontInfoFromCustomFont(
URL fontUrl, CustomFont customFont, FontCache fontCache) {
- FontTriplet fontTriplet = tripletFromFont(customFont);
List fontTripletList = new java.util.ArrayList();
- fontTripletList.add(fontTriplet);
+ generateTripletsFromFont(customFont, fontTripletList);
String embedUrl;
embedUrl = fontUrl.toExternalForm();
EmbedFontInfo fontInfo = new EmbedFontInfo(null, customFont.isKerningEnabled(),