You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2018/08/30 16:27:49 UTC
svn commit: r1839689 -
/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ToUnicodeWriter.java
Author: tilman
Date: Thu Aug 30 16:27:49 2018
New Revision: 1839689
URL: http://svn.apache.org/viewvc?rev=1839689&view=rev
Log:
PDFBOX-4302: introduce constant for upcoming test
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ToUnicodeWriter.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ToUnicodeWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ToUnicodeWriter.java?rev=1839689&r1=1839688&r2=1839689&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ToUnicodeWriter.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/ToUnicodeWriter.java Thu Aug 30 16:27:49 2018
@@ -39,6 +39,11 @@ final class ToUnicodeWriter
private int wMode;
/**
+ * To test corner case of PDFBOX-4302.
+ */
+ static final int MAX_ENTRIES_PER_OPERATOR = 100;
+
+ /**
* Creates a new ToUnicode CMap writer.
*/
ToUnicodeWriter()
@@ -145,15 +150,18 @@ final class ToUnicodeWriter
dstPrev = text;
}
- // limit of 100 entries per operator
- int batchCount = (int)Math.ceil(srcFrom.size() / 100.0);
+ // limit entries per operator
+ int batchCount = (int) Math.ceil(srcFrom.size() /
+ (double) MAX_ENTRIES_PER_OPERATOR);
for (int batch = 0; batch < batchCount; batch++)
{
- int count = batch == batchCount - 1 ? srcFrom.size() - 100 * batch : 100;
+ int count = batch == batchCount - 1 ?
+ srcFrom.size() - MAX_ENTRIES_PER_OPERATOR * batch :
+ MAX_ENTRIES_PER_OPERATOR;
writer.write(count + " beginbfrange\n");
for (int j = 0; j < count; j++)
{
- int index = batch * 100 + j;
+ int index = batch * MAX_ENTRIES_PER_OPERATOR + j;
writer.write('<');
writer.write(Hex.getChars(srcFrom.get(index).shortValue()));
writer.write("> ");