RE: Font names using multi-byte strings
Joao Andre Goncalves <[email protected]> Thu, 29 Jan 2026 21:48:19 +0000
| Newsgroups | gmane.text.xml.fop.user |
|---|---|
| Message-ID | <AS8PR04MB79426BF97A08768F720E4A6ADD9EA@AS8PR04MB7942.eurprd04.prod.outlook.com> |
--_000_AS8PR04MB79426BF97A08768F720E4A6ADD9EAAS8PR04MB7942eurp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks, your suggestion seems to work. I'll had some unit tests and get in merge in= the next couple of days. From: Luca Bellonda <[email protected]> Sent: 29 January 2026 13:53 To: [email protected] Subject: Re: Font names using multi-byte strings You don't often get email from [email protected]<mailto:[email protected]= om>. Learn why this is important<https://aka.ms/LearnAboutSenderIdentificat= ion> I was able to get the same name and I suggest this method: 1- Translate the string to UTF-8 bytes representation. 2- Get the bytes and encode them instead of characters. This way the UTF-8 statement should be respected. In code (beware: not efficient and without error management): in escapeName of PDFName: byte[] characters ; // get UTF-8 bytes try { characters =3D name.substring((skipFirst ? 1 : 0)).getBytes("UTF-8"= ); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Invalid Name:"+name); } // encode bytes for (int i =3D 0, c =3D characters.length; i < c; i++) { int ch =3D (0x00FF&characters[i]); if (ch < 33 || ch > 126 || ESCAPED_NAME_CHARS.indexOf(ch) >=3D = 0) { sb.append('#'); toHex(ch, sb); } else { char cxc =3D (char)ch ; sb.append(cxc); } } return sb.toString(); where toHex() manages an int Best regards. Il giorno gio 29 gen 2026 alle ore 01:28 Joao Andre Goncalves <JGoncalves@s= martcommunications.com<mailto:[email protected]>> ha scrit= to: I tried that earlier but while the PDF is valid, the font name would not ma= tch the original PDF. I did find the following on the ISO document: c) Any character that is not a regular character shall be written using its= 2-digit hexadecimal code, preceded by the NUMBER SIGN only. ________________________________ Joao Andre Goncalves Customer Developer t | m 07733161880 [email protected] smartcommunications.com<https://www.smartcommunications.com/> [https://www.smartcommunications.com/wp-content/uploads/025_Trends2026-450x= 160_v1.jpg]<https://scale.smartcommunications.com/2026-Trends-White-Paper.h= tml?utm_source=3Doutlook&utm_medium=3Demail&utm_campaign=3Dwc-global-2026-w= hite-paper-2026-trends> Explore the new era of AI-powered customer engagement. Get your copy of the= 2026 Trends Report now.<https://scale.smartcommunications.com/2026-Trends-= White-Paper.html?utm_source=3Doutlook&utm_medium=3Demail&utm_campaign=3Dwc-= global-2026-white-paper-2026-trends> Smart Communications is a trading name= of SmartComms SC Limited which is registered in England under No. 4303041 = whose registered office is at Suite 23, LCLB, 95 Mortimer Street, London, W= 1W 7GB. Please consider the environment before printing. The contents of th= is e-mail are intended for the named addressee only. It contains confidenti= al information. Unless you are the named addressee or an authorized designe= e, you may not copy or use it, or disclose it to anyone else. If you receiv= ed it in error please notify us immediately and then destroy it. Smart Comm= unications will process your data as described in the Smart Communications'= External Privacy Policy.<https://www.smartcommunications.com/external-priv= acy-policy/> Follow us on LinkedIn,<https://www.linkedin.com/company/15166060/admin/> Yo= uTube,<https://www.youtube.com/@Smart_Communications/> and X.<https://x.com= /ccminnovators?lang=3Den> --_000_AS8PR04MB79426BF97A08768F720E4A6ADD9EAAS8PR04MB7942eurp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable <html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr= osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" = xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:= //www.w3.org/TR/REC-html40"> <head> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"= > <meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)"> <style><!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} @font-face {font-family:Aptos;} @font-face {font-family:"Segoe UI"; panose-1:2 11 5 2 4 2 4 2 2 3;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; font-size:12.0pt; font-family:"Aptos",sans-serif;} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} span.EmailStyle19 {mso-style-type:personal-reply; font-family:"Aptos",sans-serif; color:windowtext;} .MsoChpDefault {mso-style-type:export-only; font-size:10.0pt; mso-ligatures:none;} @page WordSection1 {size:612.0pt 792.0pt; margin:72.0pt 72.0pt 72.0pt 72.0pt;} div.WordSection1 {page:WordSection1;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext=3D"edit"> <o:idmap v:ext=3D"edit" data=3D"1" /> </o:shapelayout></xml><![endif]--> </head> <body lang=3D"EN-GB" link=3D"blue" vlink=3D"purple" style=3D"word-wrap:brea= k-word"> <div class=3D"WordSection1"> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;mso-fareast-language= :EN-US">Thanks, <br> <br> your suggestion seems to work. I’ll had some unit tests and get in me= rge in the next couple of days.<br> <br> <br> <br> <o:p></o:p></span></p> <p class=3D"MsoNormal"><span style=3D"font-size:11.0pt;mso-fareast-language= :EN-US"><o:p> </o:p></span></p> <div> <div style=3D"border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm = 0cm 0cm"> <p class=3D"MsoNormal"><b><span lang=3D"EN-US" style=3D"font-size:11.0pt;fo= nt-family:"Calibri",sans-serif">From:</span></b><span lang=3D"EN-= US" style=3D"font-size:11.0pt;font-family:"Calibri",sans-serif"> = Luca Bellonda <[email protected]> <br> <b>Sent:</b> 29 January 2026 13:53<br> <b>To:</b> [email protected]<br> <b>Subject:</b> Re: Font names using multi-byte strings<o:p></o:p></span></= p> </div> </div> <p class=3D"MsoNormal"><o:p> </o:p></p> <table class=3D"MsoNormalTable" border=3D"0" cellspacing=3D"0" cellpadding= =3D"0" align=3D"left" width=3D"100%" style=3D"width:100.0%"> <tbody> <tr> <td width=3D"0" style=3D"width:.3pt;background:#A6A6A6;padding:5.25pt 1.5pt= 5.25pt 1.5pt"> </td> <td width=3D"100%" style=3D"width:100.0%;background:#EAEAEA;padding:5.25pt = 3.75pt 5.25pt 11.25pt;aspect-ratio: revert !important;background:revert !im= portant;block-size: revert !important;border:revert !important;bottom: reve= rt !important;color:revert !important;color-scheme: revert !important;conte= nt-visibility: revert !important;cursor:revert !important;direction:revert = !important;display:revert !important;font-size:revert !important;height:rev= ert !important;hyphens: revert !important;letter-spacing:revert !important;= line-height:revert !important;margin:revert !important;opacity: revert !imp= ortant;order: revert !important;outline: revert !important;overflow:revert = !important;padding:revert !important;position:revert !important;resize: rev= ert !important;rotate: revert !important;scale: revert !important;tab-size:= revert !important;table-layout:revert !important;text-align:revert !import= ant;text-indent:revert !important;text-orientation: revert !important;text-= overflow: revert !important;text-shadow:revert !important;text-transform:re= vert !important;text-wrap: revert !important;top:revert !important;transiti= on: revert !important;user-select: revert !important;vertical-align:revert = !important;visibility:revert !important;white-space:revert !important;width= :revert !important;word-break:revert !important;word-spacing:revert !import= ant;writing-mode:revert !important;zoom: revert !important"> <div> <p class=3D"MsoNormal" style=3D"mso-element:frame;mso-element-frame-hspace:= 2.25pt;mso-element-wrap:around;mso-element-anchor-vertical:paragraph;mso-el= ement-anchor-horizontal:column;mso-height-rule:exactly"> <span style=3D"font-size:9.0pt;font-family:"Segoe UI",sans-serif;= color:#212121">You don't often get email from <a href=3D"mailto:[email protected]">[email protected]</a>. <a href=3D"= https://aka.ms/LearnAboutSenderIdentification"> Learn why this is important</a> <o:p></o:p></span></p> </div> </td> <td width=3D"75" style=3D"width:56.25pt;background:#EAEAEA;padding:5.25pt 3= .75pt 5.25pt 3.75pt;aspect-ratio: revert !important;background:revert !impo= rtant;block-size: revert !important;border:revert !important;bottom: revert= !important;color:revert !important;color-scheme: revert !important;content= -visibility: revert !important;cursor:revert !important;direction:revert !i= mportant;display:revert !important;font-size:revert !important;height:rever= t !important;hyphens: revert !important;letter-spacing:revert !important;li= ne-height:revert !important;margin:revert !important;opacity: revert !impor= tant;order: revert !important;outline: revert !important;overflow:revert !i= mportant;padding:revert !important;position:revert !important;resize: rever= t !important;rotate: revert !important;scale: revert !important;tab-size: r= evert !important;table-layout:revert !important;text-align:revert !importan= t;text-indent:revert !important;text-orientation: revert !important;text-ov= erflow: revert !important;text-shadow:revert !important;text-transform:reve= rt !important;text-wrap: revert !important;top:revert !important;transition= : revert !important;user-select: revert !important;vertical-align:revert !i= mportant;visibility:revert !important;white-space:revert !important;width:r= evert !important;word-break:revert !important;word-spacing:revert !importan= t;writing-mode:revert !important;zoom: revert !important;align: left !impor= tant"> </td> </tr> </tbody> </table> <div> <div> <div> <p class=3D"MsoNormal">I was able to get the same name and I suggest this m= ethod:<o:p></o:p></p> </div> <div> <p class=3D"MsoNormal">1- Translate the string to UTF-8 bytes representatio= n.<o:p></o:p></p> </div> <div> <p class=3D"MsoNormal">2- Get the bytes and encode them instead of characte= rs.<o:p></o:p></p> </div> <div> <p class=3D"MsoNormal"><o:p> </o:p></p> </div> <div> <p class=3D"MsoNormal">This way the UTF-8 statement should be respected.<o:= p></o:p></p> </div> <div> <p class=3D"MsoNormal">In code (beware: not efficient and without error man= agement):<o:p></o:p></p> </div> <div> <p class=3D"MsoNormal"><o:p> </o:p></p> </div> <div> <p class=3D"MsoNormal">in escapeName of PDFName:<o:p></o:p></p> </div> <div> <p class=3D"MsoNormal"><o:p> </o:p></p> </div> <div> <p class=3D"MsoNormal"> byte[] characters ;<o:p></o:p></p> </div> <div> <p class=3D"MsoNormal"> // get UTF-8 bytes<o:p></o:p></p> </div> <div> <p class=3D"MsoNormal" style=3D"margin-bottom:12.0pt"> try {<br= > characters =3D name.substring((skipFirst ? 1 : = 0)).getBytes("UTF-8");<br> } catch (UnsupportedEncodingException e) {<br> throw new RuntimeException("Invalid= Name:"+name);<br> }<o:p></o:p></p> </div> <div> <p class=3D"MsoNormal">// encode bytes<o:p></o:p></p> </div> <div> <p class=3D"MsoNormal"> for (int i =3D 0, c =3D = characters.length; i < c; i++) {<br> int ch =3D (0x00FF&characters[i]);<br> <br> if (ch < 33 || ch > 126 || = ESCAPED_NAME_CHARS.indexOf(ch) >=3D 0) {<br> sb.append('#');<br> toHex(ch, sb);<br> } else {<br> char cxc =3D (char)ch ;<br> sb.append(cxc);<br> }<br> }<br> return sb.toString();<o:p></o:p></p> </div> <div> <p class=3D"MsoNormal"><o:p> </o:p></p> </div> <div> <p class=3D"MsoNormal">where toHex() manages an int<o:p></o:p></p> </div> <div> <p class=3D"MsoNormal"><o:p> </o:p></p> </div> <div> <p class=3D"MsoNormal">Best regards.<o:p></o:p></p> </div> <p class=3D"MsoNormal"><o:p> </o:p></p> <div> <div> <p class=3D"MsoNormal">Il giorno gio 29 gen 2026 alle ore 01:28 Joao Andre = Goncalves <<a href=3D"mailto:[email protected]">JGoncal= [email protected]</a>> ha scritto:<o:p></o:p></p> </div> <blockquote style=3D"border:none;border-left:solid #CCCCCC 1.0pt;padding:0c= m 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm"> <div> <div> <div> <p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;margin-bottom:12.0p= t"><span style=3D"font-size:11.0pt">I tried that earlier but while the PDF = is valid, the font name would not match the original PDF. I did find the fo= llowing on the ISO document:</span><o:p></o:p></p> <p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;margin-bottom:12.0p= t;margin-left:36.0pt"> <span style=3D"font-size:11.0pt">c) Any character that is not a regular cha= racter shall be written using its 2-digit hexadecimal code, preceded by the= NUMBER SIGN only. </span><o:p></o:p></p> <p class=3D"MsoNormal" style=3D"mso-margin-top-alt:auto;mso-margin-bottom-a= lt:auto"><o:p> </o:p></p> </div> </div> </div> </blockquote> </div> </div> </div> </div> <style type=3D"text/css">=0A= a:link {color:#20407f;text-decoration:none;}=0A= a:visited {color:#20407f;text-decoration:none;}=0A= </style> <table style=3D"width:400px"> <tbody> <tr> <td colspan=3D"2"> <hr size=3D"4" color=3D"fec432" width=3D"30%" align=3D"left"> </td> </tr> <tr> <td width=3D"65%" ;=3D"" style=3D"FONT-FAMILY: Arial Black; COLOR: #20407f;= FONT-SIZE: 11px"> Joao Andre Goncalves<br> Customer Developer<br> <br> </td> </tr> <tr> <td style=3D"FONT-FAMILY: Arial; COLOR: #20407f; FONT-SIZE: 9px">t | m 0773= 3161880<br> [email protected]<br> <a href=3D"https://www.smartcommunications.com/">smartcommunications.com</a= ><br> <br> </td> </tr> </tbody> </table> <table style=3D"width:400px"> <tbody> <tr> <td width=3D"100%" ;=3D"" colspan=3D"2"><a href=3D"https://scale.smartcommu= nications.com/2026-Trends-White-Paper.html?utm_source=3Doutlook&utm_med= ium=3Demail&utm_campaign=3Dwc-global-2026-white-paper-2026-trends"><img= src=3D"https://www.smartcommunications.com/wp-content/uploads/025_Trends20= 26-450x160_v1.jpg " width=3D"" 450=3D"" height=3D"160"></a><br> <br> </td> </tr> <tr> <td width=3D"28%" ;=3D"" style=3D"FONT-FAMILY: Arial Black; COLOR: #20407f;= FONT-SIZE: 10px"> <a href=3D"https://scale.smartcommunications.com/2026-Trends-White-Paper.ht= ml?utm_source=3Doutlook&utm_medium=3Demail&utm_campaign=3Dwc-global= -2026-white-paper-2026-trends">Explore the new era of AI-powered customer e= ngagement. Get your copy of the 2026 Trends Report now.</a></td> <td width=3D"72%" ;=3D"" style=3D"FONT-FAMILY: Arial; COLOR: #939597; line-= height: 13px; FONT-SIZE: 9px"> Smart Communications is a trading name of SmartComms SC Limited which is re= gistered in England under No. 4303041 whose registered office is at Suite 2= 3, LCLB, 95 Mortimer Street, London, W1W 7GB. Please consider the environme= nt before printing. The contents of this e-mail are intended for the named addressee only. It contains conf= idential information. Unless you are the named addressee or an authorized d= esignee, you may not copy or use it, or disclose it to anyone else. If you = received it in error please notify us immediately and then destroy it. Smart Communications will process your= data as described in the Smart Communications' <a href=3D"https://www.smartcommunications.com/external-privacy-policy/">Ex= ternal Privacy Policy.</a></td> </tr> <tr> <td width=3D"100%" ;=3D"" colspan=3D"2" style=3D"FONT-FAMILY: Arial Black; = COLOR: #20407f; FONT-SIZE: 10px"> <br> Follow us on <a href=3D"https://www.linkedin.com/company/15166060/admin/">L= inkedIn,</a> <a href=3D"https://www.youtube.com/@Smart_Communications/">YouTube,</a> and= <a href=3D"https://x.com/ccminnovators?lang=3Den"> X.</a></td> </tr> </tbody> </table> </body> </html> --_000_AS8PR04MB79426BF97A08768F720E4A6ADD9EAAS8PR04MB7942eurp_--