$left = round($line['x'] * $this->multiply, 2);\r
$top = round($line['y'] * $this->multiply, 2);\r
\r
- $res = '<div style="top:' . $top . 'px;left:' . $left . 'px;" class="' . $class . '">';\r
+ $res = '<div style="top:' . $top . 'px;left:' . $left . 'px" class="' . $class . '">';\r
foreach ($line['groups'] as $group) {\r
$res.=$this->writeGroup($group);\r
}\r
if (!is_null($group['font'])) {\r
$class[] = 'f' . $group['font'];\r
}\r
- if (!is_null($group['wordSpacing'])) {\r
- $class[] = 'w' . $group['wordSpacing'];\r
- }\r
- if (!is_null($group['letterSpacing'])) {\r
- $class[] = 'l' . $group['letterSpacing'];\r
- }\r
$class = implode(' ', $class);\r
\r
$top = round($group['x'] * $this->multiply, 2);\r
\r
- $res = '<div class="' . $class . '" style="top:' . $top . 'px;">';\r
+ $res = '<div class="' . $class . '" style="top:' . $top . 'px">';\r
foreach ($group['spans'] as $span) {\r
$res.=$this->writeSpan($span);\r
}\r
if ($span === false) {\r
return '';\r
}\r
+\r
+ $class = array();\r
+\r
+ if (!is_null($span['letterspacing'])) {\r
+ $class[] = 'l' . $span['letterspacing'];\r
+ }\r
+\r
+ if (count($class)) {\r
+ $class = ' class="' . implode(' ', $class) . '"';\r
+ }\r
+\r
$left = round($span['x'] * $this->multiply, 2);\r
\r
- $res = '<span style="left:' . $left . 'px;">';\r
- $res .= str_replace(' ', ' ', $span['text']);\r
+ $res = '<span style="left:' . $left . 'px"' . $class . '>';\r
+ $res .= self::escapeHTML($span['text']);\r
$res .= '</span>';\r
return $res;\r
}\r
}\r
\r
$res = array();\r
+\r
foreach ($group->s as $span) {\r
- $res[] = $this->addSpan($span, $document_id);\r
+ $newSpan = $this->addSpan($span, $document_id);\r
+ if (count($res) > 0) {\r
+ $lastSpan = array_pop($res);\r
+ $lastSpan['letterspacing'] = $this->getCSSLetterSpacing($newSpan['x'] - $lastSpan['x'] - $lastSpan['width']);\r
+ array_push($res, $lastspan);\r
+ }\r
+ array_push($res, $newSpan);\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
- 'x' => $group['size']/-1.2,\r
+ 'x' => $group['size'] / -1.2,\r
'spans' => $res);\r
}\r
\r
return false;\r
}\r
return array('text' => $text,\r
- 'x' => $this->normalizeFloatValue($span['x']));\r
+ 'x' => $this->normalizeFloatValue($span['x']),\r
+ 'width' => $this->normalizeFloatValue($span['width']),\r
+ 'letterspacing' => 0);\r
}\r
\r
protected function getCSSSize(&$size) {\r
}\r
\r
protected function getCSSLetterSpacing($letterspacing) {\r
- $letterspacing = $this->normalizeFloatValue($letterspacing, 2);\r
+ $letterspacing = $this->normalizeFloatValue($letterspacing, 5);\r
if ($letterspacing == 0) {\r
return null;\r
}\r
-\r
return $this->getIndex($letterspacing, $this->cssLetterSpacing);\r
}\r
\r
protected function getCSSWordSpacing($wordspacing) {\r
- $wordspacing = $this->normalizeFloatValue($wordspacing, 2);\r
+ $wordspacing = $this->normalizeFloatValue($wordspacing, 5);\r
if ($wordspacing == 0) {\r
return null;\r
}\r
return $str;\r
}\r
\r
+ public static function escapeHTML($in) {\r
+ $in = str_replace(' ', ' ', $in);\r
+ $in = str_replace("\x2009", " ", $in);\r
+\r
+\r
+ return $in;\r
+ }\r
+\r
public function __destruct() {\r
\r
}\r