[ 
https://issues.apache.org/jira/browse/PDFBOX-2945?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15032019#comment-15032019
 ] 

Philip Helger edited comment on PDFBOX-2945 at 11/30/15 4:15 PM:
-----------------------------------------------------------------

There is an invalid implementation in 2.0.0-rc2, class UniUtil:

{code}
           case 1:
                return "uni0" + hex;
            case 2:
                return "uni00" + hex;
            case 3:
                return "uni000" + hex;
            default:
                return "uni" + hex;
{code}

It should be
{code}
           case 1:
                return "uni000" + hex;
            case 2:
                return "uni00" + hex;
            case 3:
                return "uni0" + hex;
            default:
                return "uni" + hex;
{code}
Thx.


was (Author: phax):
There is an invalid implementation in 2.0.0-rc2, class UniUtil:

           case 1:
                return "uni0" + hex;
            case 2:
                return "uni00" + hex;
            case 3:
                return "uni000" + hex;
            default:
                return "uni" + hex;

It should be
           case 1:
                return "uni000" + hex;
            case 2:
                return "uni00" + hex;
            case 3:
                return "uni0" + hex;
            default:
                return "uni" + hex;

Thx.

> PDType1Font.getNameInFont(String) very slow when Unicode fallback is used
> -------------------------------------------------------------------------
>
>                 Key: PDFBOX-2945
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2945
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: PDModel
>    Affects Versions: 2.0.0
>         Environment: Windows 10, Pdfbox SNAPSHOT as of revision 1697721 from 
> today, Java 1.7.0_76, 64Bit
>            Reporter: Philip Helger
>            Assignee: Tilman Hausherr
>             Fix For: 2.0.0
>
>         Attachments: pdfbox2945.patch
>
>
> When the method is called on a non-embedded font and the unicode fallback is 
> used, the line "String uniName = String.format("uni%04X", 
> unicodes.codePointAt(0));" is called and it is very slow. I suggest either 
> adding a cache (codepoint to uniname) or at least replace the String.format 
> call with something different, as this internally invokes a new RegExp 
> Matcher etc.
> Something like the following might do the trick (maybe you have a better 
> utility classes):
> {code}
>         final StringBuilder aID = new StringBuilder (Integer.toString 
> (unicodes.codePointAt (0), 16).toUpperCase (Locale.US));
>         while (aID.length () < 4)
>              aID.insert (0, '0');
>         aID.insert (0, "uni");
>         final String uniName = aID.toString ();
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to