From: vincent@cubedesigners.com Date: Mon, 2 May 2011 00:24:49 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=e2f94013705d52af26bf34e40ec3909338634c3c;p=cubeextranet.git --- diff --git a/fluidbook/tools/extract.pe b/fluidbook/tools/extract.pe new file mode 100644 index 000000000..86b3c2853 --- /dev/null +++ b/fluidbook/tools/extract.pe @@ -0,0 +1,32 @@ +#!/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(jsetArg('-dNOPROMPT'); $gs->setArg('-dNODISPLAY'); $gs->setArg(null, WS_TOOLS . '/extractFonts.ps'); - $gs->setManualArg('-c "(' . $this->cropped . ') extractFonts quit"'); + $gs->setManualArg('-c "(' . $this->in . ') extractFonts quit"'); $gs->execute(); $this->addToLog($gs); diff --git a/inc/ws/Util/packager/class.ws.packager.html5.php b/inc/ws/Util/packager/class.ws.packager.html5.php index b80da19a4..3a5ae527e 100644 --- a/inc/ws/Util/packager/class.ws.packager.html5.php +++ b/inc/ws/Util/packager/class.ws.packager.html5.php @@ -32,7 +32,7 @@ class wsPackagerHTML5 extends wsPackager { $imagesize = getimagesize(WS_DOCS . '/' . $this->pages[1]['document_id'] . '/html/h150-' . $this->pages[1]['document_page'] . '.jpg'); $this->pdf2htmlRatio = $imagesize[0] / $this->layouts[1]['width']; - $this->scale = 20; + $this->scale = 5; $this->multiply = $this->pdf2htmlRatio * $this->scale; $this->createHTML(); @@ -47,10 +47,11 @@ class wsPackagerHTML5 extends wsPackager { foreach ($this->layouts as $page => $layout) { $this->div[$page] = array(); $document_id = $this->pages[$page]['document_id']; - foreach ($layout->xpath('//a') as $div) { - $this->div[$page][] = $this->addCSSText($div, $document_id); + foreach ($layout->l as $line) { + $this->div[$page][] = $this->addLine($line, $document_id); } } + mkdir($this->vdir . '/style', 0777, true); mkdir($this->vdir . '/contents', 0777, true); mkdir($this->vdir . '/images', 0777, true); @@ -87,47 +88,72 @@ class wsPackagerHTML5 extends wsPackager { protected function writePage($page) { $res = ''; - foreach ($page as $div) { - $res .= $this->writeSpan($div); + foreach ($page as $line) { + $res .= $this->writeLine($line); } return $res; } - protected function writeSpan($span) { - if ($span === false) { - return ''; + protected function writeLine($line) { + $class = array('l'); + if (!is_null($line['rotation'])) { + $class[] = 'r' . $line['rotation']; } + $class = implode(' ', $class); - $top = round($span['y'] * $this->multiply, 2); - $left = round($span['x'] * $this->multiply, 2); + $left = round($line['x'] * $this->multiply, 2); + $top = round($line['y'] * $this->multiply, 2); - $class = ''; - if (!is_null($span['color'])) { - $class.=' c' . $span['color']; + $res = '
'; + foreach ($line['groups'] as $group) { + $res.=$this->writeGroup($group); } - if (!is_null($span['size'])) { - $class.=' s' . $span['size']; + $res.='
'; + return $res; + } + + protected function writeGroup($group) { + if ($group === false) { + return ''; } - if (!is_null($span['font'])) { - $class.=' f' . $span['font']; + + $class = array('g'); + if (!is_null($group['color'])) { + $class[] = 'c' . $group['color']; } - if (!is_null($span['wordSpacing'])) { - $class.=' w' . $span['wordSpacing']; + if (!is_null($group['size'])) { + $class[] = 's' . $group['size']; } - if (!is_null($span['letterSpacing'])) { - $class.=' l' . $span['letterSpacing']; + if (!is_null($group['font'])) { + $class[] = 'f' . $group['font']; } - if (!is_null($span['rotation'])) { - $class.=' r' . $span['rotation']; + if (!is_null($group['wordSpacing'])) { + $class[] = 'w' . $group['wordSpacing']; } + if (!is_null($group['letterSpacing'])) { + $class[] = 'l' . $group['letterSpacing']; + } + $class = implode(' ', $class); + + $top = round($group['x'] * $this->multiply, 2); - $class = trim($class); + $res = '
'; + foreach ($group['spans'] as $span) { + $res.=$this->writeSpan($span); + } + $res.='
'; + return $res; + } + + protected function writeSpan($span) { + if ($span === false) { + return ''; + } + $left = round($span['x'] * $this->multiply, 2); - $res = '
'; - $res .= htmlentities($span['text'], ENT_NOQUOTES, 'UTF-8'); - $res .= '
'; + $res = ''; + $res .= str_replace(' ', ' ', $span['text']); + $res .= ''; return $res; } @@ -139,7 +165,6 @@ class wsPackagerHTML5 extends wsPackager { foreach ($this->cssSize as $size => $index) { $size*=$this->multiply; - // Point to pixel conversion $res[] = '.s' . $index . '{font-size:' . $size . 'px}'; } @@ -155,7 +180,17 @@ class wsPackagerHTML5 extends wsPackager { foreach ($this->cssRotation as $rotation => $index) { $rotation*= - 1; - $res[] = '.r' . $index . '{-webkit-transform: rotate(' . $rotation . 'deg);-moz-transform: rotate(' . $rotation . 'deg)}'; + + $navigators = array('-moz-', '-webkit-', '-ms-', '-o-', ''); + $t = 'transform:rotate(' . $rotation . 'deg);'; + $to = 'transform-origin:left top;'; + + $css = '.r' . $index . '{'; + foreach ($navigators as $n) { + $css.=$n . $t . $n . $to; + } + $css.='}'; + $res[] = $css; } foreach ($this->cssFont as $font => $index) { @@ -166,27 +201,49 @@ class wsPackagerHTML5 extends wsPackager { return implode("\n", $res); } - protected function addCSSText($l, $document_id) { - $alpha = intval(substr($l['color'], 1, 2), 16); - $text = (string) $l; - if ($text == '') { - return false; + protected function addLine($line, $document_id) { + $res = array(); + foreach ($line->a as $group) { + $res[] = $this->addGroup($group, $document_id); } + return array('x' => $this->normalizeFloatValue($line['x']), + 'y' => $this->normalizeFloatValue($line['y']), + 'rotation' => $this->getCSSRotation($this->normalizeFloatValue($line['rotation'], 0)), + "groups" => $res); + } + + protected function addGroup($group, $document_id) { + $alpha = intval(substr($group['color'], 1, 2), 16); if ($alpha == 0) { return false; } + + $res = array(); + foreach ($group->s as $span) { + $res[] = $this->addSpan($span, $document_id); + } + 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']), + 'x' => $group['size']/-1.2, + 'spans' => $res); + } + + protected function addSpan($span, $document_id) { + + $text = (string) $span; + if ($text == '') { + return false; + } return array('text' => $text, - 'color' => $this->getCSSColor($l['color']), - 'size' => $this->getCSSSize($l['size']), - 'font' => $this->getCSSFont($l['font'], $document_id), - 'letterSpacing' => $this->getCSSLetterSpacing($l['letterspacing']), - 'wordSpacing' => $this->getCSSWordSpacing($l['wordspacing']), - 'rotation' => $this->getCSSRotation($l['rotation']), - 'x' => $this->normalizeFloatValue($l['x']), - 'y' => $this->normalizeFloatValue($l['y'])); + 'x' => $this->normalizeFloatValue($span['x'])); } - protected function getCSSSize($size) { + protected function getCSSSize(&$size) { + $size/=1.05; $size = $this->normalizeFloatValue($size); return $this->getIndex($size, $this->cssSize); } @@ -208,7 +265,7 @@ class wsPackagerHTML5 extends wsPackager { } protected function getCSSLetterSpacing($letterspacing) { - $letterspacing = $this->normalizeFloatValue($letterspacing); + $letterspacing = $this->normalizeFloatValue($letterspacing, 2); if ($letterspacing == 0) { return null; } @@ -217,7 +274,7 @@ class wsPackagerHTML5 extends wsPackager { } protected function getCSSWordSpacing($wordspacing) { - $wordspacing = $this->normalizeFloatValue($wordspacing); + $wordspacing = $this->normalizeFloatValue($wordspacing, 2); if ($wordspacing == 0) { return null; } @@ -225,7 +282,7 @@ class wsPackagerHTML5 extends wsPackager { } protected function getCSSRotation($rotation) { - $rotation = round($rotation); + $rotation = $this->normalizeFloatValue($rotation, 0); if ($rotation == 0) { return null; } @@ -242,10 +299,10 @@ class wsPackagerHTML5 extends wsPackager { return $res; } - protected function normalizeFloatValue($value) { + protected function normalizeFloatValue($value, $round=3) { $value = str_replace(',', '.', $value); $value = (float) $value; - $value = round($value, 3); + $value = round($value, $round); return $value; }