]> _ Git - cubist_pdf.git/commitdiff
wait #6252 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 17 Oct 2023 12:36:05 +0000 (14:36 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 17 Oct 2023 12:36:05 +0000 (14:36 +0200)
resources/tools/fwstk/.idea/deployment.xml
resources/tools/fwstk/.idea/workspace.xml
resources/tools/fwstk/bin/com/fluidbook/fwstk/layout/LayoutStripper.class
resources/tools/fwstk/bin/com/fluidbook/fwstk/layout/Page.class
resources/tools/fwstk/bin/com/fluidbook/fwstk/layout/Word.class
resources/tools/fwstk/out/artifacts/fwstk_jar/fwstk.jar
resources/tools/fwstk/src/com/fluidbook/fwstk/layout/LayoutStripper.java
resources/tools/fwstk/src/com/fluidbook/fwstk/layout/Page.java
resources/tools/fwstk/src/com/fluidbook/fwstk/layout/Word.java

index 574024daf10ea6e2ba885087091122c745d0160d..df7b0e38978eab4305cb268b4fa13c1306d0966e 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
-  <component name="PublishConfigData" autoUpload="Always" serverName="toolbox.fluidbook.com" confirmBeforeUploading="false" autoUploadExternalChanges="true">
+  <component name="PublishConfigData" autoUpload="Always" serverName="toolbox.fluidbook.com" remoteFilesAllowedToDisappearOnAutoupload="false" confirmBeforeUploading="false" confirmBeforeDeletion="false" autoUploadExternalChanges="true">
+    <option name="confirmBeforeDeletion" value="false" />
     <option name="confirmBeforeUploading" value="false" />
     <serverData>
       <paths name="alphaville.cubedesigners.com">
index 538d07869770f9ac1a14d3f13b193ff1e8f17dcc..466fcb6ea2e0308f8a053f42f1ece23b7cc1c0a4 100644 (file)
     <configuration name="extract layout" type="Application" factoryName="Application">
       <option name="MAIN_CLASS_NAME" value="com.fluidbook.fwstk.Main" />
       <module name="fwstk" />
-      <option name="PROGRAM_PARAMETERS" value="--input C:\Users\vince\Desktop\20929.pdf --mode robust --layout C:\Users\vince\Desktop\20929\p%d.fby --threads 1" />
+      <option name="PROGRAM_PARAMETERS" value="--input C:\Users\vince\Desktop\test.pdf --mode robust --layout C:\Users\vince\Desktop\test\p%d.fby --threads 1" />
       <method v="2">
         <option name="Make" enabled="true" />
       </method>
       <workItem from="1694674242867" duration="1038000" />
       <workItem from="1694683468326" duration="1387000" />
       <workItem from="1694699117438" duration="618000" />
+      <workItem from="1697471786856" duration="382000" />
+      <workItem from="1697543960076" duration="2149000" />
     </task>
     <task id="LOCAL-00001" summary="wip #1111 @0.5">
       <created>1487172253077</created>
