private BaseFont getIdentityFont(String fontFamily,String fontPath,ApplicationContext applicationContext) throws DocumentException,IOException { if(!fontPath.startsWith(ApplicationContext.CLASSPATH_URL_PREFIX)){ fontPath=ApplicationContext.CLASSPATH_URL_PREFIX+fontPath; } String fontName = fontPath; int lastSlashPos=fontPath.lastIndexOf("/"); if(lastSlashPos!=-1){ fontName = fontPath.substring(lastSlashPos+1,fontPath.length()); } if (fontName.toLowerCase().endsWith(".ttc")) { fontName = fontName + ",0"; } InputStream inputStream=null; try{ fontPathMap.put(fontFamily, fontPath); inputStream=applicationContext.getResource(fontPath).getInputStream(); byte[] bytes = IOUtils.toByteArray(inputStream); BaseFont baseFont = BaseFont.createFont(fontName, BaseFont.IDENTITY_H,BaseFont.EMBEDDED,true,bytes,null); baseFont.setSubset(true); return baseFont; }finally{ if(inputStream!=null)inputStream.close(); } } }
BaseFont fonty = BaseFont.createFont(url, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); fonty.setSubset(true);
BaseFont fonty = BaseFont.createFont("assets/ARIALBD.TTF", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); fonty.setSubset(true); Phrase myName = new Phrase("Your Not Latin Words", new Font(fonty,12)); ColumnText.showTextAligned(canvas, Element.ALIGN_LEFT, myName, 66, 400, 0);
private BaseFont getIdentityFont(String fontFamily,String fontPath,ApplicationContext applicationContext) throws DocumentException,IOException { if(!fontPath.startsWith(ApplicationContext.CLASSPATH_URL_PREFIX)){ fontPath=ApplicationContext.CLASSPATH_URL_PREFIX+fontPath; } String fontName = fontPath; int lastSlashPos=fontPath.lastIndexOf("/"); if(lastSlashPos!=-1){ fontName = fontPath.substring(lastSlashPos+1,fontPath.length()); } if (fontName.toLowerCase().endsWith(".ttc")) { fontName = fontName + ",0"; } InputStream inputStream=null; try{ fontPathMap.put(fontFamily, fontPath); inputStream=applicationContext.getResource(fontPath).getInputStream(); byte[] bytes = IOUtils.toByteArray(inputStream); BaseFont baseFont = BaseFont.createFont(fontName, BaseFont.IDENTITY_H,BaseFont.EMBEDDED,true,bytes,null); baseFont.setSubset(true); return baseFont; }finally{ if(inputStream!=null)inputStream.close(); } } }
FontSelector selector = new FontSelector(); BaseFont bf1 = BaseFont.createFont(fontPath, BaseFont.IDENTITY_H, BaseFont.EMBEDDED); bf1.setSubset(true); Font font1 = new Font(baseFont, 12, Font.BOLD); selector.addFont(font1); // ... do that with all fonts you need Phrase ph = selector.process(TEXT); document.add(new Paragraph(ph));
this.options = options; font = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1250, BaseFont.NOT_EMBEDDED); font.setSubset(false);
bf.setSubset(false); fd = writer.addSimple(bf); localFonts.put(psn.toString().substring(1), bf);
bf.setSubset(false); fd = writer.addSimple(bf); localFonts.put(psn.toString().substring(1), bf);