use of com.tom_roush.fontbox.type1.Type1Font in project PdfBox-Android by TomRoush.
the class FontMapperImpl method findFontBoxFont.
/**
* Finds a font with the given PostScript name, or a suitable substitute, or null.
*
* @param postScriptName PostScript font name
*/
private FontBoxFont findFontBoxFont(String postScriptName) {
Type1Font t1 = (Type1Font) findFont(FontFormat.PFB, postScriptName);
if (t1 != null) {
return t1;
}
TrueTypeFont ttf = (TrueTypeFont) findFont(FontFormat.TTF, postScriptName);
if (ttf != null) {
return ttf;
}
OpenTypeFont otf = (OpenTypeFont) findFont(FontFormat.OTF, postScriptName);
if (otf != null) {
return otf;
}
return null;
}
use of com.tom_roush.fontbox.type1.Type1Font in project pdfbox by apache.
the class FileSystemFontProvider method addType1Font.
/**
* Adds a Type 1 font to the file cache. To reduce memory, the parsed font is not cached.
*/
private void addType1Font(File pfbFile) throws IOException {
try (InputStream input = new FileInputStream(pfbFile)) {
Type1Font type1 = Type1Font.createWithPFB(input);
if (type1.getName() == null) {
fontInfoList.add(new FSIgnored(pfbFile, FontFormat.PFB, "*skipnoname*"));
LOG.warn("Missing 'name' entry for PostScript name in font " + pfbFile);
return;
}
if (type1.getName().contains("|")) {
fontInfoList.add(new FSIgnored(pfbFile, FontFormat.PFB, "*skippipeinname*"));
LOG.warn("Skipping font with '|' in name " + type1.getName() + " in file " + pfbFile);
return;
}
fontInfoList.add(new FSFontInfo(pfbFile, FontFormat.PFB, type1.getName(), null, -1, -1, 0, 0, -1, null, this));
if (LOG.isTraceEnabled()) {
LOG.trace("PFB: '" + type1.getName() + "' / '" + type1.getFamilyName() + "' / '" + type1.getWeight() + "'");
}
} catch (IOException e) {
LOG.warn("Could not load font file: " + pfbFile, e);
}
}
use of com.tom_roush.fontbox.type1.Type1Font in project veraPDF-pdfbox-validation by veraPDF.
the class PBoxPDType1Font method getcharSetListsAllGlyphs.
@Override
public Boolean getcharSetListsAllGlyphs() {
try {
PDFontDescriptor fontDescriptor = pdFontLike.getFontDescriptor();
if (fontDescriptor != null) {
String charSet = fontDescriptor.getCharSet();
if (charSet != null) {
String[] splittedCharSet = fontDescriptor.getCharSet().split("/");
// TODO : Log warning if charset doesn't start with '/'
FontBoxFont font = ((org.apache.pdfbox.pdmodel.font.PDSimpleFont) pdFontLike).getFontBoxFont();
for (int i = 1; i < splittedCharSet.length; i++) {
if (!font.hasGlyph(splittedCharSet[i])) {
return Boolean.FALSE;
}
}
if (font instanceof Type1Font) {
if (((Type1Font) font).getCharStringsDict().size() != splittedCharSet.length) {
return Boolean.FALSE;
}
} else if (font instanceof CFFFont) {
if (((CFFFont) font).getNumCharStrings() != splittedCharSet.length) {
return Boolean.FALSE;
}
}
// }
return Boolean.TRUE;
}
}
} catch (IOException e) {
LOGGER.debug("Error while parsing embedded font program. " + e.getMessage(), e);
}
return Boolean.FALSE;
}
use of com.tom_roush.fontbox.type1.Type1Font in project xmlgraphics-fop by apache.
the class OTFToType1TestCase method testFont.
@Test
public void testFont() throws IOException {
Type1Font t1 = getFont("test/resources/fonts/otf/SourceSansProBold.otf");
Assert.assertEquals(t1.getFontName(), "SourceSansPro-Bold.0");
Assert.assertEquals(t1.getCharStringsDict().keySet().toString(), "[.notdef, d]");
t1 = getFont("test/resources/fonts/otf/AlexBrushRegular.otf");
Assert.assertEquals(t1.getFontName(), "AlexBrush-Regular.0");
}
use of com.tom_roush.fontbox.type1.Type1Font in project xmlgraphics-fop by apache.
the class OTFToType1TestCase method testCIDFont.
@Test
public void testCIDFont() throws IOException {
CFFToType1Font realFont = (CFFToType1Font) getRealFont("test/resources/fonts/otf/AlexBrush-Regular-cid.otf");
for (int i = 0; i < 10240; i++) {
realFont.mapChar((char) i);
}
List<InputStream> fonts = realFont.getInputStreams();
InputStream is = fonts.get(0);
Type1Font t1 = Type1Font.createWithPFB(is);
Assert.assertEquals(t1.getFontName(), "AlexBrush-Regular.0");
Assert.assertTrue(t1.getCharStringsDict().keySet().contains(".notdef"));
Assert.assertTrue(t1.getCharStringsDict().keySet().contains("gid_1"));
}
Aggregations