Worst case scenario, you could use "createGraphicsShapes" instead of
"createGraphics".  That translates all text into Line Art.  It's not
even remotely efficient, but will Actually Work.  If you're not dealing
with a lot of text or file size isn't an issue, then by all means.

You might also try setting a break point in your font mapper to see
what's getting looked up, if anything.  You might just be dealing with a
case sensitivity issue or something silly like that.

--Mark Storer
  Senior Software Engineer
  Cardiff.com
 
import legalese.Disclaimer;
Disclaimer<Cardiff> DisCard = null;
 
 

> -----Original Message-----
> From: Sciss [mailto:[email protected]] 
> Sent: Tuesday, March 22, 2011 9:03 AM
> To: [email protected]
> Subject: [iText-questions] Need help getting an AWT font to work
> 
> hi,
> 
> i need some help with a combo of JFreeChart and iTextPDF. 
> Whenever I export my charts as PDFs, I end up with files that 
> use Helvetica all across the place.
> 
> my initial approach was
> 
>    def createPDF( file: File, chart: JFreeChart, width: Int, 
> height: Int ) {
>       val pageSize = new IRectangle( 0, 0, width, height )
>       val doc      = new IDocument( pageSize, 0, 0, 0, 0 )
>       val stream   = new FileOutputStream( file )
>       val writer   = PdfWriter.getInstance( doc, stream )
>       doc.open()
>       val cb      = writer.getDirectContent
>       val tp      = cb.createTemplate( width, height )
>       val g2      = tp.createGraphics( width, height )
>       val r2      = new Rectangle2D.Double( 0, 0, width, height )
>       chart.draw( g2, r2 )
>       g2.dispose
>       cb.addTemplate( tp, 0, 0 )
>       doc.close
>    }
> 
> i'm trying to set the AWT font like this
> 
>      val fontName = "Gulim"   // tried different ones, 
> problem is not specific to this one
> 
>       val axis = new CategoryAxis()
>       axis.setTickLabelFont( new Font( fontName, Font.PLAIN, 10 ))
>       plot.setDomainAxis( axis )
> 
> looking around on StackOverflow, i tried different things, like
> 
>    // my own ttfs and otfs are in here:
>      def userFontDir : File = new File( new File( 
> System.getProperty( "user.home" ), "Library" ), "Fonts" )
> 
>       val fntMap     = new DefaultFontMapper()
>       fntMap.insertDirectory( userFontDir.getAbsolutePath )
> 
> and
> 
>      FontFactory.registerDirectories()
> 
> and
> 
>      val fontFile = "Gulim.ttf"
>       fntMap.putName( fontName, new 
> DefaultFontMapper.BaseFontParameters( new File( userFontDir, 
> fontFile ).getAbsolutePath ))
> 
> and
> 
>      writer.setAtLeastPdfVersion( PdfWriter.VERSION_1_7 )
> 
> ...
> 
> No luck, output PDF still shows Helvetica (I tried in 
> Preview, Acrobat Pro and Inkscape, all the same, Acrobat Doc 
> info says the only font in the PDF is Helvetica).
> The only thing that changes is the kerning which apparently 
> comes from the font I want, so it looks even more awful.
> 
> 
> Thanks for hints!
> 
> best, -sciss-
> 
> 
> --------------------------------------------------------------
> ----------------
> Enable your software for Intel(R) Active Management 
> Technology to meet the growing manageability and security 
> demands of your customers. Businesses are taking advantage of 
> Intel(R) vPro (TM) technology - will your software be a part 
> of the solution? Download the Intel(R) Manageability Checker 
> today! http://p.sf.net/sfu/intel-dev2devmar
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> iText(R) is a registered trademark of 1T3XT BVBA.
> Many questions posted to this list can (and will) be answered 
> with a reference to the iText book: 
> http://www.itextpdf.com/book/ Please check the keywords list 
> before you ask for examples: http://itextpdf.com/themes/keywords.php
> 
> 

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to