From: vincent@cubedesigners.com Date: Mon, 29 Aug 2011 02:06:26 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=9e9bb585fd49803f9a828d82430f4160879cd3d8;p=cubeextranet.git --- diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index b09b38e92..d45c20cbe 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -66,7 +66,7 @@ class wsHTML5Compiler { protected $optimalWidth = 567; protected $optimalHeight = 709; protected $additionalConfig = array(); - protected $fontScale = 1; + protected $fontScale = 0.9775; function __construct($book_id) { global $core; @@ -130,7 +130,7 @@ class wsHTML5Compiler { protected function sortPage($layout) { $lines = array(); - foreach ($layout->l as $line) { + foreach ($layout->line as $line) { $lines[] = $line; } usort($lines, array($this, 'compareLines')); @@ -227,7 +227,7 @@ class wsHTML5Compiler { $scripts[] = ''; $script = implode("\n\t\t", $scripts); - $scripts=array(); + $scripts = array(); foreach (self::$testJsFiles as $js) { $scripts[] = ''; } @@ -239,9 +239,9 @@ class wsHTML5Compiler { $uhtml = str_replace('', $$v, $uhtml); } - $thtml=file_get_contents(WS_COMPILE_ASSETS . '/_html5/tester.html'); - - $vars = array('titre', 'credits', 'ga', 'style', 'script_test'); + $thtml = file_get_contents(WS_COMPILE_ASSETS . '/_html5/tester.html'); + + $vars = array('titre', 'credits', 'ga', 'style', 'script_test'); foreach ($vars as $v) { $thtml = str_replace('', $$v, $thtml); } @@ -467,8 +467,8 @@ class wsHTML5Compiler { $group['y'] = $this->getCSSY(($group['y'] + $line['y']) * $this->multiply); $group['x'] = $this->getCSSX(($group['x']) * $this->multiply); - $group['letterspacing'] = $this->getCSSLetterSpacing($group['letterspacing'] * $this->multiply); - $group['wordspacing'] = $this->getCSSWordSpacing($group['wordspacing'] * $this->multiply); + $group['letterspacing'] = $this->getCSSLetterSpacing($group['letterspacing'] ); + $group['wordspacing'] = $this->getCSSWordSpacing($group['wordspacing']); $class = array('g'); if (!is_null($group['color'])) { @@ -690,11 +690,11 @@ class wsHTML5Compiler { } foreach ($this->cssLetterSpacing as $letterspacing => $index) { - $res[] = '.l' . $index . '{letter-spacing:' . $letterspacing . 'px}'; + $res[] = '.l' . $index . '{letter-spacing:' . $letterspacing . 'em}'; } foreach ($this->cssWordSpacing as $wordspacing => $index) { - $res[] = '.w' . $index . '{word-spacing:' . $wordspacing . 'px}'; + $res[] = '.w' . $index . '{word-spacing:' . $wordspacing . 'em}'; } foreach ($this->cssX as $x => $index) { @@ -848,14 +848,14 @@ class wsHTML5Compiler { $ws = floatval($group['wordspacing']); $ls = floatval($group['letterspacing']); - $size = floatval($group['size']); + $size = floatval($group['size'])*$this->fontScale; $res[] = array( 'color' => $this->getCSSColor($group['color']), - 'size' => $this->getCSSSize($group['size']), + 'size' => $this->getCSSSize($size), 'font' => $this->getCSSFont($group['font'], $document_id), - 'letterspacing' => $ls * $size, - 'wordspacing' => $ws * $size, + 'letterspacing' => $ls, + 'wordspacing' => $ws, 'y' => 0, 'x' => $x, 'text' => $text); @@ -871,12 +871,7 @@ class wsHTML5Compiler { $nextX = 0; $x = 0; - $spaceWidth = $group['space']; - $size = floatval($group['size']); - $letterSpacing = floatval($group['letterspacing']) * $size; - $wordSpacing = floatval($group['wordspacing']) * $size + $letterSpacing; - - $lastIsSpace = true; + $lastIsSpace = false; foreach ($group->s as $span) { $char = (string) $span; @@ -888,6 +883,12 @@ class wsHTML5Compiler { $x = floatval($span['x']); $first = false; } + + if ($char == " ") { + $lastIsSpace = true; + continue; + } + $sox = floatval($span['x']); $sx = $sox - $x; $sw = floatval($span['width']); @@ -895,44 +896,18 @@ class wsHTML5Compiler { $diff = $sx - $nextX; $s = $char; + $left = round($sx * $this->multiply, 2); + $s = '' . $s . ''; - if ($lastIsSpace) { - if ($diff > $wordSpacing) { - $diff-=$wordSpacing; - $diff = round($diff * $this->multiply, 2); - if ($diff != 0) { - $s = '' . $s . ''; - } - } - } else { - if ($diff < $letterSpacing) { - $diff-=$letterSpacing; - $diff = round($diff * $this->multiply, 2); - if ($diff != 0) { - $s = '' . $s . ''; - } - } else if ($diff > $letterSpacing) { - $diff-=$letterSpacing; - $diff = round($diff * $this->multiply, 2); - if ($diff != 0) { - $s = '' . $s . ''; - } - } - } $newSpan = array('text' => $s, 'x' => $sox); $currentGroup['spans'][] = $newSpan; - - - $nextX = $sx + $sw; - $lastIsSpace = substr($char, -1) == " "; } $res[] = $currentGroup; return $res; } - protected function getCSSSize( - $size) { + protected function getCSSSize($size) { $size = $this->normalizeFloatValue($size); $size*=$this->multiply; return $this->getIndex($size, $this->cssSize);