From: vincent@cubedesigners.com Date: Sun, 17 Jul 2011 06:18:19 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=70f78a69a991fe70d0b1f4b9dc05f5f657ecb076;p=cubeextranet.git --- diff --git a/fluidbook/tools/convert.pe b/fluidbook/tools/convert.pe index 1012d850a..84528222b 100644 --- a/fluidbook/tools/convert.pe +++ b/fluidbook/tools/convert.pe @@ -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 index 86b3c2853..000000000 --- a/fluidbook/tools/extract.pe +++ /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"+$nextfont) - - j=0; - - while(j - - - + + + 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 index e131ad00d..000000000 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 index 61cb86a59..000000000 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 index 5841b46fd..000000000 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 index 8ade70de0..000000000 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 index 18307e270..000000000 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 index 004b8b9d3..000000000 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 index b527d3b5a..000000000 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 index 54549a84e..000000000 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 index 75efcb259..000000000 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 index 70e13f561..000000000 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 index 06bf0e63b..000000000 Binary files a/fluidbook/tools/fwstk/project_resources/com/adobe/icc/cmyk/WebCoatedFOGRA28.icc and /dev/null differ diff --git a/inc/commons/class.common.core.php b/inc/commons/class.common.core.php index 4c2ff41e3..bec051d61 100644 --- a/inc/commons/class.common.core.php +++ b/inc/commons/class.common.core.php @@ -14,7 +14,7 @@ class commonCore extends cubeCore { cubeLang::set(); try { - $this->authentifie(); + $this->authentifie(); } catch (Exception $e) { } @@ -542,7 +542,7 @@ class commonCore extends cubeCore { . 'LEFT JOIN utilisateurs_entreprise r ON d.revendeur=r.utilisateur_id ' . 'LEFT JOIN utilisateurs_entreprise c ON d.utilisateur=c.utilisateur_id ' . 'LEFT JOIN utilisateurs a ON d.administrateur=a.utilisateur_id'); - // cubeDb::mysqlConvert($this->con); + cubeDb::mysqlConvert($this->con, 'UTF8', 'utf8_general_ci', 'MYISAM'); touch($cache); } diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 05d23aebe..b14587334 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -463,6 +463,23 @@ class wsMaintenance { public static function cleanPackages() { $limit = TIME - (4 * 3600); // 4 heures avant maintenant* + // Clean downloads + $dir = ROOT . '/cache/download/'; + $dr = opendir($dir); + while ($file = readdir($dr)) { + if ($file == '.' || $file == '..') { + continue; + } + $f = $dir . $file; + if (!is_dir($f)) { + continue; + } + if (filemtime($f) > $limit) { + continue; + } + `rm -rf $f`; + } + // Clean downloaded packages $dir = WS_FILES . '/packager/download/'; $dr = opendir($dir); diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index 2f115dc0e..db68cf141 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -101,19 +101,29 @@ class wsDocument extends cubeMetier { mkdir($out, 0777, true); } // Extract fonts from PDF - $gs = new cubeCommandLine('gs'); - $gs->setPath(CONVERTER_PATH); - $gs->cd($out); - $gs->setArg('-dBATCH'); - $gs->setArg('-dNOPAUSE'); - $gs->setArg('-dNOPROMPT'); - $gs->setArg('-dNODISPLAY'); - $gs->setArg(null, WS_TOOLS . '/extractFonts.ps'); - $gs->setManualArg('-c "(' . $this->in . ') extractFonts quit"'); - - $gs->execute(); - $this->addToLog($gs); - + /* $gs = new cubeCommandLine('gs'); + $gs->setPath(CONVERTER_PATH); + $gs->cd($out); + $gs->setArg('-dBATCH'); + $gs->setArg('-dNOPAUSE'); + $gs->setArg('-dNOPROMPT'); + $gs->setArg('-dNODISPLAY'); + $gs->setArg(null, WS_TOOLS . '/extractFonts.ps'); + $gs->setManualArg('-c "(' . $this->in . ') extractFonts quit"'); + + $gs->execute(); + $this->addToLog($gs); */ + + $mupdf = new cubeCommandLine('/usr/local/mupdf/pdfextract'); + $mupdf->setPath(CONVERTER_PATH); + $mupdf->cd($out); + $mupdf->setArg(null, $this->in); + $mupdf->execute(); + $this->addToLog($mupdf); + + + `rm $out/fonts/*.png`; + `rm $out/fonts/*.pam`; $dr = opendir($out); if (!file_exists($this->out . '/fonts/web')) { @@ -121,6 +131,7 @@ class wsDocument extends cubeMetier { } $formats = array('ttf', 'woff', 'svg', 'svgz', 'eot'); // Fonts conversion + $collections = array(); while ($file = readdir($dr)) { if ($file == '.' || $file == '..') { continue; @@ -130,17 +141,30 @@ class wsDocument extends cubeMetier { array_pop($e); $fname = implode('.', $e); + $e = explode('-', $fname); + array_pop($e); + $fname = implode('-', $e); + + if (!isset($collections[$fname])) { + $collections[$fname] = array(); + } + $collections[$fname][] = $file; + } + + foreach ($collections as $fontname => $files) { foreach ($formats as $format) { if ($format == 'eot') { - $ttf2eot = new cubeCommandLine('ttf2eot', $this->out . '/fonts/web/' . $fname . '.eot'); + $ttf2eot = new cubeCommandLine('ttf2eot', $this->out . '/fonts/web/' . $fontname . '.eot'); $ttf2eot->setPath(CONVERTER_PATH); - $ttf2eot->setManualArg('< ' . $this->out . '/fonts/web/' . $fname . '.ttf'); + $ttf2eot->setManualArg('< ' . $this->out . '/fonts/web/' . $fontname . '.ttf'); $ttf2eot->execute(); } else { $fontforge = new cubeCommandLine('convert.pe'); $fontforge->setPath(CONVERTER_PATH); - $fontforge->setArg(null, $out . '/' . $file); - $fontforge->setArg(null, $this->out . '/fonts/web/' . $fname . '.' . $format); + foreach ($files as $file) { + $fontforge->setArg(null, $out . '/' . $file); + } + $fontforge->setArg(null, $this->out . '/fonts/web/' . $fontname . '.' . $format); $fontforge->execute(); $this->addToLog($fontforge); } @@ -607,7 +631,7 @@ class wsDocument extends cubeMetier { // Then make HD background shots $resolutions = array(36 => 80, 72 => 70, 150 => 50); foreach ($resolutions as $r => $q) { - $texts=false; + $texts = false; $this->makeShotPNM($page, 'html/h' . $r . '-', $r, $q, 4, null, $texts); } } diff --git a/inc/ws/Util/packager/html5/class.ws.packager.html5.links.php b/inc/ws/Util/packager/html5/class.ws.packager.html5.links.php index 3a5c15199..6d83540db 100644 --- a/inc/ws/Util/packager/html5/class.ws.packager.html5.links.php +++ b/inc/ws/Util/packager/html5/class.ws.packager.html5.links.php @@ -99,7 +99,7 @@ class wsPackagerHTML5Link { } public function getCSS() { - return 'border:1px dotter #ff0000;'; + return ''; } public static function getUniversalLocation($loc, $css=false) { diff --git a/inc/ws/Util/packager/html5/class.ws.packager.html5.php b/inc/ws/Util/packager/html5/class.ws.packager.html5.php index 450373e54..7ed6f2ef1 100644 --- a/inc/ws/Util/packager/html5/class.ws.packager.html5.php +++ b/inc/ws/Util/packager/html5/class.ws.packager.html5.php @@ -36,7 +36,7 @@ class wsPackagerHTML5 extends wsPackager { } $imagesize = getimagesize(WS_DOCS . '/' . $this->pages[1]['document_id'] . '/html/h72-' . $this->pages[1]['document_page'] . '.jpg'); - $this->pdf2htmlRatio = $imagesize[0] / $this->layouts[1]['width']; + $this->pdf2htmlRatio = round($imagesize[0] / $this->layouts[1]['width'], 2); $this->scale = 4; $this->multiply = $this->pdf2htmlRatio * $this->scale; $this->numerotation = explode(',', $this->book->numerotation); @@ -57,11 +57,25 @@ class wsPackagerHTML5 extends wsPackager { return $p + 1; } + protected function compareLines($a, $b) { + if ((float) $a['y'] > (float) $b['y']) { + return 1; + } else { + return -1; + } + } + protected function createHTML() { foreach ($this->layouts as $page => $layout) { $this->div[$page] = array(); $document_id = $this->pages[$page]['document_id']; + $lines = array(); foreach ($layout->l as $line) { + $lines[] = $line; + } + usort($lines, array($this, 'compareLines')); + + foreach ($lines as $line) { $this->div[$page][] = $this->addLine($line, $document_id); } } @@ -190,37 +204,20 @@ class wsPackagerHTML5 extends wsPackager { } protected function writeLine($line) { - $line['x'] = $this->getCSSX($line['x'] * $this->multiply); - $line['y'] = $this->getCSSY($line['y'] * $this->multiply); - - $class = array('l'); - if (!is_null($line['rotation'])) { - $class[] = 'r' . $line['rotation']; - } - if (!is_null($line['x'])) { - $class[] = 'x' . $line['x']; - } - if (!is_null($line['y'])) { - $class[] = 'y' . $line['y']; - } - $class = implode(' ', $class); - - - $res = '
'; + $res = ''; foreach ($line['groups'] as $group) { - $res.=$this->writeGroup($group); + $res.=$this->writeGroup($group, $line); } - $res.='
'; return $res; } - protected function writeGroup($group) { + protected function writeGroup($group, $line) { if ($group === false) { return ''; } - $group['y'] = $this->getCSSY($group['y'] * $this->multiply); - $group['x'] = $this->getCSSX($group['x'] * $this->multiply); + $group['y'] = $this->getCSSY(($group['y'] + $line['y']) * $this->multiply); + $group['x'] = $this->getCSSX(($group['x']) * $this->multiply); $class = array('g'); if (!is_null($group['color'])) { @@ -238,6 +235,9 @@ class wsPackagerHTML5 extends wsPackager { if (!is_null($group['y'])) { $class[] = 'y' . $group['y']; } + if (!is_null($line['rotation'])) { + $class[] = 'r' . $line['rotation']; + } if (!is_null($group['letterspacing'])) { $class[] = 'l' . $group['letterspacing']; } @@ -259,7 +259,11 @@ class wsPackagerHTML5 extends wsPackager { return ''; } - return self::escapeHTML($span['text']); + if ($span['space']) { + return $span['text']; + } else { + return self::escapeHTML($span['text']); + } } protected function writeCSS($file, $links) { @@ -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 . '}'; $res[] = '.background{' . $this->writeCSSUA('transform-origin', 'top left') . ';}'; foreach (self::$resolutions as $r) { - $ratio = 72 / $r; + $ratio = round(72 / $r, 2); $wr = $this->book->parametres->width / $ratio; $hr = $this->book->parametres->height / $ratio; @@ -292,7 +296,7 @@ class wsPackagerHTML5 extends wsPackager { $res[] = '.landscape #shadow.single.right{left: ' . $w . ';}'; $res[] = '.landscape .page.right{left:' . $w . '}'; $texts = '.texts{' . $this->writeCSSUA('transform-origin', 'top left') . ';'; - $texts.=$this->writeCSSUA('transform', 'scale(' . (1 / $this->multiply) . ')') . ';'; + $texts.=$this->writeCSSUA('transform', 'scale(' . round(1 / $this->multiply, 2) . ')') . ';'; $texts.='width:' . $wm . '; max-width:' . $wm . ';'; $texts.='height:' . $hm . '; max-height:' . $hm . ';'; $texts.='}'; @@ -439,7 +443,9 @@ class wsPackagerHTML5 extends wsPackager { $css = '.r' . $index . '{'; $css.=self::writeCSSUA('transform', 'rotate(' . $rotation . 'deg)') . ';'; - $css.=self::writeCSSUA('transform-origin', 'left top'); + $css.=self::writeCSSUA('transform-origin', 'left top') . ';'; + $css.='margin-top:' . round(cos(deg2rad($rotation)) * -1, 2) . 'em !important;'; + $css.='margin-left:' . round(sin(deg2rad($rotation)), 2) . 'em !important;'; $css.='}'; $res[] = $css; } @@ -467,9 +473,9 @@ class wsPackagerHTML5 extends wsPackager { protected function addLine($line, $document_id) { $res = array(); foreach ($line->a as $group) { - $res[] = $this->addGroup($group, $document_id); + $res = array_merge($res, $this->addGroup($group, $document_id)); } - return array('x' => $this->normalizeFloatValue($line['x']), + return array( 'y' => $this->normalizeFloatValue($line['y']), 'rotation' => $this->getCSSRotation($this->normalizeFloatValue($line['rotation'], 0)), "groups" => $res); @@ -481,43 +487,135 @@ class wsPackagerHTML5 extends wsPackager { return false; } + $first = true; + $letterSpacing = 0; + $letterCount = 0; + $wordSpacing = 0; + $wordCount = 0; + $res = array(); + $spans = array(); - $first = true; foreach ($group->s as $span) { + if ($first && trim((string) $span) == '') { + continue; + } if ($first) { - $x = $span['x']; + $pos = $x = $span['x']; + $pos+=$span['width']; $first = false; + } else { + if ((string) $span == 'MARDI 19') { + fb($span['x'], $newSpan['x']); + } + if ((float) $span['x'] < (float) $newSpan['x']) { + // On change de groupe + $ls = $ws = 0; + if ($letterCount > 0) { + $ls = $letterSpacing / $letterCount; + } + if ($wordCount > 0) { + $ws = $wordSpacing / $wordCount; + } + + $res[] = array( + 'color' => $this->getCSSColor($group['color']), + 'size' => $this->getCSSSize($group['size']), + 'font' => $this->getCSSFont($group['font'], $document_id), + 'letterspacing' => $this->getCSSLetterSpacing($ls), + 'wordspacing' => $this->getCSSLetterSpacing($ws), + 'y' => 0, + 'x' => $x, + 'spans' => $spans); + + $spans = array(); + $pos = $x = $span['x']; + $pos+=$span['width']; + } else { + + $diff = $span['x'] - $pos; + if ($diff > $group['size'] / 4) { + $space = round($diff / $group['size'], 4); + if ($space > 2) { + // On change de groupe + $ls = $ws = 0; + if ($letterCount > 0) { + $ls = $letterSpacing / $letterCount; + } + if ($wordCount > 0) { + $ws = $wordSpacing / $wordCount; + } + $res[] = array( + 'color' => $this->getCSSColor($group['color']), + 'size' => $this->getCSSSize($group['size']), + 'font' => $this->getCSSFont($group['font'], $document_id), + 'letterspacing' => $this->getCSSLetterSpacing($ls), + 'wordspacing' => $this->getCSSLetterSpacing($ws), + 'y' => 0, + 'x' => $x, + 'spans' => $spans); + + $spans = array(); + $pos = $x = $span['x']; + $pos+=$span['width']; + } else { + + $newSpan = $this->addSpan(' ', true); + array_push($spans, $newSpan); + } + } + } } - $newSpan = $this->addSpan($span, $document_id); - array_push($res, $newSpan); + + $newSpan = $this->addSpan($span); + $pos = $span['x'] + $span['width']; + + array_push($spans, $newSpan); + $copy = (string) $span; + $len = mb_strlen($copy); + str_replace(' ', '-', $copy, $w); + $l = $len - $w; + + $letterCount+=$l; + $wordCount+=$w; + + $letterSpacing+=$l * (float) $span['letterspacing']; + $wordSpacing+=$w * (float) $span['wordspacing']; } - return array( - 'color' => $this->getCSSColor($group['color']), - 'size' => $this->getCSSSize($group['size']), - 'font' => $this->getCSSFont($group['font'], $document_id), - 'letterspacing' => $this->getCSSLetterSpacing($group['letterspacing']), - 'wordspacing' => $this->getCSSWordSpacing($group['wordspacing']), - 'y' => ($group['size']) / -1.2, - 'x' => $x, - 'spans' => $res); - } + if (count($spans)) { + $ls = $ws = 0; + if ($letterCount > 0) { + $ls = $letterSpacing / $letterCount; + } + if ($wordCount > 0) { + $ws = $wordSpacing / $wordCount; + } - protected function addSpan($span, $document_id) { + $res[] = array( + 'color' => $this->getCSSColor($group['color']), + 'size' => $this->getCSSSize($group['size']), + 'font' => $this->getCSSFont($group['font'], $document_id), + 'letterspacing' => $this->getCSSLetterSpacing($ls), + 'wordspacing' => $this->getCSSLetterSpacing($ws), + 'y' => 0, + 'x' => $x, + 'spans' => $spans); + } + return $res; + } + + protected function addSpan($span, $space=false) { $text = (string) $span; - if ($text == '') { - return false; - } - return array('text' => $text); + return array('text' => $text, 'space' => $space, 'x' => $span['x']); } - protected function getCSSSize(&$size) { - $size = $this->normalizeFloatValue($size * $this->multiply, 3); - $sizer = $size; - return $this->getIndex($sizer, $this->cssSize); + protected function getCSSSize($size) { + $size = $this->normalizeFloatValue($size); + $size*=$this->multiply; + return $this->getIndex($size, $this->cssSize); } protected function getCSSFont($font, $document_id) {