]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sun, 17 Jul 2011 06:18:19 +0000 (06:18 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Sun, 17 Jul 2011 06:18:19 +0000 (06:18 +0000)
21 files changed:
fluidbook/tools/convert.pe
fluidbook/tools/extract.pe [deleted file]
fluidbook/tools/extractFont.py [deleted file]
fluidbook/tools/fwstk.jar
fluidbook/tools/fwstk/.classpath
fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/CoatedFOGRA27.icc [deleted file]
fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/CoatedFOGRA39.icc [deleted file]
fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanColor2001Coated.icc [deleted file]
fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanColor2001Uncoated.icc [deleted file]
fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanColor2002Newspaper.icc [deleted file]
fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanWebCoated.icc [deleted file]
fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/USSheetfedCoated.icc [deleted file]
fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/USSheetfedUncoated.icc [deleted file]
fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/USWebUncoated.icc [deleted file]
fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/UncoatedFOGRA29.icc [deleted file]
fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/WebCoatedFOGRA28.icc [deleted file]
inc/commons/class.common.core.php
inc/ws/Controlleur/class.ws.maintenance.php
inc/ws/Metier/class.ws.document.php
inc/ws/Util/packager/html5/class.ws.packager.html5.links.php
inc/ws/Util/packager/html5/class.ws.packager.html5.php

index 1012d850a6876317b0f15ecd69644a338504e997..84528222b65ccb14e8751fe2015c52223fe6a250 100644 (file)
@@ -1,3 +1,13 @@
 #!/usr/local/bin/fontforge
-Open($1)
-Generate($2)
\ No newline at end of file
+Open($1,1)
+
+i=2;
+while ( i<=$argc-2 )
+   if (i==1)
+               MergeFonts($argv[i],1)
+   endif
+   ++i
+endloop
+
+RemoveAllKerns()
+Generate($argv[i])
\ No newline at end of file
diff --git a/fluidbook/tools/extract.pe b/fluidbook/tools/extract.pe
deleted file mode 100644 (file)
index 86b3c28..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/local/bin/fontforge
-
-a=FontsInFile($1)
-formats=Array(4);
-formats[0]='ttf';
-formats[1]='woff';
-formats[2]='svg';
-formats[3]='svgz';
-i=0
-while(i<SizeOf(a))
-       
-       e=StrSplit(a[i],"+",2)
-       name=a[i]
-       if(SizeOf(e)==2)
-               name=e[1]
-       endif
-       
-       
-       Print("open font "+$1+"("+name+")")
-       Open($1+"("+name+")")
-       Print($fontname+">"+$nextfont)
-       
-       j=0;
-       
-       while(j<SizeOf(formats))
-               out=$2+"/"+name+"."+formats[j]
-               Print("write file "+out)
-               Generate(out)
-               j++
-       endloop
-       i++
-endloop
\ No newline at end of file
diff --git a/fluidbook/tools/extractFont.py b/fluidbook/tools/extractFont.py
deleted file mode 100644 (file)
index 5501f1d..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/python
-# vim:ts=8:sw=4:expandtab:encoding=utf-8
-# Export named font from PDF file using fontforge and ctypes
-
-import sys
-from ctypes import *
-
-STRING = c_char_p
-real = c_float
-
-# We need the `map` attribute of SplineFont, so declear an incomplete struct.
-# see: http://sourceforge.net/projects/wqy/files/misc/ 
-# file: fontforge-bindctypes-0.1.tar.bz2 
-class splinefont(Structure):
-    pass
-SplineFont = splinefont
-splinefont._fields_ = [
-    ('fontname', STRING),
-    ('fullname', STRING),
-    ('familyname', STRING),
-    ('weight', STRING),
-    ('copyright', STRING),
-    ('filename', STRING),
-    ('defbasefilename', STRING),
-    ('version', STRING),
-    ('italicangle', real),
-    ('upos', real),
-    ('uwidth', real),
-    ('ascent', c_int),
-    ('descent', c_int),
-    ('uniqueid', c_int),
-    ('glyphcnt', c_int),
-    ('glyphmax', c_int),
-    ('glyphs', POINTER(c_void_p)),
-    ('changed', c_uint, 1),
-    ('changed_since_autosave', c_uint, 1),
-    ('changed_since_xuidchanged', c_uint, 1),
-    ('display_antialias', c_uint, 1),
-    ('display_bbsized', c_uint, 1),
-    ('dotlesswarn', c_uint, 1),
-    ('onlybitmaps', c_uint, 1),
-    ('serifcheck', c_uint, 1),
-    ('issans', c_uint, 1),
-    ('isserif', c_uint, 1),
-    ('hasvmetrics', c_uint, 1),
-    ('loading_cid_map', c_uint, 1),
-    ('dupnamewarn', c_uint, 1),
-    ('encodingchanged', c_uint, 1),
-    ('multilayer', c_uint, 1),
-    ('strokedfont', c_uint, 1),
-    ('new', c_uint, 1),
-    ('compacted', c_uint, 1),
-    ('backedup', c_uint, 2),
-    ('use_typo_metrics', c_uint, 1),
-    ('weight_width_slope_only', c_uint, 1),
-    ('save_to_dir', c_uint, 1),
-    ('head_optimized_for_cleartype', c_uint, 1),
-    ('ticked', c_uint, 1),
-    ('internal_temp', c_uint, 1),
-    ('complained_about_spiros', c_uint, 1),
-    ('use_xuid', c_uint, 1),
-    ('use_uniqueid', c_uint, 1),
-    ('fv', c_void_p),
-    ('metrics', c_void_p),
-    ('uni_interp', c_int),
-    ('for_new_glyphs', c_void_p),
-    ('map', c_void_p),
-    # ...
-]
-
-def main():
-    if len(sys.argv) != 3:
-        print "Usage: %s doc.pdf fontname" % sys.argv[0]
-        sys.exit(2)
-    pdfname = sys.argv[1]
-    fontname = sys.argv[2]
-    fontfile = fontname + '.ttf'
-    
-    # ctypes functions
-    libc = CDLL("libc.so.6")
-    libc.fopen.restype = c_void_p
-    libc.fopen.argtype = [c_char_p, c_char_p]
-
-    lib_ff = CDLL('libfontforge.so')
-
-    # SplineFont *_SFReadPdfFont(FILE *pdf,char *filename,
-    #     char *select_this_font, enum openflags openflags)
-    lib_ff._SFReadPdfFont.argtypes = [c_void_p, c_char_p, c_char_p, c_int]
-    lib_ff._SFReadPdfFont.restype = POINTER(SplineFont)
-
-    # int GenerateScript(SplineFont *sf, char *filename, char *bitmaptype,
-    #     int fmflags, int res, char *subfontdefinition, struct sflist *sfs,
-    #     EncMap *map, NameList *rename_to,int layer)
-    lib_ff.GenerateScript.argytpes = [POINTER(SplineFont), c_char_p, c_char_p,
-            c_int, c_int, c_char_p, c_void_p, c_void_p, c_void_p, c_int]
-    lib_ff.GenerateScript.restype = c_int
-
-    # need to somehow initialize libfontforge or it will segfault somewhere.
-    lib_ff.doinitFontForgeMain()
-    fobj = libc.fopen(pdfname, "rb")
-    if not fobj:
-        print "%s not found" % pdfname
-        sys.exit(1)
-
-    font = lib_ff._SFReadPdfFont(fobj, pdfname, fontname, 0)
-    ret = 0
-    if bool(font):
-        ret = lib_ff.GenerateScript(font, fontfile, None, -1, -1, None, None,
-                font.contents.map, None, 1)
-    if ret:
-        print 'Font export to "%s".' % fontfile
-    else:
-        print "** Error ** Failed to export font!!"
-
-if __name__ == '__main__':
-    main()
-
index 513684f3e7cb24179fcff8825427eb8c8c7b73a4..5a77a1e7a47b1a56d9229f076c9f1a207b4bdcd3 100644 (file)
Binary files a/fluidbook/tools/fwstk.jar and b/fluidbook/tools/fwstk.jar differ
index a4c76d5c35421dc56b223a0afd741ece19d14a52..94ae0a3c748dbe8b0de35507ae7888563ef5b41b 100644 (file)
@@ -1,9 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <classpath>\r
        <classpathentry kind="src" path="src"/>\r
-       <classpathentry kind="src" path="project_resources"/>\r
-       <classpathentry kind="src" path="resources"/>\r
-       <classpathentry excluding="com/fluidbook/fwstk/|com/fluidbook/fwstk/geom/|com/fluidbook/stats/|com/fluidbook/stats/lists/" kind="src" path="Java"/>\r
+       <classpathentry excluding="com/adobe/icc/rgb/" kind="src" path="project_resources"/>\r
+       <classpathentry excluding="org/apache/pdfbox/resources/cmap/" kind="src" path="resources"/>\r
+       <classpathentry excluding="com/fluidbook/fwstk/|com/fluidbook/fwstk/geom/|com/fluidbook/stats/|com/fluidbook/stats/lists/|com/maxmind/geoip/|org/jdom/|org/jdom/adapters/|org/jdom/filter/|org/jdom/input/|org/jdom/output/|org/jdom/transform/|org/jdom/xpath/|org/json/|resources/org/apache/pdfbox/resources/|resources/org/apache/pdfbox/resources/cmap/|resources/org/apache/pdfbox/resources/ttf/|jar/" kind="src" path="Java"/>\r
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_25"/>\r
        <classpathentry kind="output" path="bin"/>\r
 </classpath>\r
diff --git a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/CoatedFOGRA27.icc b/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/CoatedFOGRA27.icc
deleted file mode 100644 (file)
index e131ad0..0000000
Binary files a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/CoatedFOGRA27.icc and /dev/null differ
diff --git a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/CoatedFOGRA39.icc b/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/CoatedFOGRA39.icc
deleted file mode 100644 (file)
index 61cb86a..0000000
Binary files a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/CoatedFOGRA39.icc and /dev/null differ
diff --git a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanColor2001Coated.icc b/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanColor2001Coated.icc
deleted file mode 100644 (file)
index 5841b46..0000000
Binary files a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanColor2001Coated.icc and /dev/null differ
diff --git a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanColor2001Uncoated.icc b/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanColor2001Uncoated.icc
deleted file mode 100644 (file)
index 8ade70d..0000000
Binary files a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanColor2001Uncoated.icc and /dev/null differ
diff --git a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanColor2002Newspaper.icc b/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanColor2002Newspaper.icc
deleted file mode 100644 (file)
index 18307e2..0000000
Binary files a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanColor2002Newspaper.icc and /dev/null differ
diff --git a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanWebCoated.icc b/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanWebCoated.icc
deleted file mode 100644 (file)
index 004b8b9..0000000
Binary files a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/JapanWebCoated.icc and /dev/null differ
diff --git a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/USSheetfedCoated.icc b/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/USSheetfedCoated.icc
deleted file mode 100644 (file)
index b527d3b..0000000
Binary files a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/USSheetfedCoated.icc and /dev/null differ
diff --git a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/USSheetfedUncoated.icc b/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/USSheetfedUncoated.icc
deleted file mode 100644 (file)
index 54549a8..0000000
Binary files a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/USSheetfedUncoated.icc and /dev/null differ
diff --git a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/USWebUncoated.icc b/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/USWebUncoated.icc
deleted file mode 100644 (file)
index 75efcb2..0000000
Binary files a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/USWebUncoated.icc and /dev/null differ
diff --git a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/UncoatedFOGRA29.icc b/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/UncoatedFOGRA29.icc
deleted file mode 100644 (file)
index 70e13f5..0000000
Binary files a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/UncoatedFOGRA29.icc and /dev/null differ
diff --git a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/WebCoatedFOGRA28.icc b/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/WebCoatedFOGRA28.icc
deleted file mode 100644 (file)
index 06bf0e6..0000000
Binary files a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/WebCoatedFOGRA28.icc and /dev/null differ
index 4c2ff41e308ed6225bb7900c81894fbc6e4b0ff2..bec051d618a9777b6a75eab837095779ad0c6138 100644 (file)
@@ -14,7 +14,7 @@ class commonCore extends cubeCore {
 \r
                cubeLang::set();\r
                try {\r
-                       $this->authentifie();\r
+                       $this->authentifie(); \r
                } catch (Exception $e) {\r
                        \r
                }\r
@@ -542,7 +542,7 @@ class commonCore extends cubeCore {
                                . 'LEFT JOIN utilisateurs_entreprise r ON d.revendeur=r.utilisateur_id '\r
                                . 'LEFT JOIN utilisateurs_entreprise c ON d.utilisateur=c.utilisateur_id '\r
                                . 'LEFT JOIN utilisateurs a ON d.administrateur=a.utilisateur_id');\r
-               // cubeDb::mysqlConvert($this->con);\r
+               cubeDb::mysqlConvert($this->con, 'UTF8', 'utf8_general_ci', 'MYISAM');  \r
                touch($cache);\r
        }\r
 \r
index 05d23aebeae822de5aaf21b6006d9c5168879e52..b145873342aeb9d86c3453beb3ec7203fdf8a1ff 100644 (file)
@@ -463,6 +463,23 @@ class wsMaintenance {
 \r
        public static function cleanPackages() {\r
                $limit = TIME - (4 * 3600); // 4 heures avant maintenant*\r
+               // Clean downloads\r
+               $dir = ROOT . '/cache/download/';\r
+               $dr = opendir($dir);\r
+               while ($file = readdir($dr)) {\r
+                       if ($file == '.' || $file == '..') {\r
+                               continue;\r
+                       }\r
+                       $f = $dir . $file;\r
+                       if (!is_dir($f)) {\r
+                               continue;\r
+                       }\r
+                       if (filemtime($f) > $limit) {\r
+                               continue;\r
+                       }\r
+                       `rm -rf $f`;\r
+               }\r
+\r
                // Clean downloaded packages\r
                $dir = WS_FILES . '/packager/download/';\r
                $dr = opendir($dir);\r
index 2f115dc0ee1e5233a4a046b5c6e7788ae4b00034..db68cf141924d37fd400b3ea6286cecbe9f6f21f 100644 (file)
@@ -101,19 +101,29 @@ class wsDocument extends cubeMetier {
                        mkdir($out, 0777, true);\r
                }\r
                // Extract fonts from PDF\r
-               $gs = new cubeCommandLine('gs');\r
-               $gs->setPath(CONVERTER_PATH);\r
-               $gs->cd($out);\r
-               $gs->setArg('-dBATCH');\r
-               $gs->setArg('-dNOPAUSE');\r
-               $gs->setArg('-dNOPROMPT');\r
-               $gs->setArg('-dNODISPLAY');\r
-               $gs->setArg(null, WS_TOOLS . '/extractFonts.ps');\r
-               $gs->setManualArg('-c "(' . $this->in . ') extractFonts quit"');\r
-\r
-               $gs->execute();\r
-               $this->addToLog($gs);\r
-\r
+               /* $gs = new cubeCommandLine('gs');\r
+                 $gs->setPath(CONVERTER_PATH);\r
+                 $gs->cd($out);\r
+                 $gs->setArg('-dBATCH');\r
+                 $gs->setArg('-dNOPAUSE');\r
+                 $gs->setArg('-dNOPROMPT');\r
+                 $gs->setArg('-dNODISPLAY');\r
+                 $gs->setArg(null, WS_TOOLS . '/extractFonts.ps');\r
+                 $gs->setManualArg('-c "(' . $this->in . ') extractFonts quit"');\r
+\r
+                 $gs->execute();\r
+                 $this->addToLog($gs); */\r
+\r
+               $mupdf = new cubeCommandLine('/usr/local/mupdf/pdfextract');\r
+               $mupdf->setPath(CONVERTER_PATH);\r
+               $mupdf->cd($out);\r
+               $mupdf->setArg(null, $this->in);\r
+               $mupdf->execute();\r
+               $this->addToLog($mupdf);\r
+\r
+\r
+               `rm $out/fonts/*.png`;\r
+               `rm $out/fonts/*.pam`;\r
                $dr = opendir($out);\r
 \r
                if (!file_exists($this->out . '/fonts/web')) {\r
@@ -121,6 +131,7 @@ class wsDocument extends cubeMetier {
                }\r
                $formats = array('ttf', 'woff', 'svg', 'svgz', 'eot');\r
                // Fonts conversion\r
+               $collections = array();\r
                while ($file = readdir($dr)) {\r
                        if ($file == '.' || $file == '..') {\r
                                continue;\r
@@ -130,17 +141,30 @@ class wsDocument extends cubeMetier {
                        array_pop($e);\r
                        $fname = implode('.', $e);\r
 \r
+                       $e = explode('-', $fname);\r
+                       array_pop($e);\r
+                       $fname = implode('-', $e);\r
+\r
+                       if (!isset($collections[$fname])) {\r
+                               $collections[$fname] = array();\r
+                       }\r
+                       $collections[$fname][] = $file;\r
+               }\r
+\r
+               foreach ($collections as $fontname => $files) {\r
                        foreach ($formats as $format) {\r
                                if ($format == 'eot') {\r
-                                       $ttf2eot = new cubeCommandLine('ttf2eot', $this->out . '/fonts/web/' . $fname . '.eot');\r
+                                       $ttf2eot = new cubeCommandLine('ttf2eot', $this->out . '/fonts/web/' . $fontname . '.eot');\r
                                        $ttf2eot->setPath(CONVERTER_PATH);\r
-                                       $ttf2eot->setManualArg('< ' . $this->out . '/fonts/web/' . $fname . '.ttf');\r
+                                       $ttf2eot->setManualArg('< ' . $this->out . '/fonts/web/' . $fontname . '.ttf');\r
                                        $ttf2eot->execute();\r
                                } else {\r
                                        $fontforge = new cubeCommandLine('convert.pe');\r
                                        $fontforge->setPath(CONVERTER_PATH);\r
-                                       $fontforge->setArg(null, $out . '/' . $file);\r
-                                       $fontforge->setArg(null, $this->out . '/fonts/web/' . $fname . '.' . $format);\r
+                                       foreach ($files as $file) {\r
+                                               $fontforge->setArg(null, $out . '/' . $file);\r
+                                       }\r
+                                       $fontforge->setArg(null, $this->out . '/fonts/web/' . $fontname . '.' . $format);\r
                                        $fontforge->execute();\r
                                        $this->addToLog($fontforge);\r
                                }\r
@@ -607,7 +631,7 @@ class wsDocument extends cubeMetier {
                // Then make HD background shots\r
                $resolutions = array(36 => 80, 72 => 70, 150 => 50);\r
                foreach ($resolutions as $r => $q) {\r
-                       $texts=false;\r
+                       $texts = false;\r
                        $this->makeShotPNM($page, 'html/h' . $r . '-', $r, $q, 4, null, $texts);\r
                }\r
        }\r
index 3a5c151997081faf2deb72e1bba0478f7287fc64..6d83540dbc9f54a100996ab28c510b6b0dbf8e81 100644 (file)
@@ -99,7 +99,7 @@ class wsPackagerHTML5Link {
        }
 
        public function getCSS() {
-               return 'border:1px dotter #ff0000;';
+               return '';
        }
 
        public static function getUniversalLocation($loc, $css=false) {
index 450373e548cb010c69d6aa462d557cb14a5f44e4..7ed6f2ef1cad2f386c16929cf884afab08b575bf 100644 (file)
@@ -36,7 +36,7 @@ class wsPackagerHTML5 extends wsPackager {
                }\r
 \r
                $imagesize = getimagesize(WS_DOCS . '/' . $this->pages[1]['document_id'] . '/html/h72-' . $this->pages[1]['document_page'] . '.jpg');\r
-               $this->pdf2htmlRatio = $imagesize[0] / $this->layouts[1]['width'];\r
+               $this->pdf2htmlRatio = round($imagesize[0] / $this->layouts[1]['width'], 2);\r
                $this->scale = 4;\r
                $this->multiply = $this->pdf2htmlRatio * $this->scale;\r
                $this->numerotation = explode(',', $this->book->numerotation);\r
@@ -57,11 +57,25 @@ class wsPackagerHTML5 extends wsPackager {
                return $p + 1;\r
        }\r
 \r
+       protected function compareLines($a, $b) {\r
+               if ((float) $a['y'] > (float) $b['y']) {\r
+                       return 1;\r
+               } else {\r
+                       return -1;\r
+               }\r
+       }\r
+\r
        protected function createHTML() {\r
                foreach ($this->layouts as $page => $layout) {\r
                        $this->div[$page] = array();\r
                        $document_id = $this->pages[$page]['document_id'];\r
+                       $lines = array();\r
                        foreach ($layout->l as $line) {\r
+                               $lines[] = $line;\r
+                       }\r
+                       usort($lines, array($this, 'compareLines'));\r
+\r
+                       foreach ($lines as $line) {\r
                                $this->div[$page][] = $this->addLine($line, $document_id);\r
                        }\r
                }\r
@@ -190,37 +204,20 @@ class wsPackagerHTML5 extends wsPackager {
        }\r
 \r
        protected function writeLine($line) {\r
-               $line['x'] = $this->getCSSX($line['x'] * $this->multiply);\r
-               $line['y'] = $this->getCSSY($line['y'] * $this->multiply);\r
-\r
-               $class = array('l');\r
-               if (!is_null($line['rotation'])) {\r
-                       $class[] = 'r' . $line['rotation'];\r
-               }\r
-               if (!is_null($line['x'])) {\r
-                       $class[] = 'x' . $line['x'];\r
-               }\r
-               if (!is_null($line['y'])) {\r
-                       $class[] = 'y' . $line['y'];\r
-               }\r
-               $class = implode(' ', $class);\r
-\r
-\r
-               $res = '<div class="' . $class . '">';\r
+               $res = '';\r
                foreach ($line['groups'] as $group) {\r
-                       $res.=$this->writeGroup($group);\r
+                       $res.=$this->writeGroup($group, $line);\r
                }\r
-               $res.='</div>';\r
                return $res;\r
        }\r
 \r
-       protected function writeGroup($group) {\r
+       protected function writeGroup($group, $line) {\r
                if ($group === false) {\r
                        return '';\r
                }\r
 \r
-               $group['y'] = $this->getCSSY($group['y'] * $this->multiply);\r
-               $group['x'] = $this->getCSSX($group['x'] * $this->multiply);\r
+               $group['y'] = $this->getCSSY(($group['y'] + $line['y']) * $this->multiply);\r
+               $group['x'] = $this->getCSSX(($group['x']) * $this->multiply);\r
 \r
                $class = array('g');\r
                if (!is_null($group['color'])) {\r
@@ -238,6 +235,9 @@ class wsPackagerHTML5 extends wsPackager {
                if (!is_null($group['y'])) {\r
                        $class[] = 'y' . $group['y'];\r
                }\r
+               if (!is_null($line['rotation'])) {\r
+                       $class[] = 'r' . $line['rotation'];\r
+               }\r
                if (!is_null($group['letterspacing'])) {\r
                        $class[] = 'l' . $group['letterspacing'];\r
                }\r
@@ -259,7 +259,11 @@ class wsPackagerHTML5 extends wsPackager {
                        return '';\r
                }\r
 \r
-               return self::escapeHTML($span['text']);\r
+               if ($span['space']) {\r
+                       return $span['text'];\r
+               } else {\r
+                       return self::escapeHTML($span['text']);\r
+               }\r
        }\r
 \r
        protected function writeCSS($file, $links) {\r
@@ -277,7 +281,7 @@ class wsPackagerHTML5 extends wsPackager {
                $res[] = '.portrait #pages,.portrait .doublePage.page,.page,.portrait #shadow,#shadow.single,.page .links{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}';\r
                $res[] = '.background{' . $this->writeCSSUA('transform-origin', 'top left') . ';}';\r
                foreach (self::$resolutions as $r) {\r
-                       $ratio = 72 / $r;\r
+                       $ratio = round(72 / $r, 2);\r
                        $wr = $this->book->parametres->width / $ratio;\r
                        $hr = $this->book->parametres->height / $ratio;\r
 \r
@@ -292,7 +296,7 @@ class wsPackagerHTML5 extends wsPackager {
                $res[] = '.landscape #shadow.single.right{left: ' . $w . ';}';\r
                $res[] = '.landscape .page.right{left:' . $w . '}';\r
                $texts = '.texts{' . $this->writeCSSUA('transform-origin', 'top left') . ';';\r
-               $texts.=$this->writeCSSUA('transform', 'scale(' . (1 / $this->multiply) . ')') . ';';\r
+               $texts.=$this->writeCSSUA('transform', 'scale(' . round(1 / $this->multiply, 2) . ')') . ';';\r
                $texts.='width:' . $wm . '; max-width:' . $wm . ';';\r
                $texts.='height:' . $hm . '; max-height:' . $hm . ';';\r
                $texts.='}';\r
@@ -439,7 +443,9 @@ class wsPackagerHTML5 extends wsPackager {
 \r
                        $css = '.r' . $index . '{';\r
                        $css.=self::writeCSSUA('transform', 'rotate(' . $rotation . 'deg)') . ';';\r
-                       $css.=self::writeCSSUA('transform-origin', 'left top');\r
+                       $css.=self::writeCSSUA('transform-origin', 'left top') . ';';\r
+                       $css.='margin-top:' . round(cos(deg2rad($rotation)) * -1, 2) . 'em !important;';\r
+                       $css.='margin-left:' . round(sin(deg2rad($rotation)), 2) . 'em !important;';\r
                        $css.='}';\r
                        $res[] = $css;\r
                }\r
@@ -467,9 +473,9 @@ class wsPackagerHTML5 extends wsPackager {
        protected function addLine($line, $document_id) {\r
                $res = array();\r
                foreach ($line->a as $group) {\r
-                       $res[] = $this->addGroup($group, $document_id);\r
+                       $res = array_merge($res, $this->addGroup($group, $document_id));\r
                }\r
-               return array('x' => $this->normalizeFloatValue($line['x']),\r
+               return array(\r
                        'y' => $this->normalizeFloatValue($line['y']),\r
                        'rotation' => $this->getCSSRotation($this->normalizeFloatValue($line['rotation'], 0)),\r
                        "groups" => $res);\r
@@ -481,43 +487,135 @@ class wsPackagerHTML5 extends wsPackager {
                        return false;\r
                }\r
 \r
+               $first = true;\r
+               $letterSpacing = 0;\r
+               $letterCount = 0;\r
+               $wordSpacing = 0;\r
+               $wordCount = 0;\r
+\r
                $res = array();\r
+               $spans = array();\r
 \r
-               $first = true;\r
                foreach ($group->s as $span) {\r
+                       if ($first && trim((string) $span) == '') {\r
+                               continue;\r
+                       }\r
                        if ($first) {\r
-                               $x = $span['x'];\r
+                               $pos = $x = $span['x'];\r
+                               $pos+=$span['width'];\r
                                $first = false;\r
+                       } else {\r
+                               if ((string) $span == 'MARDI 19') {\r
+                                       fb($span['x'], $newSpan['x']);\r
+                               }\r
+                               if ((float) $span['x'] < (float) $newSpan['x']) {\r
+                                       // On change de groupe\r
+                                       $ls = $ws = 0;\r
+                                       if ($letterCount > 0) {\r
+                                               $ls = $letterSpacing / $letterCount;\r
+                                       }\r
+                                       if ($wordCount > 0) {\r
+                                               $ws = $wordSpacing / $wordCount;\r
+                                       }\r
+\r
+                                       $res[] = array(\r
+                                               'color' => $this->getCSSColor($group['color']),\r
+                                               'size' => $this->getCSSSize($group['size']),\r
+                                               'font' => $this->getCSSFont($group['font'], $document_id),\r
+                                               'letterspacing' => $this->getCSSLetterSpacing($ls),\r
+                                               'wordspacing' => $this->getCSSLetterSpacing($ws),\r
+                                               'y' => 0,\r
+                                               'x' => $x,\r
+                                               'spans' => $spans);\r
+\r
+                                       $spans = array();\r
+                                       $pos = $x = $span['x'];\r
+                                       $pos+=$span['width'];\r
+                               } else {\r
+\r
+                                       $diff = $span['x'] - $pos;\r
+                                       if ($diff > $group['size'] / 4) {\r
+                                               $space = round($diff / $group['size'], 4);\r
+                                               if ($space > 2) {\r
+                                                       // On change de groupe\r
+                                                       $ls = $ws = 0;\r
+                                                       if ($letterCount > 0) {\r
+                                                               $ls = $letterSpacing / $letterCount;\r
+                                                       }\r
+                                                       if ($wordCount > 0) {\r
+                                                               $ws = $wordSpacing / $wordCount;\r
+                                                       }\r
+                                                       $res[] = array(\r
+                                                               'color' => $this->getCSSColor($group['color']),\r
+                                                               'size' => $this->getCSSSize($group['size']),\r
+                                                               'font' => $this->getCSSFont($group['font'], $document_id),\r
+                                                               'letterspacing' => $this->getCSSLetterSpacing($ls),\r
+                                                               'wordspacing' => $this->getCSSLetterSpacing($ws),\r
+                                                               'y' => 0,\r
+                                                               'x' => $x,\r
+                                                               'spans' => $spans);\r
+\r
+                                                       $spans = array();\r
+                                                       $pos = $x = $span['x'];\r
+                                                       $pos+=$span['width'];\r
+                                               } else {\r
+\r
+                                                       $newSpan = $this->addSpan('<span style="width:' . $space . 'em;"> </span>', true);\r
+                                                       array_push($spans, $newSpan);\r
+                                               }\r
+                                       }\r
+                               }\r
                        }\r
-                       $newSpan = $this->addSpan($span, $document_id);\r
 \r
-                       array_push($res, $newSpan);\r
+\r
+                       $newSpan = $this->addSpan($span);\r
+                       $pos = $span['x'] + $span['width'];\r
+\r
+                       array_push($spans, $newSpan);\r
+                       $copy = (string) $span;\r
+                       $len = mb_strlen($copy);\r
+                       str_replace(' ', '-', $copy, $w);\r
+                       $l = $len - $w;\r
+\r
+                       $letterCount+=$l;\r
+                       $wordCount+=$w;\r
+\r
+                       $letterSpacing+=$l * (float) $span['letterspacing'];\r
+                       $wordSpacing+=$w * (float) $span['wordspacing'];\r
                }\r
 \r
-               return array(\r
-                       'color' => $this->getCSSColor($group['color']),\r
-                       'size' => $this->getCSSSize($group['size']),\r
-                       'font' => $this->getCSSFont($group['font'], $document_id),\r
-                       'letterspacing' => $this->getCSSLetterSpacing($group['letterspacing']),\r
-                       'wordspacing' => $this->getCSSWordSpacing($group['wordspacing']),\r
-                       'y' => ($group['size']) / -1.2,\r
-                       'x' => $x,\r
-                       'spans' => $res);\r
-       }\r
+               if (count($spans)) {\r
+                       $ls = $ws = 0;\r
+                       if ($letterCount > 0) {\r
+                               $ls = $letterSpacing / $letterCount;\r
+                       }\r
+                       if ($wordCount > 0) {\r
+                               $ws = $wordSpacing / $wordCount;\r
+                       }\r
 \r
-       protected function addSpan($span, $document_id) {\r
+                       $res[] = array(\r
+                               'color' => $this->getCSSColor($group['color']),\r
+                               'size' => $this->getCSSSize($group['size']),\r
+                               'font' => $this->getCSSFont($group['font'], $document_id),\r
+                               'letterspacing' => $this->getCSSLetterSpacing($ls),\r
+                               'wordspacing' => $this->getCSSLetterSpacing($ws),\r
+                               'y' => 0,\r
+                               'x' => $x,\r
+                               'spans' => $spans);\r
+               }\r
 \r
+               return $res;\r
+       }\r
+\r
+       protected function addSpan($span, $space=false) {\r
                $text = (string) $span;\r
-               if ($text == '') {\r
-                       return false;\r
-               }\r
-               return array('text' => $text);\r
+               return array('text' => $text, 'space' => $space, 'x' => $span['x']);\r
        }\r
 \r
-       protected function getCSSSize(&$size) {\r
-               $size = $this->normalizeFloatValue($size * $this->multiply, 3);\r
-               $sizer = $size;\r
-               return $this->getIndex($sizer, $this->cssSize);\r
+       protected function getCSSSize($size) {\r
+               $size = $this->normalizeFloatValue($size);\r
+               $size*=$this->multiply;\r
+               return $this->getIndex($size, $this->cssSize);\r
        }\r
 \r
        protected function getCSSFont($font, $document_id) {\r