octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Google Summer of Code - LaTeX processing


From: Michael Goffioul
Subject: Re: Google Summer of Code - LaTeX processing
Date: Wed, 19 Jun 2013 10:46:09 -0400

On Wed, Jun 19, 2013 at 10:40 AM, Andrej Lojdl <address@hidden> wrote:

Please, try to produce proper patches using "hg diff". In the above code, I don't see anything that will pass the line_height value down to text engine. By comparison, you should follow how it's done for the fontsize:
1) extend ft_render::set_font() method with a "lineheight" argument
2) populate that new argument in opengl_renderer::set_font() method

Also, don't use "line_height", but "lineheight" for the property name, to be consistent with the rest of the property names. And I think it's better  to make lineheight a scaling factor rather than an absolute offset. In the latter case, it would then be more appropriate to make lineheight sensitive to the "units" property, but I don't want to go down that road.

 
diff -r dc76e3909d36 libinterp/interp-core/gl-render.cc
--- a/libinterp/interp-core/gl-render.cc Thu Jun 13 11:56:09 2013 -0400
+++ b/libinterp/interp-core/gl-render.cc Wed Jun 19 16:05:48 2013 +0200
@@ -2668,7 +2668,8 @@
   text_renderer.set_font (props.get ("fontname").string_value (),
                           props.get ("fontweight").string_value (),
                           props.get ("fontangle").string_value (),
-                          props.get ("fontsize").double_value ());
+                          props.get ("fontsize").double_value ()
+                          props.get ("lineheight").double_value ());
 #endif
 }
 
diff -r dc76e3909d36 libinterp/interp-core/txt-eng-ft.cc
--- a/libinterp/interp-core/txt-eng-ft.cc Thu Jun 13 11:56:09 2013 -0400
+++ b/libinterp/interp-core/txt-eng-ft.cc Wed Jun 19 16:05:48 2013 +0200
@@ -253,7 +253,7 @@
 
 void
 ft_render::set_font (const std::string& name, const std::string& weight,
-                     const std::string& angle, double size)
+                     const std::string& angle, double size, double lineheight)
 {
   if (face)
     FT_Done_Face (face);
@@ -342,7 +342,7 @@
                       {
                         line_index++;
                         xoffset = multiline_align_xoffsets[line_index];
-                        yoffset -= (face->size->metrics.height >> 6);
+                        yoffset -= (lineheight * (face->size->metrics.height >> 6));
                       }
                     }
                   else if (FT_Render_Glyph (face->glyph, FT_RENDER_MODE_NORMAL))
@@ -410,7 +410,7 @@
                         // allocate a bounding box larger than the horizontal
                         // width of the multi-line
                         box_line_width = 0;
-                        bbox(1) -= (face->size->metrics.height >> 6);
+                        bbox(1) -= (lineheight * (face->size->metrics.height >> 6));
                       }
                     }
                   else
diff -r dc76e3909d36 libinterp/interpfcn/graphics.in.h
--- a/libinterp/interpfcn/graphics.in.h Thu Jun 13 11:56:09 2013 -0400
+++ b/libinterp/interpfcn/graphics.in.h Wed Jun 19 16:05:48 2013 +0200
@@ -3815,6 +3815,7 @@
       radio_property fontangle u , "{normal}|italic|oblique"
       string_property fontname u , OCTAVE_DEFAULT_FONTNAME
       double_property fontsize u , 10
+      double_property lineheight hu, 0
       radio_property fontunits SU , "{points}|normalized|inches|centimeters|pixels"
       radio_property fontweight u , "{normal}|light|demi|bold"
       radio_property gridlinestyle , "-|--|{:}|-.|none"
@@ -3963,6 +3964,7 @@
     void update_font (void);
     void update_fontname (void) { update_font (); }
     void update_fontsize (void) { update_font (); }
+    void update_lineheight (void) { update_font (); }
     void update_fontangle (void) { update_font (); }
     void update_fontweight (void) { update_font (); }
 
@@ -4274,6 +4276,7 @@
       color_property color u , color_values (0, 0, 0)
       string_property fontname u , OCTAVE_DEFAULT_FONTNAME
       double_property fontsize u , 10
+      double_property lineheight hu , 0
       radio_property fontangle u , "{normal}|italic|oblique"
       radio_property fontweight u , "light|{normal}|demi|bold"
       radio_property interpreter u , "{tex}|none|latex"
@@ -4358,6 +4361,7 @@
     void update_color (void) { update_font (); }
     void update_fontname (void) { update_font (); update_text_extent (); }
     void update_fontsize (void) { update_font (); update_text_extent (); }
+    void update_lineheight (void) { update_font (); update_text_extent (); }
     void update_fontangle (void) { update_font (); update_text_extent (); }
     void update_fontweight (void) { update_font (); update_text_extent (); }
     void update_interpreter (void) { update_text_extent (); }

