On 05/02/11 09:42, Larry Evans wrote:
> On 05/02/11 01:15, 1T3XT BVBA wrote:
>> Op 1/05/2011 19:28, Larry Evans schreef:
>>> Did an `svn update` then `ant execute` which got much fewer errors,
>>> but still got some suggesting a windows path expression (using c:)
>>> instaad of something more generic was used:
>> That's documented on p374.
>>
>> The rationale is that we make it easy for Windows users to run the code,
>> whereas Linux users are smart enough to fix this problem.
>>
>> Using the c:/windows/fonts/ path is the "simple" solution.
>> The generic solution is explained from section 11.4.1 on (p374).
>>
> Thanks for the reference. However, the suggestion on that page
> to look at:
>
> /usr/share/X11/fonts/
>
> doesn't work for ubuntu, which I gather is typical for linux
> distributions which sometimes (maybe often) don't have a
> standard place to put things. Anyway, I found the fonts here:
>
> /usr/share/fonts/truetype/msttcorefonts
>
> I changed:
>
> book/src/part1/chapter02/DirectorPhrases2.java
>
> by substituting:
>
> /usr/share/fonts/truetype/msttcorefonts
>
> for:
>
> c:/windows/fonts/
>
> in the 2 statements:
> timesbd = BaseFont.createFont(
> "c:/windows/fonts/timesbd.ttf",
> BaseFont.WINANSI, BaseFont.EMBEDDED);
> times = BaseFont.createFont(
> "c:/windows/fonts/times.ttf",
> BaseFont.WINANSI, BaseFont.EMBEDDED);
>
> and that .java file now compiles without problem; however, I will
> have to make similar changes to all files that have similar
> errors. Wouldn't providing a constant string, somewhere,
> for the directory where the fonts are located make
> the code more portable? I mean something like the:
>
> public static final String RESULT =
> "results/part1/chapter02/director_phrases_2.pdf";
>
> only it would be:
>
> public static final String FONTSDIR
> = "c:/windows/fonts/";
>
> for windows, and:
>
> public static final String FONTSDIR
> = "/usr/share/fonts/truetype/msttcorefonts/";
>
> for ubuntu, and, as suggested on p. 374:
>
> public static final String FONTSDIR
> = "/Library/fonts/";
>
To be more specific, say such a static final String were put
in the BaseFont class with as:
--{--BaseFont.java part--
public abstract class BaseFont {
/** This directory where true-type fonts are located
* This value is OS dependent.
*/
public static final String TTFONTSDIR
= "/usr/share/fonts/truetype/msttcorefonts/";
/** This is a possible value of a base 14 type 1 font */
public static final String COURIER = "Courier";
--}--BaseFont.java part--
Then the statements in DirectorPhrases2.java could be changed
to:
--{--DirectorPhrase2.java part--
// create a font that will be embedded
timesbd = BaseFont.createFont
( BaseFont.TTFONTSDIR + "timesbd.ttf",
BaseFont.WINANSI, BaseFont.EMBEDDED);
// create a font that will be embedded
times = BaseFont.createFont
( BaseFont.TTFONTSDIR + "times.ttf",
BaseFont.WINANSI, BaseFont.EMBEDDED);
--}--DirectorPhrase2.java part--
Then there would only be one place, the definition
of BaseFont.TTFONTSDIR, to change for
each OS to get the correct fonts directory.
-regards,
Larry
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
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