]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3483: Pango font size should be calculated using rounding
authorDavid Kastrup <dak@gnu.org>
Thu, 1 Aug 2013 10:20:24 +0000 (12:20 +0200)
committerDavid Kastrup <dak@gnu.org>
Thu, 8 Aug 2013 07:30:57 +0000 (09:30 +0200)
So far, pango font size has been calculated using truncation.  Since
the calculation of font size may involve conversion of magnifications
to font-size and back, numerical errors can easily throw the
calculation slightly off.  For that reason, rounding is the
appropriate option here.

lily/pango-select.cc
lily/paper-def.cc

index cb05b0c183037f6e4c472253288be2bbfaa89936..082bcd824374ca9b8907c36e28b6b601b83fdc85 100644 (file)
@@ -19,6 +19,7 @@
 
 #include "dimensions.hh"
 #include "all-font-metrics.hh"
+#include "libc-extension.hh"
 #include "output-def.hh"
 #include "pango-font.hh"
 
@@ -54,7 +55,8 @@ properties_to_pango_description (SCM chain, Real text_size)
                                  0.0);
   Real size = text_size * pow (2.0, step / 6.0);
 
-  pango_font_description_set_size (description, gint (size * PANGO_SCALE));
+  pango_font_description_set_size (description,
+                                   gint (my_round (size * PANGO_SCALE)));
   return description;
 }
 
index aa3a296c1f4bca5f179af85b459ed41f70b825c0..4c6dc86ebeb8d645477920e9e4aa35c4b45cdd5a 100644 (file)
@@ -18,6 +18,7 @@
 */
 
 #include "dimensions.hh"
+#include "libc-extension.hh"
 #include "output-def.hh"
 #include "modified-font-metric.hh"
 #include "pango-font.hh"
@@ -92,9 +93,9 @@ find_pango_font (Output_def *layout, SCM descr, Real factor)
   PangoFontDescription *description
     = pango_font_description_from_string (scm_i_string_chars (descr));
 
-  pango_font_description_set_size (description,
-                                   gint (factor *
-                                         pango_font_description_get_size (description)));
+  pango_font_description_set_size
+    (description,
+     gint (my_round (factor * pango_font_description_get_size (description))));
 
   Font_metric *fm = all_fonts_global->find_pango_font (description,
                                                        output_scale (layout));