then I changed ft_renderer::set_font (add new parameter to body of function) and again get 

--- a/libinterp/interp-core/gl-render.cc Thu Jun 13 11:56:09 2013 -0400
+++ b/libinterp/interp-core/gl-render.cc Wed Jun 19 16:25:31 2013 +0200
@@ -2668,7 +2668,8 @@
   text_renderer.set_font (props.get ("fontname").string_value (),
                           props.get ("fontweight").string_value (),
                           props.get ("fontangle").string_value (),
-                          props.get ("fontsize").double_value ());
+                          props.get ("fontsize").double_value ()
+                          props.get ("lineheight").double_value ());
 #endif
 }
 
diff -r dc76e3909d36 libinterp/interp-core/txt-eng-ft.cc
--- a/libinterp/interp-core/txt-eng-ft.cc Thu Jun 13 11:56:09 2013 -0400
+++ b/libinterp/interp-core/txt-eng-ft.cc Wed Jun 19 16:25:31 2013 +0200
@@ -253,17 +253,17 @@
 
 void
 ft_render::set_font (const std::string& name, const std::string& weight,
-                     const std::string& angle, double size)
+                     const std::string& angle, double size, double lineheight)
 {
   if (face)
     FT_Done_Face (face);
 
   // FIXME: take "fontunits" into account
-  face = ft_manager::get_font (name, weight, angle, size);
+  face = ft_manager::get_font (name, weight, angle, size, lineheight);
 
   if (face)
     {
-      if (FT_Set_Char_Size (face, 0, size*64, 0, 0))
+      if (FT_Set_Char_Size (face, 0, size*64, 0, 0, 0))
         ::warning ("ft_render: unable to set font size to %d", size);
     }
   else
@@ -342,7 +342,7 @@
                       {
                         line_index++;
                         xoffset = multiline_align_xoffsets[line_index];
-                        yoffset -= (face->size->metrics.height >> 6);
+                        yoffset -= (lineheight * (face->size->metrics.height >> 6));
                       }
                     }
                   else if (FT_Render_Glyph (face->glyph, FT_RENDER_MODE_NORMAL))
@@ -410,7 +410,7 @@
                         // allocate a bounding box larger than the horizontal
                         // width of the multi-line
                         box_line_width = 0;
-                        bbox(1) -= (face->size->metrics.height >> 6);
+                        bbox(1) -= (lineheight * (face->size->metrics.height >> 6));
                       }
                     }
                   else
diff -r dc76e3909d36 libinterp/interpfcn/graphics.in.h
--- a/libinterp/interpfcn/graphics.in.h Thu Jun 13 11:56:09 2013 -0400
+++ b/libinterp/interpfcn/graphics.in.h Wed Jun 19 16:25:31 2013 +0200
@@ -3815,6 +3815,7 @@
       radio_property fontangle u , "{normal}|italic|oblique"
       string_property fontname u , OCTAVE_DEFAULT_FONTNAME
       double_property fontsize u , 10
+      double_property lineheight hu, 0
       radio_property fontunits SU , "{points}|normalized|inches|centimeters|pixels"
       radio_property fontweight u , "{normal}|light|demi|bold"
       radio_property gridlinestyle , "-|--|{:}|-.|none"
@@ -3963,6 +3964,7 @@
     void update_font (void);
     void update_fontname (void) { update_font (); }
     void update_fontsize (void) { update_font (); }
+    void update_lineheight (void) { update_font (); }
     void update_fontangle (void) { update_font (); }
     void update_fontweight (void) { update_font (); }
 
@@ -4274,6 +4276,7 @@
       color_property color u , color_values (0, 0, 0)
       string_property fontname u , OCTAVE_DEFAULT_FONTNAME
       double_property fontsize u , 10
+      double_property lineheight hu , 0
       radio_property fontangle u , "{normal}|italic|oblique"
       radio_property fontweight u , "light|{normal}|demi|bold"
       radio_property interpreter u , "{tex}|none|latex"
@@ -4358,6 +4361,7 @@
     void update_color (void) { update_font (); }
     void update_fontname (void) { update_font (); update_text_extent (); }
     void update_fontsize (void) { update_font (); update_text_extent (); }
+    void update_lineheight (void) { update_font (); update_text_extent (); }
     void update_fontangle (void) { update_font (); update_text_extent (); }
     void update_fontweight (void) { update_font (); update_text_extent (); }
     void update_interpreter (void) { update_text_extent (); }

Error message is:
get: unknown text property lineheight
error: called from:
error:   /usr/share/octave/3.6.2/m/plot/private/__axis_label__.m at line 30, column 3
error:   /usr/share/octave/3.6.2/m/plot/title.m at line 39, column 7

This may be due to the fact that you marked the option as "hidden".

Michael.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]