> On 20 May 2016, at 10:16, Peter Prusi <[email protected]> wrote:
> 
> Not exactly. In my case, I dont know which font should be used. I am getting 
> a string which respresents the font name. For example I could make a big 
> switch/case block:
> 
>        switch (fontName) {
>        case "HELVETICA":
>            PDFont font = PDType1Font.HELVETICA;
>            break;
> …
> }

Yes, you should do that.

> with 14 cases, one for each available font, but I think there is a nicer way 
> to do this :-) In 1.8 I could simply pass the font name to PDType1Font 
> constructor, but in 2.0 I dont see this option.

You could also pass garbage to the PDType1Font constructor and PDFBox would 
either produce broken PDFs or crash. The above method prevents this.

— John

> Am 20.05.2016 um 18:44 schrieb Tilman Hausherr:
>> Just use the static variables, e.g. PDType1Font.HELVETICA. Is this what you 
>> had in mind?
>> 
>> Tilman
>> 
>> Am 20.05.2016 um 18:42 schrieb Peter Prusi:
>>> No, I like to use one of the 14 fonts defined in PDType1Font class. In 
>>> version 1.8 it was possible to pass a font name to the PDType1Font 
>>> constructor (PDType1Font(String baseFont)) to create a PDType1Font object 
>>> with given name. In version 2.0 this constructor is private. In 1.8 I see 
>>> also a function getStandardFont(String name), which returns the PDType1Font 
>>> object with the passed string.
>>> 
>>> I am looking for something like this in version 2.0.
>>> 
>>> Am 20.05.2016 um 17:27 schrieb Tilman Hausherr:
>>>> Am 20.05.2016 um 15:41 schrieb Peter Prusinowski:
>>>>> Hello,
>>>>> 
>>>>> I am trying set a base font from its name as string. In PDType1Font 
>>>>> class, there is a constructor for this purpose: PDType1Font(String 
>>>>> baseFont), but only private accessible.
>>>>> I also tried with FontMappers class without success. Can anyone help me ?
>>>> 
>>>> Could you clarify what you mean with "set a base font from its name as 
>>>> string"?
>>>> 
>>>> Do you want to use an external font?
>>>> 
>>>> Tilman
>>>> 
>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [email protected]
>>>> For additional commands, e-mail: [email protected]
>>>> 
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to