2001 JI Open Discussion Posted August 17, 2006 Share Posted August 17, 2006 By: Yong Wang - wymz pls help with font problem 2002-12-16 19:30Hi, I am trying to create a few font definitions for Arial, Courier, and Times with different styles, Normal, Bold, and Italic. So here is what's in my jasper xml: <reportFont name="Arial_Italic" fontName="Arial" isBold="false" isItalic="true" size="8" isDefault="false" isPdfEmbedded="false" pdfEncoding="Cp1252" pdfFontName="Helvetica-Oblique" /> <reportFont name="Arial_Normal" fontName="Arial" isBold="false" isItalic="false" size="8" isDefault="true" isPdfEmbedded="false" pdfEncoding="Cp1252" pdfFontName="Helvetica" /> <reportFont name="Arial_Bold" fontName="Arial" isBold="true" isItalic="false" size="8" isDefault="false" isPdfEmbedded="false" pdfEncoding="Cp1252" pdfFontName="Helvetica-Bold" /> <reportFont name="Courier_Italic" fontName="Courier" isBold="false" isItalic="true" size="8" isDefault="false" isPdfEmbedded="false" pdfEncoding="Cp1252" pdfFontName="Courier-Oblique" /> <reportFont name="Courier_Normal" fontName="Courier" isBold="false" isItalic="false" size="8" isDefault="true" isPdfEmbedded="false" pdfEncoding="Cp1252" pdfFontName="Courier" /> <reportFont name="Courier_Bold" fontName="Courier" isBold="true" isItalic="false" size="8" isDefault="false" isPdfEmbedded="false" pdfEncoding="Cp1252" pdfFontName="Courier-Bold" /> <reportFont name="Times_Italic" fontName="Times" isBold="false" isItalic="true" size="8" isDefault="false" isPdfEmbedded="false" pdfEncoding="Cp1252" pdfFontName="Times-Oblique" /> <reportFont name="Times_Normal" fontName="Times" isBold="false" isItalic="false" size="8" isDefault="true" isPdfEmbedded="false" pdfEncoding="Cp1252" pdfFontName="Times" /> <reportFont name="Times_Bold" fontName="Times" isBold="true" isItalic="false" size="8" isDefault="false" isPdfEmbedded="false" pdfEncoding="Cp1252" pdfFontName="Times-Bold" /> It works for Arial and Courier, but I am getting exception for Times fonts during runtime: ************************************************************************* * WARNING: Failure using Thread.currentThread().getContextClassLoader() * * in JRLoader class. Using JRLoader.class.getClassLoader() instead. * ************************************************************************* dori.jasper.engine.JRException: Could not load font from location : Times at dori.jasper.engine.export.JRPdfExporter.exportText(JRPdfExporter.java:850) at dori.jasper.engine.export.JRPdfExporter.exportPage(JRPdfExporter.java:316) at dori.jasper.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:270) at dori.jasper.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:214) at dori.jasper.engine.JasperExportManager.exportReportToPdfStream(JasperExportManager.java:166) ... I am totally baffled. It appears that jasper is trying to locate "Times" font from a file named "Times". But how come it works for Arial and Courier? where is it trying to load the font from? I'd appreciate any insight or solution how I can make this work. Thanks. By: Teodor Danciu - teodord RE: pls help with font problem 2002-12-17 02:03 Hi, Try pdfFontName="Times-Roman". Thank you, Teodor By: Chuck Deal - cdeal RE: pls help with font problem 2002-12-17 05:21Here is what I have in my file. <reportFont name="Times" isDefault="false" fontName="Times New Roman" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Times-Roman" pdfEncoding="Cp1252" isPdfEmbedded="false"/> <reportFont name="TimesBold" isDefault="false" fontName="Times Bold" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Times-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/> As you can see, they are similiar. I don't think your definitions are wrong. I had a similiar problem that generated the exception that you gave because I had <textElement> that contained a <font reportFont="Times"/> and there was no definition of the reportFont "Times". By: Yong Wang - wymz RE: pls help with font problem 2002-12-17 12:34Thank you for the info. I tried Times-Roman as the "normal" Times fonts, and it works. I am now getting the same exception about "Times-Oblique". What pdfFontName should I use for Times with Italic style? Thanks. By: Yong Wang - wymz RE: pls help with font problem 2002-12-17 12:41Pls disregard my previous question. I tried the obvious (Times-Italic) and it works! By: Teodor Danciu - teodord RE: pls help with font problem 2002-12-17 23:15 Hi, Use pdfFontName="Times-Italic". Here are the 14 built-in fonts that iText supports: "Courier" "Courier-Bold" "Courier-Oblique" "Courier-BoldOblique" "Helvetica" "Helvetica-Bold" "Helvetica-Oblique" "Helvetica-BoldOblique" "Symbol" "Times-Roman" "Times-Bold" "Times-Italic" "Times-BoldItalic" "ZapfDingbats" Thank you, Teodor Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now