You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Da...@gro-scotland.gsi.gov.uk on 2013/09/24 10:42:59 UTC

Problem loading Courier New TTF

Hi,

I'm having a problem loading Courier New as a true type font.  I'm using version 1.8.2.  I've noticed there are a lot of bugs regarding true type fonts, but one fix managed to fix loading Arial as a true type font (https://issues.apache.org/jira/browse/PDFBOX-1663).  I'm just wondering if there is any fix for Courier New?  If not, is there any work around?  The think the problem exists with the widths in Courier as:
PDType1Font.COURIER.getWidths(); returns null - would this be the same for the Courier New font I'm loading?

My code that works with Arial:

File fontfile = new File("C:\\WINDOWS\\Fonts\\ARIAL.ttf");
PDFont font = org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(doc, fontfile);

My code that doesn't work with Courier New:

File fontfile = new File("C:\\WINDOWS\\Fonts\\COUR.ttf");
PDFont font = org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(doc, fontfile);

Thanks in advance,
David

David Petrie
Java Developer | Registration Systems Project Team : Registration IT | National Records of Scotland |
South Search Room, New Register House, 3 West Register Street, Edinburgh, EH1 3YT |
Telephone: (0131 3144) 587



**********************************************************************
This e-mail (and any files or other attachments transmitted with it) is intended solely for the attention of the addressee(s). Unauthorised use, disclosure, storage, copying or distribution of any part of this e-mail is not permitted. If you are not the intended recipient please destroy the email, remove any copies from your system and inform the sender immediately by return.

Communications with the Scottish Government may be monitored or recorded in order to secure the effective operation of the system and for other lawful purposes. The views or opinions contained within this e-mail may not necessarily reflect those of the Scottish Government.


Tha am post-d seo (agus faidhle neo ceanglan  còmhla ris) dhan neach neo luchd-ainmichte a-mhàin. Chan eil e ceadaichte a chleachdadh ann an dòigh sam bith, a’ toirt a-steach còraichean, foillseachadh neo sgaoileadh,  gun chead. Ma ’s e is gun d’fhuair sibh seo le gun fhiosd’, bu choir cur às dhan phost-d agus lethbhreac sam bith air an t-siostam agaibh, leig fios chun  neach a sgaoil am post-d  gun dàil.  

Dh’fhaodadh gum bi teachdaireachd sam bith bho Riaghaltas na h-Alba air a chlàradh neo air a sgrùdadh airson dearbhadh gu bheil an siostam ag obair gu h-èifeachdach neo airson adhbhar laghail eile. Dh’fhaodadh nach  eil beachdan anns a’ phost-d seo co-ionann ri beachdan Riaghaltas na h-Alba. 
**********************************************************************



Re: Problem loading Courier New TTF

Posted by Andreas Lehmkühler <an...@lehmi.de>.
Hi,

> David.Petrie@gro-scotland.gsi.gov.uk hat am 24. September 2013 um 10:42 geschrieben:
> 
> 
> Hi,
> 
> I'm having a problem loading Courier New as a true type font.  I'm using version 1.8.2.  I've noticed there are a lot of bugs regarding true type fonts, but one fix managed to fix loading Arial as a true type font (https://issues.apache.org/jira/browse/PDFBOX-1663).  I'm just wondering if there is any fix for Courier New?  If not, is there any work around?  The think the problem exists with the widths in Courier as:
> PDType1Font.COURIER.getWidths(); returns null - would this be the same for the Courier New font I'm loading?
> 
> My code that works with Arial:
> 
> File fontfile = new File("C:\\WINDOWS\\Fonts\\ARIAL.ttf");
> PDFont font = org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(doc, fontfile);
> 
> My code that doesn't work with Courier New:
> 
> File fontfile = new File("C:\\WINDOWS\\Fonts\\COUR.ttf");
> PDFont font = org.apache.pdfbox.pdmodel.font.PDTrueTypeFont.loadTTF(doc, fontfile);
> 
> Thanks in advance,
> David
Hmm, I somehow didn't get the point. If you are using true type fonts the class
PDType1Font isn't involved,
consequently there can't be a problem with getWidths().
What exactly are you trying to do? Do you get a stacktrace?

> David Petrie
> Java Developer | Registration Systems Project Team : Registration IT | National Records of Scotland |
> South Search Room, New Register House, 3 West Register Street, Edinburgh, EH1 3YT |
> Telephone: (0131 3144) 587

BR
Andreas Lehmkühler