index 12ba9c479678dc0f8720605ceabbfdf42ae309d4..7cb76994710f475f1e3c5571a85e3d3bbbc4b174 100644 (file)
Binary files a/resources/tools/fwstk/bin/com/fluidbook/fwstk/layout/LayoutStripper.class and b/resources/tools/fwstk/bin/com/fluidbook/fwstk/layout/LayoutStripper.class differ
index 9a8c8187ade3c3856f315c4cccdd020dfa1d0c64..49dbecde6516c846adc2938293b2863c1bf79fad 100644 (file)
Binary files a/resources/tools/fwstk/bin/com/fluidbook/fwstk/layout/Page.class and b/resources/tools/fwstk/bin/com/fluidbook/fwstk/layout/Page.class differ
index b20cebd26dd496fdc90675ce3ad6f239fb8b752c..9d512c95ebbf4c654eb18dfa87ee9455466e185c 100644 (file)
Binary files a/resources/tools/fwstk/bin/com/fluidbook/fwstk/layout/Word.class and b/resources/tools/fwstk/bin/com/fluidbook/fwstk/layout/Word.class differ
index f15916521b12eb645a6239053a0e8e554b390957..6fe8dd5c13017babfe42a20ea73a4cd210f5350e 100644 (file)
Binary files a/resources/tools/fwstk/out/artifacts/fwstk_jar/fwstk.jar and b/resources/tools/fwstk/out/artifacts/fwstk_jar/fwstk.jar differ
index df7096459527140aeae25fc2b3b90ffe7e7fd5f7..5374acec2d834db9c9740f292dd3812404d1cfe8 100644 (file)
@@ -39,7 +39,7 @@ public class LayoutStripper extends PDFStreamEngine {
         this.resetEngine();
 
         this.currentPage = page;
-        layout = new Page(currentPage, i,this.splitAllChars, this.ignoredSeparators);
+        layout = new Page(currentPage, i, this.splitAllChars, this.ignoredSeparators);
 
         PDResources resources = currentPage.findResources();
         PDStream contents = null;
@@ -65,7 +65,7 @@ public class LayoutStripper extends PDFStreamEngine {
             return;
         }
         try {
-            layout.addText(gs, getTextLineMatrix(), getTextMatrix(), text, c);
+            layout.addText(gs, getTextLineMatrix(), getTextMatrix(), text, c, true);
         } catch (IOException ex) {
             ex.printStackTrace();
         }
index c458d3e91016bd7d8250409f9ad19cf7808db657..556939efd47f6ed8fe26cfaa1afbc041e049e7e0 100644 (file)
@@ -52,7 +52,7 @@ public class Page extends LayoutElement {
         this.lines = new LinkedList<>();
     }
 
-    public void addText(PDGraphicsState gs, Matrix textLineMatrix, Matrix textMatrix, TextPosition textPosition, String text) throws IOException {
+    public void addText(PDGraphicsState gs, Matrix textLineMatrix, Matrix textMatrix, TextPosition textPosition, String text, boolean splitLigatures) throws IOException {
         PDTextState ts = gs.getTextState();
         float rotation = new CubeMatrix(textLineMatrix).getRotation();
         float size = textPosition.getFontSize() * textMatrix.getXScale();
@@ -80,7 +80,44 @@ public class Page extends LayoutElement {
         lineScaleY /= minScale;
 
         Line line = getLine(y, rotation, lineScaleX, lineScaleY);
-        line.addText(size, x, y, width, height, text, spaceWidth);
+        if ( splitLigatures && text.length() > 1) {
+            if (isRtl(text)) {
+                for (int i = 0; i < text.length(); i++) {
+                    line.addText(size, x, y, width, height, text.substring(i, i+1), spaceWidth);
+                }
+            } else {
+                for (int i = 0; i < text.length(); i++) {
+                    line.addText(size, x, y, width, height, text.substring(i, i + 1), spaceWidth);
+                }
+            }
+        } else {
+            line.addText(size, x, y, width, height, text, spaceWidth);
+        }
+    }
+
+    public static boolean isRtl(String string) {
+        if (string == null) {
+            return false;
+        }
+
+        for (int i = 0, n = string.length(); i < n; ++i) {
+            byte d = Character.getDirectionality(string.charAt(i));
+
+            switch (d) {
+                case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
+                case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
+                case Character.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING:
+                case Character.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE:
+                    return true;
+
+                case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
+                case Character.DIRECTIONALITY_LEFT_TO_RIGHT_EMBEDDING:
+                case Character.DIRECTIONALITY_LEFT_TO_RIGHT_OVERRIDE:
+                    return false;
+            }
+        }
+
+        return false;
     }
 
     public String asJSON() {
@@ -125,7 +162,7 @@ public class Page extends LayoutElement {
 
     protected Line getLine(float y, float rotation, float scaleX, float scaleY) {
         if (lines.size() == 0 || !lines.getLast().equals(y, rotation, scaleX, scaleY)) {
-            Line newLine = new Line(y, rotation, scaleX, scaleY,splitAllChars, ignoredSeparators);
+            Line newLine = new Line(y, rotation, scaleX, scaleY, splitAllChars, ignoredSeparators);
             lines.add(newLine);
             return newLine;
         }
index e4e92cf299cf4a606900f0bca83889c2b2567260..05014af45b0a4f6427efd261802ffcb227b2d103 100644 (file)
@@ -72,6 +72,7 @@ public class Word extends LayoutElement {
         return word;
     }
 
+
     public String asText(PDRectangle cropbox) {
         if (startX() > cropbox.getWidth()) {
             return "";