From: vincent@cubedesigners.com Date: Sun, 18 Sep 2011 17:38:35 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=855bc9a731de6bb7c070e11a38c52c91018d1754;p=cubeextranet.git --- diff --git a/fluidbook/tools/FWSTK_Resources/dist/FWSTK_Resources.jar b/fluidbook/tools/FWSTK_Resources/dist/FWSTK_Resources.jar index 04d781ae0..3cbc926cb 100644 Binary files a/fluidbook/tools/FWSTK_Resources/dist/FWSTK_Resources.jar and b/fluidbook/tools/FWSTK_Resources/dist/FWSTK_Resources.jar differ diff --git a/fluidbook/tools/FWSTK_Resources/src/org/apache/pdfbox/resources/LayoutStripper.properties b/fluidbook/tools/FWSTK_Resources/src/org/apache/pdfbox/resources/LayoutStripper.properties index 1c84790a9..ec11c56ea 100644 --- a/fluidbook/tools/FWSTK_Resources/src/org/apache/pdfbox/resources/LayoutStripper.properties +++ b/fluidbook/tools/FWSTK_Resources/src/org/apache/pdfbox/resources/LayoutStripper.properties @@ -17,59 +17,59 @@ # OperatorProcessor abstract class for the stategy pattern used in the # org.apache.pdfbox.util.PDFStreamEngine class. # To change the behaviour of the system, remplace the class name by a new class name. -b#=org.apache.pdfbox.util.operator.pagedrawer.CloseFillNonZeroAndStrokePath -B#=org.apache.pdfbox.util.operator.pagedrawer.FillNonZeroAndStrokePath -b*#=org.apache.pdfbox.util.operator.pagedrawer.CloseFillEvenOddAndStrokePath -B*#=org.apache.pdfbox.util.operator.pagedrawer.FillEvenOddAndStrokePath -BDC# org.apache.pdfbox.util.operator.NotImplemented ##Begin Marked Content -- section 10.5 -BI#=org.apache.pdfbox.util.operator.pagedrawer.BeginInlineImage -BMC# org.apache.pdfbox.util.operator.NotImplemented ##Begin Marked Content -- section 10.5 +b +B +b* +B* +BDC +BI +BMC BT=org.apache.pdfbox.util.operator.BeginText -BX# org.apache.pdfbox.util.operator.NotImplemented -c#=org.apache.pdfbox.util.operator.pagedrawer.CurveTo +BX +c cm=org.apache.pdfbox.util.operator.Concatenate CS=org.apache.pdfbox.util.operator.SetStrokingColorSpace cs=org.apache.pdfbox.util.operator.SetNonStrokingColorSpace -d#=org.apache.pdfbox.util.operator.pagedrawer.SetLineDashPattern -#d0 org.apache.pdfbox.util.operator.NotImplemented -#d1 org.apache.pdfbox.util.operator.NotImplemented -Do#=org.apache.pdfbox.util.operator.pagedrawer.Invoke -#DP org.apache.pdfbox.util.operator.NotImplemented ##Marked Content Point-- section 10.5 -#El org.apache.pdfbox.util.operator.NotImplemented -#EMC org.apache.pdfbox.util.operator.NotImplemented ##End Marked Content -- section 10.5 +d +d0 +d1 +Do=org.apache.pdfbox.util.operator.Invoke +DP +El +EMC ET=org.apache.pdfbox.util.operator.EndText -#EX org.apache.pdfbox.util.operator.NotImplemented -f#=org.apache.pdfbox.util.operator.pagedrawer.FillNonZeroRule -F#=org.apache.pdfbox.util.operator.pagedrawer.FillNonZeroRule -f*#=org.apache.pdfbox.util.operator.pagedrawer.FillEvenOddRule +EX +f +F +f* G=org.apache.pdfbox.util.operator.SetStrokingGrayColor g=org.apache.pdfbox.util.operator.SetNonStrokingGrayColor gs=org.apache.pdfbox.util.operator.SetGraphicsStateParameters -h#=org.apache.pdfbox.util.operator.pagedrawer.ClosePath -#i org.apache.pdfbox.util.operator.NotImplemented -#ID org.apache.pdfbox.util.operator.NotImplemented -j#=org.apache.pdfbox.util.operator.pagedrawer.SetLineJoinStyle -J#=org.apache.pdfbox.util.operator.pagedrawer.SetLineCapStyle +h +i +ID +j +J K=org.apache.pdfbox.util.operator.SetStrokingCMYKColor k=org.apache.pdfbox.util.operator.SetNonStrokingCMYKColor -l#=org.apache.pdfbox.util.operator.pagedrawer.LineTo -m#=org.apache.pdfbox.util.operator.pagedrawer.MoveTo -M#=org.apache.pdfbox.util.operator.pagedrawer.SetLineMiterLimit -#MP org.apache.pdfbox.util.operator.NotImplemented ##Marked Content Point-- section 10.5 -n#=org.apache.pdfbox.util.operator.pagedrawer.EndPath +l +m +M +MP +n q=org.apache.pdfbox.util.operator.GSave Q=org.apache.pdfbox.util.operator.GRestore -re#=org.apache.pdfbox.util.operator.pagedrawer.AppendRectangleToPath +re RG=org.apache.pdfbox.util.operator.SetStrokingRGBColor rg=org.apache.pdfbox.util.operator.SetNonStrokingRGBColor -#ri org.apache.pdfbox.util.operator.NotImplemented +ri s=org.apache.pdfbox.util.operator.CloseAndStrokePath -S#=org.apache.pdfbox.util.operator.pagedrawer.StrokePath +S SC=org.apache.pdfbox.util.operator.SetStrokingColor sc=org.apache.pdfbox.util.operator.SetNonStrokingColor SCN=org.apache.pdfbox.util.operator.SetStrokingColor scn=org.apache.pdfbox.util.operator.SetNonStrokingColor -sh#=org.apache.pdfbox.util.operator.pagedrawer.SHFill +sh T*=org.apache.pdfbox.util.operator.NextLine Tc=org.apache.pdfbox.util.operator.SetCharSpacing Td=org.apache.pdfbox.util.operator.MoveText @@ -83,10 +83,10 @@ Tr=org.apache.pdfbox.util.operator.SetTextRenderingMode Ts=org.apache.pdfbox.util.operator.SetTextRise Tw=org.apache.pdfbox.util.operator.SetWordSpacing Tz=org.apache.pdfbox.util.operator.SetHorizontalTextScaling -v#=org.apache.pdfbox.util.operator.pagedrawer.CurveToReplicateInitialPoint -w#=org.apache.pdfbox.util.operator.pagedrawer.SetLineWidth -W# org.apache.pdfbox.util.operator.pagedrawer.ClipNonZeroRule -W*# org.apache.pdfbox.util.operator.pagedrawer.ClipEvenOddRule -y#=org.apache.pdfbox.util.operator.pagedrawer.CurveToReplicateFinalPoint +v +w +W +W* +y \'=org.apache.pdfbox.util.operator.MoveAndShow \"=org.apache.pdfbox.util.operator.SetMoveAndShow diff --git a/fluidbook/tools/convert.pe b/fluidbook/tools/convert.pe index 1ef60a3a0..312b4cc93 100644 --- a/fluidbook/tools/convert.pe +++ b/fluidbook/tools/convert.pe @@ -1,6 +1,7 @@ #!/usr/local/bin/fontforge Open($1,1) Print("Open font ",$1) +Print("Em size : ",$em); i=2 while ( i<=$argc-3 ) Print ("Merge with font ",$argv[i]); @@ -17,7 +18,7 @@ if($argv[i]!="-") while(jBen Litchfield + * @version $Revision: 1.22 $ + */ +public class PageDrawer extends PDFStreamEngine +{ + + /** + * Log instance. + */ + private static final Log log = LogFactory.getLog(PageDrawer.class); + + private Graphics2D graphics; + protected Dimension pageSize; + protected PDPage page; + + private GeneralPath linePath = new GeneralPath(); + + /** + * Default constructor, loads properties from file. + * + * @throws IOException If there is an error loading properties from the file. + */ + public PageDrawer() throws IOException + { + super( ResourceLoader.loadProperties( + "org/apache/pdfbox/resources/PageDrawer.properties", true ) ); + } + + public PageDrawer(Properties properties) throws IOException { + super(properties); + } + + /** + * This will draw the page to the requested context. + * + * @param g The graphics context to draw onto. + * @param p The page to draw. + * @param pageDimension The size of the page to draw. + * + * @throws IOException If there is an IO error while drawing the page. + */ + public void drawPage( Graphics g, PDPage p, Dimension pageDimension ) throws IOException + { + graphics = (Graphics2D)g; + page = p; + pageSize = pageDimension; + graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); + graphics.setRenderingHint( RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON ); + // Only if there is some content, we have to process it. + // Otherwise we are done here and we will produce an empty page + if ( page.getContents() != null) + { + PDResources resources = page.findResources(); + processStream( page, resources, page.getContents().getStream() ); + } + + return;/* + List annotations = page.getAnnotations(); + for( int i=0; i '00C6', 'ae' => '00E6', 'OE' => '0152', 'oe' => '0152', 'IJ' => '0132', 'ij' => '0133', @@ -59,10 +67,43 @@ class wsPDFFont { $e = explode(" ", $line); if (strpos($e[0], "/FontFile") !== false) { $this->font_file_id = $e[1]; + } elseif ($e[0] == '/ItalicAngle') { + $this->italicAngle = $e[1]; + } elseif ($e[0] == '/FontWeight') { + $this->fontWeight = $e[1]; + } elseif ($e[0] == '/FontStretch') { + $this->fontStretch = ltrim($e[1], "/"); + } elseif ($e[0] == '/Ascent') { + $this->ascent = $e[1]; + } elseif ($e[0] == '/Descent') { + $this->descent = abs($e[1]); + } elseif ($e[0] == '/XHeight') { + $this->xheight = $e[1]; + } elseif ($e[0] == '/CapHeight') { + $this->capheight = $e[1]; + } elseif ($e[0] == '/Flags') { + $this->flags = $e[1]; } } } + public function setDescriptorsToFile($file) { + $fontforge = new cubeCommandLine('descriptors.pe'); + $fontforge->setPath(CONVERTER_PATH); + + $font=$this; + if(!is_null($this->descendant)){ + $font=$this->decendant; + } + + $fontforge->setArg(null, $file); + $fontforge->setArg(null, $font->italicAngle); + $fontforge->setArg(null, $font->ascent); + $fontforge->setArg(null, $font->descent); + $fontforge->execute(); + $this->addToLog($fontforge); + } + public function getInfos() { $lines = $this->showObject($this->id); // Test redirection @@ -70,7 +111,7 @@ class wsPDFFont { $e = explode(' ', $lines[0]); if ($e[0] == '[' && $e[4] == ']') { // Change id and get infos again - $this->id=$e[1]; + $this->id = $e[1]; return $this->getInfos(); } else { return; @@ -261,15 +302,35 @@ class wsPDFFont { return $this->font_file_id; } + public function getName() { + return $this->name; + } + + public function getCanonicalName() { + $n = $this->getName(); + $e = explode('+', $n); + if (count($e) > 1) { + array_shift($e); + $n = implode('+', $e); + } + return $n; + } + + public function getTTFFile() { + return $this->ttffile; + } + public function writeTTF($dir) { $cmap = $this->writeCMAP(); $file = $this->writeFont(); + $this->ttffile = $dir . '/' . $this->name . '-' . $this->id . '.ttf'; + $fontforge = new cubeCommandLine('convert.pe'); $fontforge->setPath(CONVERTER_PATH); $fontforge->setArg(null, $file); $fontforge->setArg(null, $cmap); - $fontforge->setArg(null, $dir . '/' . $this->name . '-' . $this->id . '.ttf'); + $fontforge->setArg(null, $this->ttffile); $fontforge->execute(); $this->addToLog($fontforge); diff --git a/inc/ws/Util/fontextractor/class.ws.pdf.fontextractor.php b/inc/ws/Util/fontextractor/class.ws.pdf.fontextractor.php index a6ad65ddb..4cd286275 100644 --- a/inc/ws/Util/fontextractor/class.ws.pdf.fontextractor.php +++ b/inc/ws/Util/fontextractor/class.ws.pdf.fontextractor.php @@ -23,8 +23,7 @@ class wsPDFFontExtractor { $this->getFonts(); $this->convertToTTF(); - - $this->addToLog(print_r($this,true)); + $this->mergeFonts(); } public function convertToTTF() { @@ -33,6 +32,35 @@ class wsPDFFontExtractor { } } + public function mergeFonts() { + $collections = array(); + foreach ($this->fonts as $font) { + if (!isset($collections[$font->getCanonicalName()])) { + $collections[$font->getCanonicalName()] = array(); + } + $collections[$font->getCanonicalName()][] = $font; + } + + foreach ($collections as $name => $fonts) { + $out = $this->outweb . '/' . $fonts[0]->getCanonicalName() . '.ttf'; + if (count($fonts) == 1) { + copy($fonts[0]->getTTFFile(), $out); + } else { + $fontforge = new cubeCommandLine('convert.pe'); + $fontforge->setPath(CONVERTER_PATH); + foreach ($fonts as $font) { + $fontforge->setArg(null, $font->getTTFFile()); + } + $fontforge->setArg(null, '-'); + $fontforge->setArg(null, $out); + $fontforge->execute(); + $this->addToLog($fontforge); + } + + $fonts[0]->setDescriptorsToFile($out); + } + } + public function getFonts() { $pdfinfo = $this->getCommandLine('pdfinfo'); $pdfinfo->setArg('f'); @@ -66,7 +94,7 @@ class wsPDFFontExtractor { */ - if (preg_match_all("|\s+\d+\s+\(\s+\d+\s+\d+\s+\w+\):\s+\w+\s+'([A-Za-z-+]+)'\s+\((\d+)\s+\d+\s+\w+\)\s|", $pdfinfo->output, $matches)) { + if (preg_match_all("|\s+\d+\s+\(\s+\d+\s+\d+\s+\w+\):\s+\w+\s+'([^']+)'\s+\((\d+)\s+\d+\s+\w+\)\s|", $pdfinfo->output, $matches)) { foreach ($matches[1] as $k => $name) { $this->fonts[$matches[2][$k]] = new wsPDFFont($this, $matches[2][$k], $name); } @@ -92,25 +120,21 @@ class wsPDFFontExtractor { $pdfshow->setArg(null, $this->in); $pdfshow->setArg(null, $object); $pdfshow->execute(); - + $this->addToLog($pdfshow); - + $obj = $pdfshow->output; $obj = explode("\n", $obj); $res = array(); foreach ($obj as $o) { - $o=trim($o); - if($o==''){ + $o = trim($o); + if ($o == '') { continue; } $res[] = trim($o); - } array_shift($res); array_pop($res); - - $this->addToLog(print_r($res,true)); - return $res; } @@ -122,7 +146,7 @@ class wsPDFFontExtractor { $pdfshow->setArg(null, $this->in); $pdfshow->setArg(null, $obj); $pdfshow->execute(); - + $this->addToLog($pdfshow->commande); } diff --git a/inc/ws/Util/html5/class.ws.html5.compiler.php b/inc/ws/Util/html5/class.ws.html5.compiler.php index 52aac6046..a7ac27cb2 100644 --- a/inc/ws/Util/html5/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/class.ws.html5.compiler.php @@ -67,7 +67,7 @@ class wsHTML5Compiler { protected $optimalWidth = 567; protected $optimalHeight = 709; protected $additionalConfig = array(); - protected $fontScale = 0.9775; + protected $fontScale = 1; function __construct($book_id) { global $core; @@ -369,6 +369,9 @@ class wsHTML5Compiler { $fontforge->setArg(null, '-'); $fontforge->setArg(null, $this->vdir . '/data/style/F' . $index . '.' . $format); $fontforge->execute(); + + fb($fontforge->commande); + fb($fontforge->output); } } } @@ -728,7 +731,7 @@ class wsHTML5Compiler { foreach ($this->cssTransform as $transform => $index) { - list($rotation, $scaleX, $scaleY) = explode(',', $transform); + list($rotation, $scaleX, $scaleY, $translateX, $translateY) = explode(',', $transform); $rotation*= - 1; @@ -739,6 +742,9 @@ class wsHTML5Compiler { if ($scaleX != 1 || $scaleY != 1) { $t[] = 'scale(' . $scaleX . ',' . $scaleY . ')'; } + if ($translateX != '0' || $translateY != '') { + $t[] = 'translate(' . $translateX . ',' . $translateY . ')'; + } $css = '.t' . $index . '{'; $css.=self::writeCSSUA('transform', implode(' ', $t)) . ';'; @@ -881,6 +887,12 @@ class wsHTML5Compiler { protected function getCSSFont($font, $oblique, $document_id) { $font = (string) $font; + $e = explode('+', $font); + if (count($e) > 1) { + array_shift($e); + $font = implode('+', $e); + } + if (!isset($this->fontDocs[$font])) { $this->fontDocs[$font] = array(); } @@ -930,10 +942,7 @@ class wsHTML5Compiler { $scaleY*=-1; } - if ($rotation == 0 && $scaleX == 1 && $scaleY = 1) { - return null; - } - return $this->getIndex($rotation . ',' . $scaleX . ',' . $scaleY, $this->cssTransform); + return $this->getIndex($rotation . ',' . $scaleX . ',' . $scaleY . ',0,-0.8em', $this->cssTransform); } protected function getCSSX($x) {