\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
</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
SetUnicodeValue(UCodePoint(uto))
j++
endif
- endloop
+ endloop
endif
-
i++
+RemoveAllKerns()
Print("Write font ",$argv[i])
Generate($argv[i])
\ No newline at end of file
<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=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file)\r
+ or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> 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
<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
<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
<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
<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
<classpath>\r
<path path="@{classpath}"/>\r
</classpath>\r
+ <bootclasspath>\r
+ <path path="${platform.bootcp}"/>\r
+ </bootclasspath>\r
</nbjpdastart>\r
</sequential>\r
</macrodef>\r
</macrodef>\r
</target>\r
<target name="-init-debug-args">\r
- <property name="version-output" value="java version "${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 "1.0"/>\r
<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
<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
<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
<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
-->\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
-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
<?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
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
<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
--- /dev/null
+/*
+ * 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;
+ }
+ }
+}
/**
* 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
if (!currentChar.equals(c)) {
if (c.toUpperCase().equals(currentChar)) {
c = c.toUpperCase();
- } else if (c.toLowerCase().equals(currentChar)) {
- c = c.toLowerCase();
}
}
} catch (NullPointerException e) {
public void process(PDFOperator operator, List<COSBase> arguments) throws IOException {
COSString string = (COSString) arguments.get(0);
context.setCurrentString(string.getString());
+
context.processEncodedText(string.getBytes());
+
}
}
} 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);
}
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
$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
$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
$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
protected $outweb;
protected $fonts = array();
protected $cmaps = array();
+ protected $descendants = array();
+ protected $descendantNames = array();
protected $doc;
public function __construct($in, $doc=null) {
}
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) {
$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
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);
continue;
}
$e = explode(' ', $line);
- if (count($e)==3 && $e[2] == 'obj') {
+ if (count($e) == 3 && $e[2] == 'obj') {
$currentFont = $e[0];
continue;
}
$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');
}
$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;
}
$finalCmaps[$fontname] = array();
}
+ if (strlen($to) >= 8) {
+ $toc = $to;
+ $to = $this->manageLigatures($to);
+ $this->addToLog('Correct ligature ' . $toc . ' -> ' . $to);
+ }
+
$finalCmaps[$fontname][$from] = $to;
}
}
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) {
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');
$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'];
$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}';
}
$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;
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) {
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;
}
}\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
}\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