• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[SOLUTION] Preparing OS X fonts for iText [and most likely FOP too]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SOLUTION] Preparing OS X fonts for iText [and most likely FOP too]


  • Subject: [SOLUTION] Preparing OS X fonts for iText [and most likely FOP too]
  • From: Stefan Pantke <email@hidden>
  • Date: Wed, 7 Dec 2005 00:22:35 +0100

First of all, thanks to everybody who answered my Mac-related Font
problems.

Before preparing Mac OS X fonts for iText usage, download and install fondu 
http://fondu.sourceforge.net/

open terminal, start a csh and fire

>>>
setenv PATH /usr/local/bin:$PATH 
setenv MANPATH /usr/local/man 
<<<

Switch to your personal Fonts directory [e.g. /Users/sp/Library/Fonts ]
and fire [fondu asks, before it overwrites any file]

fondu *

After fondu finished its job, iText knows much more fonts. In my case
0 iText-compatible fonts before and 113 after fondu's work.

After fondu did its job, you might wish to evaluate your newly available fonts.
Try this iText based source, which prepares a font report PDF:

>>>
   Document document = new Document( PageSize.A4 );

           ByteArrayOutputStream oBuffer = new ByteArrayOutputStream();

try {
PdfWriter.getInstance( document, oBuffer );

try {
document.open();


// First of all, let's see if iText works at all
           document.add(new Paragraph("Font report as of " + new Date().toString() ));

// Next, register OS X's well know places for fonts

// For non OS X users: These directories exist on each and any OS X box

int systemFontNr = FontFactory.registerDirectory( "/Library/Fonts/" );
int systemFontNr2 = FontFactory.registerDirectory( "/System/Library/Fonts/" );

// Next, let iText add our personal account's font directory too
// In this case, I register fonts of user 'sp'
int userFontNr = FontFactory.registerDirectory( "/Users/sp/Library/Fonts/" );

     // Emit details, how much fonts are available
System.err.println("Fonts: " + userFontNr + " user, " + systemFontNr + " system, " + systemFontNr2 + " system-core" );


int aFontIndex = 0;

            for ( Iterator i = FontFactory.getRegisteredFamilies().iterator(); i.hasNext(); ) {


aFontIndex ++;


String currentFontName = (String) i.next();


try {


Paragraph para = new Paragraph(aFontIndex 
+ " [This is font family " + currentFontName + "] ",
  FontFactory.getFont(currentFontName, 12));
document.add( para );

} catch ( Exception ex) {
System.err.println("getFont failed: " + ex.getMessage() + "[" + currentFontName + "]");
}


               }


}
catch ( Exception ex) {
System.err.println("Document problem 2: " + ex.getMessage());
}


// step 5: we close the document
document.close();
<<<

Additionally, if you are using Apple's WebObjects and your are preparing a
WOResponse, you might wish to add this:

>>>
response.setContent( new NSData( oBuffer.toByteArray() ) );
response.setHeader("application/pdf", "Content-Type");
<<<


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Request for feedback on proposed project
  • Next by Date: ClassCastException
  • Previous by thread: Re: _EOCheapCopyMutableArray blocks
  • Next by thread: ClassCastException
  • Index(es):
    • Date
    • Thread