protected $optimalWidth = 567;
protected $optimalHeight = 709;
protected $additionalConfig = array();
- protected $fontScale = 1;
+ protected $fontScale = 0.9775;
function __construct($book_id) {
global $core;
protected function sortPage($layout) {
$lines = array();
- foreach ($layout->l as $line) {
+ foreach ($layout->line as $line) {
$lines[] = $line;
}
usort($lines, array($this, 'compareLines'));
$scripts[] = '<script type="text/javascript" src="data/datas.js"></script>';
$script = implode("\n\t\t", $scripts);
- $scripts=array();
+ $scripts = array();
foreach (self::$testJsFiles as $js) {
$scripts[] = '<script type="text/javascript" src="' . $js . '"></script>';
}
$uhtml = str_replace('<!-- $' . $v . ' -->', $$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 . ' -->', $$v, $thtml);
}
$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'])) {
}
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) {
$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);
$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;
$x = floatval($span['x']);
$first = false;
}
+
+ if ($char == " ") {
+ $lastIsSpace = true;
+ continue;
+ }
+
$sox = floatval($span['x']);
$sx = $sox - $x;
$sw = floatval($span['width']);
$diff = $sx - $nextX;
$s = $char;
+ $left = round($sx * $this->multiply, 2);
+ $s = '<span style="left:' . $left . 'px;">' . $s . '</span>';
- if ($lastIsSpace) {
- if ($diff > $wordSpacing) {
- $diff-=$wordSpacing;
- $diff = round($diff * $this->multiply, 2);
- if ($diff != 0) {
- $s = '<span class="gap" style="margin-left:' . $diff . 'px">' . $s . '</span>';
- }
- }
- } else {
- if ($diff < $letterSpacing) {
- $diff-=$letterSpacing;
- $diff = round($diff * $this->multiply, 2);
- if ($diff != 0) {
- $s = '<span class="gap" style="margin-left:' . $diff . 'px">' . $s . '</span>';
- }
- } else if ($diff > $letterSpacing) {
- $diff-=$letterSpacing;
- $diff = round($diff * $this->multiply, 2);
- if ($diff != 0) {
- $s = '<span class="gap" style="margin-left:' . $diff . 'px">' . $s . '</span>';
- }
- }
- }
$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);