diff libinterp/corefcn/base-text-renderer.h @ 29470:2ae4764180c6

Initial implementation of a LaTeX interpreter (bug #59546). * NEWS: Announce basic support for "latex" interpreter. * plot.txi: Restructure the "Use of the interpreter Property" section to include 3 subsections, one for each interpreter type. In "Printing and Saving Plots" describe the new behavior. * print.m: Document new behavior. * contributors.in: Add Andrej Lojdl, a former GSoC student that worked on this subject. Even though there is not much left of his original work, it served as a very useful starting point. * base-text-renderer.h, base-text-renderer.cc: New enum to store symbolic constants for rotation angles. (base_text_renderer::rotate_pixels): New utility method. Code extracted from ft_text_renderer::render. (base_text_renderer::rotation_to_mode): Moved from ft_text_renderer class. (base_text_renderer::fix_bbox_anchor): New utility method. Code extracted from ft_text_renderer::text_to_pixels. * ft_text_renderer.cc (ft_text_renderer::render, ft_text_renderer::text_to_pixels): Make use of base class utility functions. * gl2ps-print.cc: New counter variable m_svg_def_index for safe inclusion of defs coming from dvisvgm. (gl2ps_renderer::format_svg_element): New function to manipulate svg elements obtained from dvisvgm so as to position them properly on the figure and change their color. (gl2ps_renderer::strlist_to_svg): If the str_list object returned from text_to_strlist contains an svg element, use format_svg_element to handle position and color and then return it. Otherwise, use <g> and <text> elements rather than <text> and <tspan> elements which are not supported by Qt's svg renderer (svg-tiny implementation). (gl2ps_renderer::strlist_to_ps): If the str_list object returned from text_to_strlist contains an svg element, raise a warning about the necessity of using -svgconvert. * latex-text-renderer.h, latex-text-renderer.cc: New files to hold the latex_interpreter class. * libinterp/corefcn/module.mk: Add new files to the build system. * text-renderer.h, text-renderer.cc (text_renderer): New data member latex_rep to hold a pointer to an instance of a latex_renderer. (text_renderer::~text_renderer, get_extent, set_anti_aliasing, set_font, set_color, text_to_pixels, text_to_strlist): Duplicate action of the latex_rep. (text_renderer::latex_ok): New method to test the usability of the latex_renderer. (text_renderer::string::svg_element, text_renderer::string::set_svg_element, text_renderer::string::get_svg_element): New string data member to hold preformated svg element. Provide accessor methods. * acinclude.m4: Add QtSvg to the list of imported QT_MODULES. * octave-svgconvert.cc: Overhaul program to make use of Qt's QSvgRenderer when rendering to PDF.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Mon, 22 Mar 2021 21:32:54 +0100
parents 0a5b15007766
children af41ebf3d1b3
line wrap: on
line diff
--- a/libinterp/corefcn/base-text-renderer.h	Mon Mar 29 07:54:26 2021 +0200
+++ b/libinterp/corefcn/base-text-renderer.h	Mon Mar 22 21:32:54 2021 +0100
@@ -45,6 +45,14 @@
   {
   public:
 
+    enum
+    {
+      ROTATION_0   = 0,
+      ROTATION_90  = 1,
+      ROTATION_180 = 2,
+      ROTATION_270 = 3
+    };
+
     base_text_renderer (void) : text_processor () { }
 
     // No copying!
@@ -85,6 +93,15 @@
                      std::list<text_renderer::string>& lst,
                      Matrix& box, int halign, int valign, double rotation,
                      const caseless_str& interpreter = "tex") = 0;
+
+    void rotate_pixels (uint8NDArray& pixels, int rot_mode) const;
+
+    int rotation_to_mode (double rotation) const;
+
+    void fix_bbox_anchor (Matrix& bbox, int halign,
+                          int valign, int rot_mode,
+                          bool handle_rotation) const;
+
   };
 }