You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "Hiller, Gerhard" <Ge...@msh.de> on 2021/05/06 18:33:18 UTC
Font-Handling
Hi everybody,
I try to use a TrueTypeFont https://fonts.google.com/specimen/Playfair+Display with its embedded "Upper Case Numbers".
The font includes "normal" numbers from Unicode +0030 until +0039.
Additionally there are Numbers which can be used in InDesign as upper case. They are bigger and have another appearance.
When I open the font using Fontforge they are visible. But they have the same Unicode, but another hex- (0x1011a-0x10123) and int-Value (65818 until 65827).
In an PDF-Example from InDesign the text "29" with this glyphs has the following PDF-Code:
BT
/C2_0 1 Tf
0 Tw 42.5815 0 0 42.5815 865.3147 1343.9668 Tm
<031C0323>Tj
ET
031C means 2
0323 means 9
The Font has following codes:
12 dict begin
begincmap
/CIDSystemInfo
<< /Registry (Adobe)
/Ordering (UCS) /Supplement 0 >> def
/CMapName /Adobe-Identity-UCS def
/CMapType 2 def
1 begincodespacerange
<0000> <FFFF>
endcodespacerange
2 beginbfchar
<031C> <0032>
<0323> <0039>
endbfchar
endcmap CMapName currentdict /CMap defineresource pop end end
endstream
endobj
How can I do this with PDF-Box?
Thanks in advance
Gerhard Hiller
mailto:gerhard.hiller@msh.de | Phone: +49 711 72007 4163 | Mobile: +49 172 718 48 46
- -
[MSH-Logo]
MSH Medien System Haus GmbH & Co. KG, Stuttgart, HRA 9274 Stuttgart
P.h.G.: MSH Medien System Haus Verwaltungsges. MbH, Stuttgart, HRB 4443 Stuttgart
Re: Font-Handling
Posted by Tilman Hausherr <TH...@t-online.de>.
Not out of the box if it doesn't have a separate unicode. (In DTL
OTMaster they had none, and 31c and 323 were there GID number)
It's probably easier to modify the font for that purpose. Or to use a
larger font size.
Tilman
Am 06.05.2021 um 20:33 schrieb Hiller, Gerhard:
>
> Hi everybody,
>
> I try to use a TrueTypeFont
> https://fonts.google.com/specimen/Playfair+Display
> <https://fonts.google.com/specimen/Playfair+Display> with its
> embedded “Upper Case Numbers”.
>
> The font includes “normal” numbers from Unicode +0030 until +0039.
>
> Additionally there are Numbers which can be used in InDesign as upper
> case. They are bigger and have another appearance.
>
> When I open the font using Fontforge they are visible. But they have
> the same Unicode, but another hex- (0x1011a-0x10123) and int-Value
> (65818 until 65827).
>
> In an PDF-Example from InDesign the text “29” with this glyphs has the
> following PDF-Code:
>
> BT
>
> /C2_0 1 Tf
>
> 0 Tw 42.5815 0 0 42.5815 865.3147 1343.9668 Tm
>
> <031C0323>Tj
>
> ET
>
> 031C means 2
>
> 0323 means 9
>
> The Font has following codes:
>
> 12 dict begin
>
> begincmap
>
> /CIDSystemInfo
>
> << /Registry (Adobe)
>
> /Ordering (UCS) /Supplement 0 >> def
>
> /CMapName /Adobe-Identity-UCS def
>
> /CMapType 2 def
>
> 1 begincodespacerange
>
> <0000> <FFFF>
>
> endcodespacerange
>
> 2 beginbfchar
>
> <031C> <0032>
>
> <0323> <0039>
>
> endbfchar
>
> endcmap CMapName currentdict /CMap defineresource pop end end
>
> endstream
>
> endobj
>
> How can I do this with PDF-Box?
>
> Thanks in advance
>
> Gerhard Hiller
> mailto:gerhard.hiller@msh.de <ma...@msh.de> | Phone:
> +49 711 72007 4163 | Mobile: +49 172 718 48 46
> - -
> MSH-Logo
> MSH Medien System Haus GmbH & Co. KG, Stuttgart, HRA 9274 Stuttgart
> P.h.G.: MSH Medien System Haus Verwaltungsges. MbH, Stuttgart, HRB
> 4443 Stuttgart
>
Re: Font-Handling
Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,
There was a response but obviously yours is perfect. You're great, I
tried it and it works. It's similar to the "vertical" feature.
Tilman
PDDocument doc = new PDDocument();
InputStream is1 = new
FileInputStream("PlayfairDisplay-VariableFont_wght.ttf");
TrueTypeFont ttf1 = new TTFParser().parse(is1);
ttf1.enableGsubFeature("lnum");
InputStream is2 = new
FileInputStream("PlayfairDisplay-VariableFont_wght.ttf");
TrueTypeFont ttf2 = new TTFParser().parse(is2);
PDPage page = new PDPage();
doc.addPage(page);
PDPageContentStream cs = new PDPageContentStream(doc, page);
PDFont font1 = PDType0Font.load(doc, ttf1, true);
PDFont font2 = PDType0Font.load(doc, ttf2, true);
cs.setFont(font1, 25);
cs.beginText();
cs.newLineAtOffset(50, 700);
cs.showText("1234567890");
cs.endText();
cs.setFont(font2, 25);
cs.beginText();
cs.newLineAtOffset(50, 650);
cs.showText("1234567890");
cs.endText();
cs.close();
doc.save("PlayfairDisplay.pdf");
doc.close();
Am 11.05.2021 um 07:31 schrieb Hiller, Gerhard:
> Hi everybody,
>
> I got no response but figured it out. You have to load the TrueTypeFont and then you need to call enableGsubFeature("lnum").
>
> TrueTypeFont ttf = new TTFParser().parse(is);
> ttf.enableGsubFeature("lnum);
>
> Maybe this answer helps somone out.
>
> Greetings from Germany
>
> Gerhard Hiller
>
> Von: Hiller, Gerhard <Ge...@msh.de>
> Gesendet: Donnerstag, 6. Mai 2021 20:33
> An: users@pdfbox.apache.org
> Betreff: Font-Handling
>
> Hi everybody,
>
> I try to use a TrueTypeFont https://fonts.google.com/specimen/Playfair+Display with its embedded "Upper Case Numbers".
>
> The font includes "normal" numbers from Unicode +0030 until +0039.
>
> Additionally there are Numbers which can be used in InDesign as upper case. They are bigger and have another appearance.
>
> When I open the font using Fontforge they are visible. But they have the same Unicode, but another hex- (0x1011a-0x10123) and int-Value (65818 until 65827).
>
> In an PDF-Example from InDesign the text "29" with this glyphs has the following PDF-Code:
>
> BT
> /C2_0 1 Tf
> 0 Tw 42.5815 0 0 42.5815 865.3147 1343.9668 Tm
> <031C0323>Tj
> ET
>
> 031C means 2
> 0323 means 9
>
> The Font has following codes:
>
> 12 dict begin
> begincmap
> /CIDSystemInfo
> << /Registry (Adobe)
> /Ordering (UCS) /Supplement 0 >> def
> /CMapName /Adobe-Identity-UCS def
> /CMapType 2 def
> 1 begincodespacerange
> <0000> <FFFF>
> endcodespacerange
> 2 beginbfchar
> <031C> <0032>
> <0323> <0039>
> endbfchar
> endcmap CMapName currentdict /CMap defineresource pop end end
>
> endstream
> endobj
>
>
> How can I do this with PDF-Box?
>
> Thanks in advance
> Gerhard Hiller
> mailto:gerhard.hiller@msh.de | Phone: +49 711 72007 4163 | Mobile: +49 172 718 48 46
> - -
> [MSH-Logo]
> MSH Medien System Haus GmbH & Co. KG, Stuttgart, HRA 9274 Stuttgart
> P.h.G.: MSH Medien System Haus Verwaltungsges. MbH, Stuttgart, HRB 4443 Stuttgart
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
AW: Font-Handling
Posted by "Hiller, Gerhard" <Ge...@msh.de>.
Hi everybody,
I got no response but figured it out. You have to load the TrueTypeFont and then you need to call enableGsubFeature("lnum").
TrueTypeFont ttf = new TTFParser().parse(is);
ttf.enableGsubFeature("lnum);
Maybe this answer helps somone out.
Greetings from Germany
Gerhard Hiller
Von: Hiller, Gerhard <Ge...@msh.de>
Gesendet: Donnerstag, 6. Mai 2021 20:33
An: users@pdfbox.apache.org
Betreff: Font-Handling
Hi everybody,
I try to use a TrueTypeFont https://fonts.google.com/specimen/Playfair+Display with its embedded "Upper Case Numbers".
The font includes "normal" numbers from Unicode +0030 until +0039.
Additionally there are Numbers which can be used in InDesign as upper case. They are bigger and have another appearance.
When I open the font using Fontforge they are visible. But they have the same Unicode, but another hex- (0x1011a-0x10123) and int-Value (65818 until 65827).
In an PDF-Example from InDesign the text "29" with this glyphs has the following PDF-Code:
BT
/C2_0 1 Tf
0 Tw 42.5815 0 0 42.5815 865.3147 1343.9668 Tm
<031C0323>Tj
ET
031C means 2
0323 means 9
The Font has following codes:
12 dict begin
begincmap
/CIDSystemInfo
<< /Registry (Adobe)
/Ordering (UCS) /Supplement 0 >> def
/CMapName /Adobe-Identity-UCS def
/CMapType 2 def
1 begincodespacerange
<0000> <FFFF>
endcodespacerange
2 beginbfchar
<031C> <0032>
<0323> <0039>
endbfchar
endcmap CMapName currentdict /CMap defineresource pop end end
endstream
endobj
How can I do this with PDF-Box?
Thanks in advance
Gerhard Hiller
mailto:gerhard.hiller@msh.de | Phone: +49 711 72007 4163 | Mobile: +49 172 718 48 46
- -
[MSH-Logo]
MSH Medien System Haus GmbH & Co. KG, Stuttgart, HRA 9274 Stuttgart
P.h.G.: MSH Medien System Haus Verwaltungsges. MbH, Stuttgart, HRB 4443 Stuttgart