]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sun, 11 Sep 2011 17:43:47 +0000 (17:43 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sun, 11 Sep 2011 17:43:47 +0000 (17:43 +0000)
17 files changed:
fluidbook/compile/_js/fluidbook.js
fluidbook/compile/index.html
fluidbook/tools/convert.pe
fluidbook/tools/fwstk/nbproject/build-impl.xml
fluidbook/tools/fwstk/nbproject/genfiles.properties
fluidbook/tools/fwstk/nbproject/private/private.xml
fluidbook/tools/fwstk/nbproject/project.properties
fluidbook/tools/fwstk/nbproject/project.xml
fluidbook/tools/fwstk/src/org/apache/pdfbox/pdmodel/font/PDType0Font.java [new file with mode: 0644]
fluidbook/tools/fwstk/src/org/apache/pdfbox/util/PDFStreamEngine.java
fluidbook/tools/fwstk/src/org/apache/pdfbox/util/operator/ShowText.java
fluidbook/tools/fwstk/src/org/apache/pdfbox/util/operator/ShowTextGlyph.java
inc/ws/DAO/class.ws.dao.book.php
inc/ws/Metier/class.ws.book.parametres.php
inc/ws/Util/class.ws.pdf.fontextractor.php
inc/ws/Util/html5/class.ws.html5.compiler.php
inc/ws/Util/packager/class.ws.packager.html.php

index d0537bfcb517d605f4061566559b5491a13525d3..ce4bedb54a210f2a46696c67411fff6dc42da730 100644 (file)
@@ -96,7 +96,7 @@ function handleWheel(delta){
 \r
 function isMobile(){\r
        var ua=navigator.userAgent;\r
-       var devices = ['iphone', 'ipad', 'ipod', 'android', 'blackberry', 'mobile', 'symbian', 'phone', 'nintendo', 'playstation'];\r
+       var devices = ['iphone', 'ipad', 'ipod', 'android', 'blackberry', 'mobile', 'symbian', 'phone', 'nintendo', 'playstation','webos'];\r
        var pattern;\r
 \r
        for(i=0;i<devices.length;i++){\r
index 3e1e6a5199623bd9519b138769924f23a53b7730..6cf5466cbba0c16c13e7244796d497ac96c2b3d4 100644 (file)
@@ -16,7 +16,7 @@ $redirectScript
 </div>\r
 <script type="text/javascript">\r
 if(isMobile()){\r
-       window.location='data/document.pdf';\r
+       $redirectMobile\r
 }else{\r
        swfobject.embedSWF("$pathToIndex", "fluidbook", "100%", "100%", "10.0.22","", parseGet(),       {"allowScriptAccess":"always","quality":"high","scale":"noscale","wmode":getWmode(),"allowFullScreen":"true"},{"bgcolor":"#$bgcolor"});\r
 }\r
index 7884e2377efe825d0f0b51b145f8c1143a174f35..6a0eab3520584729f6ab34016f7ba0c82d6da64f 100644 (file)
@@ -22,9 +22,9 @@ if($argv[i]!="-")
                        SetUnicodeValue(UCodePoint(uto))
                        j++
                endif
-       endloop
+       endloop 
 endif
-
 i++
+RemoveAllKerns() 
 Print("Write font ",$argv[i])
 Generate($argv[i])
\ No newline at end of file
index e0ac685fb6800f33c5c90589ea5efb5e1626b010..ba8fe7e7e5e44c77e45bc7584008eb6121912d6c 100644 (file)
@@ -54,6 +54,43 @@ is divided into following sections:
         <property file="nbproject/project.properties"/>\r
     </target>\r
     <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">\r
+        <j2seproject1:property name="platform.home" value="platforms.${platform.active}.home"/>\r
+        <j2seproject1:property name="platform.bootcp" value="platforms.${platform.active}.bootclasspath"/>\r
+        <j2seproject1:property name="platform.compiler" value="platforms.${platform.active}.compile"/>\r
+        <j2seproject1:property name="platform.javac.tmp" value="platforms.${platform.active}.javac"/>\r
+        <condition property="platform.javac" value="${platform.home}/bin/javac">\r
+            <equals arg1="${platform.javac.tmp}" arg2="$${platforms.${platform.active}.javac}"/>\r
+        </condition>\r
+        <property name="platform.javac" value="${platform.javac.tmp}"/>\r
+        <j2seproject1:property name="platform.java.tmp" value="platforms.${platform.active}.java"/>\r
+        <condition property="platform.java" value="${platform.home}/bin/java">\r
+            <equals arg1="${platform.java.tmp}" arg2="$${platforms.${platform.active}.java}"/>\r
+        </condition>\r
+        <property name="platform.java" value="${platform.java.tmp}"/>\r
+        <j2seproject1:property name="platform.javadoc.tmp" value="platforms.${platform.active}.javadoc"/>\r
+        <condition property="platform.javadoc" value="${platform.home}/bin/javadoc">\r
+            <equals arg1="${platform.javadoc.tmp}" arg2="$${platforms.${platform.active}.javadoc}"/>\r
+        </condition>\r
+        <property name="platform.javadoc" value="${platform.javadoc.tmp}"/>\r
+        <condition property="platform.invalid" value="true">\r
+            <or>\r
+                <contains string="${platform.javac}" substring="$${platforms."/>\r
+                <contains string="${platform.java}" substring="$${platforms."/>\r
+                <contains string="${platform.javadoc}" substring="$${platforms."/>\r
+            </or>\r
+        </condition>\r
+        <fail unless="platform.home">Must set platform.home</fail>\r
+        <fail unless="platform.bootcp">Must set platform.bootcp</fail>\r
+        <fail unless="platform.java">Must set platform.java</fail>\r
+        <fail unless="platform.javac">Must set platform.javac</fail>\r
+        <fail if="platform.invalid">\r
+ The J2SE Platform is not correctly set up.\r
+ Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. \r
+ Either open the project in the IDE and setup the Platform with the same name or add it manually.\r
+ For example like this:\r
+     ant -Duser.properties.file=&lt;path_to_property_file&gt; jar (where you put the property "platforms.${platform.active}.home" in a .properties file)\r
+  or ant -Dplatforms.${platform.active}.home=&lt;path_to_JDK_home&gt; jar (where no properties file is used) \r
+  </fail>\r
         <available file="${manifest.file}" property="manifest.available"/>\r
         <condition property="splashscreen.available">\r
             <and>\r
@@ -185,15 +222,6 @@ is divided into following sections:
         <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">\r
             <length length="0" string="${endorsed.classpath}" when="greater"/>\r
         </condition>\r
-        <condition else="false" property="jdkBug6558476">\r
-            <and>\r
-                <matches pattern="1\.[56]" string="${java.specification.version}"/>\r
-                <not>\r
-                    <os family="unix"/>\r
-                </not>\r
-            </and>\r
-        </condition>\r
-        <property name="javac.fork" value="${jdkBug6558476}"/>\r
         <property name="jar.index" value="false"/>\r
         <property name="jar.index.metainf" value="${jar.index}"/>\r
         <available file="${meta.inf.dir}/persistence.xml" property="has.persistence.xml"/>\r
@@ -239,7 +267,7 @@ is divided into following sections:
                 <property location="${build.dir}/empty" name="empty.dir"/>\r
                 <mkdir dir="${empty.dir}"/>\r
                 <mkdir dir="@{apgeneratedsrcdir}"/>\r
-                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">\r
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" executable="${platform.javac}" fork="yes" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">\r
                     <src>\r
                         <dirset dir="@{gensrcdir}" erroronmissingdir="false">\r
                             <include name="*"/>\r
@@ -278,7 +306,7 @@ is divided into following sections:
             <sequential>\r
                 <property location="${build.dir}/empty" name="empty.dir"/>\r
                 <mkdir dir="${empty.dir}"/>\r
-                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">\r
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" executable="${platform.javac}" fork="yes" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">\r
                     <src>\r
                         <dirset dir="@{gensrcdir}" erroronmissingdir="false">\r
                             <include name="*"/>\r
@@ -335,7 +363,7 @@ is divided into following sections:
             <attribute default="**" name="testincludes"/>\r
             <sequential>\r
                 <property name="junit.forkmode" value="perTest"/>\r
-                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" showoutput="true" tempdir="${build.dir}">\r
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" forkmode="${junit.forkmode}" jvm="${platform.java}" showoutput="true" tempdir="${build.dir}">\r
                     <batchtest todir="${build.test.results.dir}"/>\r
                     <classpath>\r
                         <path path="${run.test.classpath}"/>\r
@@ -407,6 +435,9 @@ is divided into following sections:
                     <classpath>\r
                         <path path="@{classpath}"/>\r
                     </classpath>\r
+                    <bootclasspath>\r
+                        <path path="${platform.bootcp}"/>\r
+                    </bootclasspath>\r
                 </nbjpdastart>\r
             </sequential>\r
         </macrodef>\r
@@ -422,7 +453,9 @@ is divided into following sections:
         </macrodef>\r
     </target>\r
     <target name="-init-debug-args">\r
-        <property name="version-output" value="java version &quot;${ant.java.version}"/>\r
+        <exec executable="${platform.java}" outputproperty="version-output">\r
+            <arg value="-version"/>\r
+        </exec>\r
         <condition property="have-jdk-older-than-1.4">\r
             <or>\r
                 <contains string="${version-output}" substring="java version &quot;1.0"/>\r
@@ -447,7 +480,7 @@ is divided into following sections:
             <attribute default="${debug.classpath}" name="classpath"/>\r
             <element name="customize" optional="true"/>\r
             <sequential>\r
-                <java classname="@{classname}" dir="${work.dir}" fork="true">\r
+                <java classname="@{classname}" dir="${work.dir}" fork="true" jvm="${platform.java}">\r
                     <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>\r
                     <jvmarg line="${debug-args-line}"/>\r
                     <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>\r
@@ -472,7 +505,7 @@ is divided into following sections:
             <attribute default="${run.classpath}" name="classpath"/>\r
             <element name="customize" optional="true"/>\r
             <sequential>\r
-                <java classname="@{classname}" dir="${work.dir}" fork="true">\r
+                <java classname="@{classname}" dir="${work.dir}" fork="true" jvm="${platform.java}">\r
                     <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>\r
                     <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>\r
                     <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>\r
@@ -655,7 +688,7 @@ is divided into following sections:
             <path path="${run.classpath}"/>\r
             <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>\r
         </pathconvert>\r
-        <echo level="info">java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>\r
+        <echo level="info">${platform.java} -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>\r
     </target>\r
     <target depends="init" if="do.archive" name="-do-jar-with-libraries-create-manifest" unless="manifest.available">\r
         <tempfile deleteonexit="true" destdir="${build.dir}" property="tmp.manifest.file"/>\r
@@ -682,7 +715,7 @@ is divided into following sections:
         <j2seproject3:copylibs manifest="${tmp.manifest.file}"/>\r
         <echo level="info">To run this application from the command line without Ant, try:</echo>\r
         <property location="${dist.jar}" name="dist.jar.resolved"/>\r
-        <echo level="info">java -jar "${dist.jar.resolved}"</echo>\r
+        <echo level="info">${platform.java} -jar "${dist.jar.resolved}"</echo>\r
     </target>\r
     <target depends="-do-jar-with-libraries-pack" if="do.archive" name="-do-jar-with-libraries-delete-manifest">\r
         <delete>\r
@@ -832,16 +865,15 @@ is divided into following sections:
             -->\r
     <target depends="init" if="have.sources" name="-javadoc-build">\r
         <mkdir dir="${dist.javadoc.dir}"/>\r
-        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">\r
+        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" executable="${platform.javadoc}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">\r
             <classpath>\r
                 <path path="${javac.classpath}"/>\r
             </classpath>\r
-            <fileset dir="${src.src.dir}" excludes="*.java,${excludes}" includes="${includes}">\r
+            <fileset dir="${src.src.dir}" excludes="${excludes}" includes="${includes}">\r
                 <filename name="**/*.java"/>\r
             </fileset>\r
             <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">\r
                 <include name="**/*.java"/>\r
-                <exclude name="*.java"/>\r
             </fileset>\r
         </javadoc>\r
         <copy todir="${dist.javadoc.dir}">\r
index 00af3e9f51cd07dd8e94266e641db7e69f2e7061..c18a0bf72cbba98a8d9ea15560736172f02ef233 100644 (file)
@@ -1,8 +1,8 @@
-build.xml.data.CRC32=5afba316\r
+build.xml.data.CRC32=0fe54e23\r
 build.xml.script.CRC32=ef618d2d\r
-build.xml.stylesheet.CRC32=28e38971@1.44.1.45\r
+build.xml.stylesheet.CRC32=28e38971@1.43.1.45\r
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.\r
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.\r
-nbproject/build-impl.xml.data.CRC32=5afba316\r
-nbproject/build-impl.xml.script.CRC32=f0904f14\r
-nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45\r
+nbproject/build-impl.xml.data.CRC32=0fe54e23\r
+nbproject/build-impl.xml.script.CRC32=34b388b3\r
+nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45\r
index 561b445a080ea1ef171a02930756a70600781813..cc2c0e57c4f9286a6ee78a9b3557c26caca57415 100644 (file)
@@ -1,13 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <project-private xmlns="http://www.netbeans.org/ns/project-private/1">\r
     <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>\r
-    <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">\r
-        <file>file:/H:/Works/extranet/fluidbook/tools/fwstk/src/com/fluidbook/fwstk/LayoutStripper.java</file>\r
-        <file>file:/H:/Works/extranet/fluidbook/tools/fwstk/src/com/fluidbook/fwstk/layout/Group.java</file>\r
-        <file>file:/H:/Works/extranet/fluidbook/tools/fwstk/src/com/fluidbook/fwstk/layout/Word.java</file>\r
-        <file>file:/H:/Works/extranet/fluidbook/tools/fwstk/src/com/fluidbook/fwstk/Main.java</file>\r
-        <file>file:/H:/Works/extranet/fluidbook/tools/fwstk/src/org/apache/pdfbox/util/operator/ShowTextGlyph.java</file>\r
-        <file>file:/H:/Works/extranet/fluidbook/tools/fwstk/src/org/apache/pdfbox/util/PDFStreamEngine.java</file>\r
-        <file>file:/H:/Works/extranet/fluidbook/tools/fwstk/src/org/apache/pdfbox/util/operator/ShowText.java</file>\r
-    </open-files>\r
 </project-private>\r
index e1d9e82f1d2a10e18975226fe1f02854848a50e3..2bb20f19cead100858b11c6d2a32efc408c09766 100644 (file)
@@ -85,7 +85,7 @@ main.class=com.fluidbook.fwstk.Main
 manifest.file=manifest.mf\r
 meta.inf.dir=${src.dir}/META-INF\r
 mkdist.disabled=false\r
-platform.active=default_platform\r
+platform.active=JDK_1.7\r
 run.classpath=\\r
     ${build.classes.dir}:\\r
     ${javac.classpath}\r
index a70a3bf29431378f33d371fe067865f62a63519c..38eb6a1e35c4121bb8fcb1ab0c5af13aa69e7610 100644 (file)
@@ -4,6 +4,7 @@
     <configuration>\r
         <data xmlns="http://www.netbeans.org/ns/j2se-project/3">\r
             <name>fwstk</name>\r
+            <explicit-platform explicit-source-supported="true"/>\r
             <source-roots>\r
                 <root id="src.src.dir"/>\r
             </source-roots>\r
diff --git a/fluidbook/tools/fwstk/src/org/apache/pdfbox/pdmodel/font/PDType0Font.java b/fluidbook/tools/fwstk/src/org/apache/pdfbox/pdmodel/font/PDType0Font.java
new file mode 100644 (file)
index 0000000..db734d3
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.font;
+
+import java.awt.Font;
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fontbox.afm.FontMetric;
+import org.apache.pdfbox.cos.COSArray;
+import org.apache.pdfbox.cos.COSDictionary;
+import org.apache.pdfbox.cos.COSName;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
+
+/**
+ * This is implementation of the Type0 Font. 
+ * See <a href="https://issues.apache.org/jira/browse/PDFBOX-605">PDFBOX-605</a>
+ * for the related improvement issue.
+ *
+ * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
+ * @version $Revision: 1.9 $
+ */
+public class PDType0Font extends PDSimpleFont {
+
+       /**
+        * Log instance.
+        */
+       private static final Log log = LogFactory.getLog(PDType0Font.class);
+       private COSArray descendantFontArray;
+       private PDFont descendentFont;
+       private COSDictionary descendantFontDictionary;
+       private Font awtFont;
+       private PDFontDescriptor fontDescriptor;
+
+       /**
+        * Constructor.
+        */
+       public PDType0Font() {
+               super();
+               font.setItem(COSName.SUBTYPE, COSName.TYPE0);
+       }
+
+       /**
+        * Constructor.
+        *
+        * @param fontDictionary The font dictionary according to the PDF specification.
+        */
+       public PDType0Font(COSDictionary fontDictionary) {
+               super(fontDictionary);
+               descendantFontDictionary = (COSDictionary) getDescendantFonts().getObject(0);
+               if (descendantFontDictionary != null) {
+                       try {
+                               descendentFont = PDFontFactory.createFont(descendantFontDictionary);
+                       } catch (IOException exception) {
+                               log.error("Error while creating the descendant font!");
+                       }
+               }
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public Font getawtFont() throws IOException {
+               if (awtFont == null) {
+                       if (descendentFont != null) {
+                               awtFont = ((PDSimpleFont) descendentFont).getawtFont();
+                       }
+                       if (awtFont == null) {
+                               awtFont = FontManager.getStandardFont();
+                               log.info("Using font " + awtFont.getName() + " instead of " + descendentFont.getFontDescriptor().getFontName());
+                       }
+               }
+               return awtFont;
+       }
+
+       /**
+        * This will get the fonts bounding box.
+        *
+        * @return The fonts bounding box.
+        *
+        * @throws IOException If there is an error getting the bounding box.
+        */
+       public PDRectangle getFontBoundingBox() throws IOException {
+               throw new RuntimeException("Not yet implemented");
+       }
+
+       /**
+        * This will get the font width for a character.
+        *
+        * @param c The character code to get the width for.
+        * @param offset The offset into the array.
+        * @param length The length of the data.
+        *
+        * @return The width is in 1000 unit of text space, ie 333 or 777
+        *
+        * @throws IOException If an error occurs while parsing.
+        */
+       public float getFontWidth(byte[] c, int offset, int length) throws IOException {
+               return descendentFont.getFontWidth(c, offset, length);
+       }
+
+       /**
+        * This will get the font height for a character.
+        *
+        * @param c The character code to get the height for.
+        * @param offset The offset into the array.
+        * @param length The length of the data.
+        *
+        * @return The width is in 1000 unit of text space, ie 333 or 777
+        *
+        * @throws IOException If an error occurs while parsing.
+        */
+       public float getFontHeight(byte[] c, int offset, int length) throws IOException {
+               return descendentFont.getFontHeight(c, offset, length);
+       }
+
+       /**
+        * This will get the average font width for all characters.
+        *
+        * @return The width is in 1000 unit of text space, ie 333 or 777
+        *
+        * @throws IOException If an error occurs while parsing.
+        */
+       public float getAverageFontWidth() throws IOException {
+               return descendentFont.getAverageFontWidth();
+       }
+
+       private COSArray getDescendantFonts() {
+               if (descendantFontArray == null) {
+                       descendantFontArray = (COSArray) font.getDictionaryObject(COSName.DESCENDANT_FONTS);
+               }
+               return descendantFontArray;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public PDFontDescriptor getFontDescriptor() {
+               if (fontDescriptor == null) {
+                       fontDescriptor=super.getFontDescriptor();
+                       if(fontDescriptor==null){
+                               fontDescriptor=descendentFont.getFontDescriptor();
+                       }
+               }
+               return fontDescriptor;
+       }
+
+       /**
+        * {@inheritDoc}
+        */
+       public float getFontWidth(int charCode) {
+               return descendentFont.getFontWidth(charCode);
+       }
+
+       @Override
+       public String encode(byte[] c, int offset, int length) throws IOException {
+               if (hasToUnicode()) {
+                       return super.encode(c, offset, length);
+               } else {
+                       int result = cmap.lookupCID(c, offset, length);
+                       if (result != -1) {
+                               return descendentFont.cmapEncoding(result, 2, true);
+                       }
+                       return null;
+               }
+       }
+}
index 93a246611517fe74de179fd2ad2fb3280697a217..757254f98c4d701e7003f0f65bf9d06a5e1ef970 100644 (file)
@@ -86,7 +86,7 @@ public class PDFStreamEngine {
        /**
         * Flag to skip malformed or otherwise unparseable input where possible.
         */
-       private boolean forceParsing = false;
+       private boolean forceParsing = true;
 
        /**
         * This is a simple internal class used by the Stream engine to handle the
@@ -378,8 +378,6 @@ public class PDFStreamEngine {
                                if (!currentChar.equals(c)) {
                                        if (c.toUpperCase().equals(currentChar)) {
                                                c = c.toUpperCase();
-                                       } else if (c.toLowerCase().equals(currentChar)) {
-                                               c = c.toLowerCase();
                                        }
                                }
                        } catch (NullPointerException e) {
index a5f7c8d4e24ad2f8cca586c8b59842934a10583f..8612ca0abe98b1e6e1d7fa2d218434fe8f8c0347 100644 (file)
@@ -40,6 +40,8 @@ public class ShowText extends OperatorProcessor {
        public void process(PDFOperator operator, List<COSBase> arguments) throws IOException {
                COSString string = (COSString) arguments.get(0);
                context.setCurrentString(string.getString());
+
                context.processEncodedText(string.getBytes());
+
        }
 }
index 5cb9b646839a347c0d613bf19430756be5854250..b61c6dece2fcd5e0fc41e5412129460188079589 100644 (file)
@@ -55,6 +55,7 @@ public class ShowTextGlyph extends OperatorProcessor {
                        } else if (next instanceof COSString) {
                                context.setCurrentString(((COSString) next).getString());
                                context.processEncodedText(((COSString) next).getBytes());
+
                        } else {
                                throw new IOException("Unknown type in array for TJ operation:" + next);
                        }
index 3698ba57ef93351a76cd4cc0c065712bf82c9974..1bac59d515ca16214541add71d105b29e6235182 100644 (file)
@@ -1018,7 +1018,7 @@ class wsDAOBook extends commonDAO {
        public function compilePDF($book, $pages) {\r
                $finalPDF = WS_BOOKS . '/final/' . $book->book_id . '/data/document.pdf';\r
 \r
-               if (!$book->parametres->pdf) {\r
+               if (!$book->parametres->pdf && $book->parametres->mobileVersion!='pdf') {\r
                        // Si l'export PDF n'est pas activé on supprime le fichier si il existe\r
                        if (file_exists($finalPDF)) {\r
                                unlink($finalPDF);\r
index 7d224b4e36dd609194934ca9b615eb34f03b821a..c48693881d3ffd171a3dee91da692fd3a4d8d822 100644 (file)
@@ -140,11 +140,11 @@ class wsBookParametres extends wsParametres {
                $this->forms['sommaire'] = array('label' => __('Sommaire'),\r
                        'fieldsnames' => array('displayChaptersIcon', 'displayChaptersAtStart', 'chaptersPage', 'chaptersPosition', '|', 'chaptersColMaxWidth', 'chaptersColumns', '|', 'externalChapters', 'fullExternalChapters', '|', 'ongletsSWF', 'ongletsXML'));\r
                // .\r
-               $this->fields['customLinkClass']= array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Classe pour les liens personnalisés'),'grade'=>5);\r
+               $this->fields['customLinkClass'] = array('type' => 'text', 'default' => '', 'editable' => true, 'label' => __('Classe pour les liens personnalisés'), 'grade' => 5);\r
                $this->fields['permanentLinks'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Liens visibles en permanence'), 'grade' => 3);\r
                $this->fields['linkBlinkTime'] = array('type' => 'float', 'default' => 1.0, 'editable' => true, 'label' => __("Temps d'apparition du lien Ã  l'ouverture de la page (en secondes)"));\r
                $this->forms['multimedia'] = array('label' => __('Liens et multimédia'),\r
-                       'fieldsnames' => array('permanentLinks', 'linkBlinkTime','customLinkClass'));\r
+                       'fieldsnames' => array('permanentLinks', 'linkBlinkTime', 'customLinkClass'));\r
                // .\r
                $this->fields['externalArchives'] = array('type' => 'freefile', 'default' => '', 'editable' => true,\r
                        'label' => __('Archives'), 'grade' => 3, 'fileFilter' => $swfFilter);\r
@@ -172,6 +172,15 @@ class wsBookParametres extends wsParametres {
                $this->forms['offline'] = array('label' => __('Version offline'),\r
                        'fieldsnames' => array('offlineLink'));\r
 \r
+               $this->fields['mobileVersion'] = array('type' => 'combo', 'default' => 'pdf', 'editable' => true, 'label' => __('Version mobile'), 'grade' => 5,\r
+                       'datas' => array(__('Rediriger vers le PDF') => 'pdf',\r
+                               __('Version HTML5') => 'html5',\r
+                               __("Version HTML5 en images") => 'html5-images')\r
+               );\r
+               $this->forms['mobile'] = array('label' => __('Version mobile'),\r
+                       'fieldsnames' => array('mobileVersion'));\r
+\r
+\r
                $this->fields['widget'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __('Générer le widget'), 'grade' => 5);\r
                $this->fields['widgetCover'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __('Afficher la couverture') . ')', 'grade' => 5);\r
                $this->fields['widgetSize'] = array('type' => 'integer', 'default' => 200, 'editable' => true, 'label' => __('Optimiser pour une hauteur de (en pixels)'), 'grade' => 5);\r
@@ -181,6 +190,8 @@ class wsBookParametres extends wsParametres {
                $this->forms['widget'] = array('label' => __('Widget') . ' (' . __('Mini Fluidbook') . ')',\r
                        'fieldsnames' => array('widget', 'widgetCover', 'widgetSize', 'widgetQuality', 'widgetStart', 'widgetEnd'));\r
 \r
+\r
+\r
                // Paramètres non implémentés\r
                /*\r
                  // $this->fields['attachPDFInEmail'] = array('type' => 'boolean', 'default' => false, 'editable' => true, 'label' => __("Joindre le fichier PDF de la page en cours Ã  l'email"),  'grade' => 4);\r
index 6afff2a6a2e1b73162a7d5167bc8c6c820c226bc..3d2bbc6f5c9b0d70bbc2b25495b7472bc8892cab 100644 (file)
@@ -7,6 +7,8 @@ class wsPDFFontExtractor {
        protected $outweb;
        protected $fonts = array();
        protected $cmaps = array();
+       protected $descendants = array();
+       protected $descendantNames = array();
        protected $doc;
 
        public function __construct($in, $doc=null) {
@@ -51,6 +53,13 @@ class wsPDFFontExtractor {
                }
 
                foreach ($collections as $fontname => $files) {
+                       $descendant = array_keys($this->descendantNames, $fontname);
+                       if (count($descendant)) {
+                               $f = array_keys($this->descendants, $descendant[0]);
+                               $fontname = $f[0];
+                       }
+
+
                        $fontforge = new cubeCommandLine('convert.pe');
                        $fontforge->setPath(CONVERTER_PATH);
                        foreach ($files as $file) {
@@ -113,7 +122,7 @@ class wsPDFFontExtractor {
                $pdfshow->setArg(null, $this->in);
                $pdfshow->setManualArg(implode(' ', array_keys($this->fonts)));
                $pdfshow->execute();
-               //$this->doc->addToLog($pdfshow);
+               $this->doc->addToLog($pdfshow);
 
                /*
                  8677 0 obj
@@ -153,6 +162,19 @@ class wsPDFFontExtractor {
                  0 740 0 0 0 0 0 0 0 0 536 ]
                  >>
                  endobj
+                * 
+                 10 0 obj
+                 <<
+                 /BaseFont /FuturaLT-Bold--Identity-H
+                 /DescendantFonts [ 11 0 R ]
+                 /Encoding /Identity-H
+                 /Name /F0
+                 /Subtype /Type0
+                 /ToUnicode 3881 0 R
+                 /Type /Font
+                 >>
+                 endobj
+
                 */
 
                $lines = explode("\n", $pdfshow->output);
@@ -167,7 +189,7 @@ class wsPDFFontExtractor {
                                continue;
                        }
                        $e = explode(' ', $line);
-                       if (count($e)==3 && $e[2] == 'obj') {
+                       if (count($e) == 3 && $e[2] == 'obj') {
                                $currentFont = $e[0];
                                continue;
                        }
@@ -182,11 +204,83 @@ class wsPDFFontExtractor {
                                $this->fonts[$currentFont]['cmap'] = $e[1];
                                $this->cmaps[$fontname] = $e[1];
                        }
+
+                       if ($e[0] == '/DescendantFonts') {
+                               $this->fonts[$currentFont]['descendant'] = $e[2];
+                               $this->descendants[$fontname] = $e[2];
+                       }
                }
 
+               $this->manageDescendants();
+
                $this->addToLog(print_r($this->fonts, true));
        }
 
+       protected function manageDescendants() {
+               if (!count($this->descendants)) {
+                       return;
+               }
+
+               $pdfshow = $this->getCommandLine('pdfshow');
+               $pdfshow->setArg(null, $this->in);
+               $pdfshow->setManualArg(implode(' ', $this->descendants));
+               $pdfshow->execute();
+               $this->doc->addToLog($pdfshow);
+
+               /*
+                 11 0 obj
+                 <<
+                 /BaseFont /EHLOJB+FuturaLT-Bold-OV-JVKOJB
+                 /CIDSystemInfo <<
+                 /Ordering (Identity)
+                 /Registry (Adobe)
+                 /Supplement 0
+                 >>
+                 /DW 343
+                 /FontDescriptor 3878 0 R
+                 /Name /F0
+                 /Subtype /CIDFontType0
+                 /Type /Font
+                 /W [ 1 [ 781 ] 4 [ 781 ] 9 [ 677 660 ] 12 [ 752 550 550 550 ]
+                 17 [ 550 ] 20 [ 542 842 803 324 ] 26 [ 324 ] 28 [ 489 ] 30
+                 [ 495 ] 32 [ 983 881 ] 35 [ 887 ] 43 [ 661 887 680 616 ]
+                 48 [ 533 ] 50 [ 778 ] 55 [ 761 ] 57 [ 789 ] 61 [ 707 ] 63
+                 [ 682 ] 77 [ 682 ] 87 [ 483 ] 93 [ 343 343 ] 97 [ 682 ] 106
+                 [ 610 610 610 ] 111 [ 686 ] 119 [ 388 ] 121 [ 689 ] 124 [
+                 686 ] 126 [ 677 ] 134 [ 661 ] 136 [ 392 ] 138 [ 302 ] 140
+                 [ 302 302 ] 149 [ 989 ] 154 [ 661 ] 156 [ 686 ] 159 [ 662 ]
+                 167 [ 686 ] 175 [ 682 ] 180 [ 343 ] 193 [ 372 ] 196 [ 453 ]
+                 199 [ 513 ] 203 [ 686 686 ] 208 [ 360 ] 210 [ 686 ] 215 [
+                 686 ] 217 [ 659 ] 232 [ 686 ] ]
+                 >>
+                 endobj
+
+                */
+
+               $currentDescendant = null;
+               $lines = explode("\n", $pdfshow->output);
+               foreach ($lines as $line) {
+                       $line = trim($line);
+                       $e = explode(' ', $line);
+                       if (count($e) == 3 && $e[2] == "obj") {
+                               $currentDescendant = $e[0];
+                       }
+                       if ($line == 'endobj') {
+                               $currentDescendant = null;
+                       }
+
+                       if (is_null($currentDescendant)) {
+                               continue;
+                       }
+
+                       if ($e[0] == '/BaseFont') {
+                               $this->descendantNames[$currentDescendant] = trim($e[1], "/");
+                       }
+               }
+
+               $this->addToLog('Descendant names : ' . print_r($this->descendantNames, true));
+       }
+
        protected function extractFonts() {
                $descriptors = $this->getUniqueId('descriptor');
 
@@ -265,12 +359,12 @@ class wsPDFFontExtractor {
                        }
 
                        $e = explode(' ', $line);
-                       if (count($e)==3 && $e[2] == 'obj') {
+                       if (count($e) == 3 && $e[2] == 'obj') {
                                $currentCmap = $e[0];
                                continue;
                        }
 
-                       if (count($e)==1 && $e[1] == 'beginbfchar') {
+                       if (count($e) == 2 && $e[1] == 'beginbfchar') {
                                $inMap = true;
                                continue;
                        }
@@ -289,6 +383,12 @@ class wsPDFFontExtractor {
                                        $finalCmaps[$fontname] = array();
                                }
 
+                               if (strlen($to) >= 8) {
+                                       $toc = $to;
+                                       $to = $this->manageLigatures($to);
+                                       $this->addToLog('Correct ligature ' . $toc . ' -> ' . $to);
+                               }
+
                                $finalCmaps[$fontname][$from] = $to;
                        }
                }
@@ -299,10 +399,37 @@ class wsPDFFontExtractor {
                        foreach ($cmap as $from => $to) {
                                $data.=$from . "\t" . $to . "\n";
                        }
+
+                       $this->addToLog('Write cmap for font ' . $fontname . ' in ' . $this->outpdf . '/' . $fontname . '.cmap');
+
                        file_put_contents($this->outpdf . '/' . $fontname . '.cmap', $data);
                }
        }
 
+       protected function manageLigatures($code) {
+               $codes = str_split($code, 4);
+               $str = '';
+               foreach ($codes as $c) {
+                       $str.=chr(intval($c, 16));
+               }
+
+               $ligatures = array('AE' => '00C6', 'ae' => '00E6',
+                       'OE' => '0152', 'oe' => '0152',
+                       'IJ' => '0132', 'ij' => '0133',
+                       'ff' => 'fb00',
+                       'fi' => 'fb01',
+                       'fl' => 'fb02',
+                       'ffi' => 'fb03',
+                       'ffl' => 'fb04');
+
+               // Si un couple est une ligature standard
+               if (isset($ligatures[$str])) {
+                       return $ligatures[$str];
+               }
+               // Sinon, on ne retourne que le premier code
+               return $codes[0];
+       }
+
        protected function getUniqueId($param) {
                $res = array();
                foreach ($this->fonts as $f) {
index d45c20cbea6387fae20a397ac52e1ca6d7262d5a..6b18736a443f1e6f43f8a2e9e5086bed80c68285 100644 (file)
@@ -355,7 +355,8 @@ class wsHTML5Compiler {
        protected function writeFonts() {
                $formats = array('ttf', 'woff', 'svg');
 
-               foreach ($this->cssFont as $font => $index) {
+               foreach ($this->cssFont as $font => $infos) {
+                       $index=$infos['index'];
 
                        foreach ($formats as $format) {
                                $fontforge = new cubeCommandLine('convert.pe');
@@ -467,18 +468,22 @@ class wsHTML5Compiler {
 
                $group['y'] = $this->getCSSY(($group['y'] + $line['y']) * $this->multiply);
                $group['x'] = $this->getCSSX(($group['x']) * $this->multiply);
-               $group['letterspacing'] = $this->getCSSLetterSpacing($group['letterspacing'] );
+               $group['letterspacing'] = $this->getCSSLetterSpacing($group['letterspacing']);
                $group['wordspacing'] = $this->getCSSWordSpacing($group['wordspacing']);
 
                $class = array('g');
+               if ($group['oblique']) {
+                       $class[] = 'o';
+               }
+
                if (!is_null($group['color'])) {
                        $class[] = 'c' . $group['color'];
                }
                if (!is_null($group['size'])) {
                        $class[] = 's' . $group['size'];
                }
-               if (!is_null($group['font'])) {
-                       $class[] = 'f' . $group['font'];
+               if (!is_null($group['font']['index'])) {
+                       $class[] = 'f' . $group['font']['index'];
                }
                if (!is_null($group['x'])) {
                        $class[] = 'x' . $group['x'];
@@ -720,8 +725,10 @@ class wsHTML5Compiler {
                        $res[] = $css;
                }
 
-               foreach ($this->cssFont as $font => $index) {
-                       $res[] = "@font-face{font-family:F" . $index . ";src:url('F" . $index . ".ttf') format('truetype'),url('F" . $index . ".woff') format('woff'),url('F" . $index . ".svg#" . $font . "') format('svg')}";
+               foreach ($this->cssFont as $font => $infos) {
+                       $index = $infos['index'];
+                       $style = $infos['oblique'] ? 'oblique' : 'normal';
+                       $res[] = "@font-face{font-family:F" . $index . ";font-style:" . $style . ";src:url('F" . $index . ".ttf') format('truetype'),url('F" . $index . ".woff') format('woff'),url('F" . $index . ".svg#" . $font . "') format('svg')}";
                        $res[] = '.f' . $index . '{font-family:F' . $index . ',Arial,Helvetica}';
                }
 
@@ -848,16 +855,17 @@ class wsHTML5Compiler {
 
                        $ws = floatval($group['wordspacing']);
                        $ls = floatval($group['letterspacing']);
-                       $size = floatval($group['size'])*$this->fontScale;
+                       $size = floatval($group['size']) * $this->fontScale;
 
                        $res[] = array(
                                'color' => $this->getCSSColor($group['color']),
                                'size' => $this->getCSSSize($size),
-                               'font' => $this->getCSSFont($group['font'], $document_id),
+                               'font' => $this->getCSSFont($group['font'], $group['oblique'] == 'true', $document_id),
                                'letterspacing' => $ls,
                                'wordspacing' => $ws,
                                'y' => 0,
                                'x' => $x,
+                               'oblique' => ($group['oblique'] == 'true'),
                                'text' => $text);
                }
                return $res;
@@ -913,15 +921,14 @@ class wsHTML5Compiler {
                return $this->getIndex($size, $this->cssSize);
        }
 
-       protected function getCSSFont(
-       $font, $document_id) {
+       protected function getCSSFont($font, $oblique, $document_id) {
                $font = (string) $font;
                if (!isset($this->fontDocs[$font])) {
                        $this->fontDocs[$font] = array();
                }
                $this->fontDocs[$font][$document_id] = true;
 
-               return $this->getIndex($font, $this->cssFont);
+               return $this->getIndex($font, $this->cssFont, array('oblique' => $oblique));
        }
 
        protected function getCSSColor($color) {
@@ -978,13 +985,17 @@ class wsHTML5Compiler {
                return $this->getIndex($y, $this->cssY);
        }
 
-       protected function getIndex($value, &$tab) {
+       protected function getIndex($value, &$tab, $params=array()) {
                $value = (string) $value;
                if (isset($tab[$value])) {
                        return $tab[$value];
                }
                $res = $this->base62(count($tab));
-               $tab[$value] = $res;
+               if (!count($params)) {
+                       $tab[$value] = $res;
+               } else {
+                       $tab[$value] = array_merge(array('index'=>$res), $params);
+               }
                return $res;
        }
 
index f31b6bc234ba55474fe22c112f2067f56f190949..fe2092c098a6fdfbc5e293f9c4572a669a527add 100644 (file)
@@ -45,8 +45,21 @@ class wsPackagerHTML extends wsPackager {
                        }\r
                        $facebook .= '<meta property="og:image" content="http://workshop.fluidbook.com/services/facebook_thumbnail?id=' . $this->book->book_id . '" />';\r
                }\r
+\r
+               if ($this->book->parametres->mobileVersion == 'pdf') {\r
+                       $redirectMobile = 'window.location="data/document.pdf";';\r
+               } else {\r
+                       $redirectMobile = 'window.location="m/index.html";';\r
+                       $this->prepareHTML5();\r
+               }\r
+\r
+\r
                // Stuffs to replace in html\r
-               $toReplace = array('lang' => strtolower($this->book->lang), 'title' => self::escape($this->book->parametres->title), 'ga' => $ga, 'facebook' => $facebook, 'bgcolor' => $this->theme->parametres->loadingBackColor);\r
+               $toReplace = array('lang' => strtolower($this->book->lang),\r
+                       'title' => self::escape($this->book->parametres->title),\r
+                       'ga' => $ga, 'facebook' => $facebook,\r
+                       'bgcolor' => $this->theme->parametres->loadingBackColor,\r
+                       'redirectMobile' => $redirectMobile);\r
 \r
                $this->origHTML = file_get_contents($this->vdir . '/index.html');\r
                $this->origHTML = $this->replaceHTML($toReplace);\r
@@ -92,6 +105,32 @@ class wsPackagerHTML extends wsPackager {
                }\r
        }\r
 \r
+       public function prepareHTML5() {\r
+               $dest = $this->vdir . 'm';\r
+               mkdir($dest, 0777, true);\r
+\r
+               $cp = new cubeCommandLine('cp');\r
+               $cp->setPath(CONVERTER_PATH);\r
+               $cp->setArg('r');\r
+               $cp->setArg(null,WS_BOOKS . '/html5/' . $this->book_id . '/*');\r
+               $cp->setArg(null,$dest);\r
+               $cp->execute();\r
+\r
+               $filesToDelete = array('indext.html', 'indexu.html', 'data/datas.js');\r
+               if ($this->book->parametres->mobileVersion == 'html5') {\r
+                       $filesToDelete[] = 'data/background/*/t*.jpg';\r
+                       $filesToDelete[] = 'data/background/contents/p*.html';\r
+               } else {\r
+                       $filesToDelete[] = 'data/background/*/p*.jpg';\r
+               }\r
+               $rm = new cubeCommandLine('rm');\r
+               $rm->setPath(CONVERTER_PATH);\r
+               foreach ($filesToDelete as $f) {\r
+                       $rm->setArg(null, $dest.'/'.$f);\r
+               }\r
+               $rm->execute();\r
+       }\r
+\r
        public function makePackage($zip) {\r
                parent::makePackage($zip);\r
                if ($zip) {\r