From cccee40bb3a13b6c230fa98a8ca61f7c526d5f66 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 1 Jan 2005 15:03:05 +0000 Subject: [PATCH] * scm/framework-ps.scm (output-variables): separately scale the page to mm * lily/pango-font.cc (Pango_font): fix scaling. * lily/font-metric.cc (design_size): design_size returns a dimension now as well. --- ChangeLog | 10 ++++++++++ lily/font-metric.cc | 3 ++- lily/font-select.cc | 9 +++------ lily/include/pango-font.hh | 5 ++--- lily/open-type-font.cc | 4 ++-- lily/pango-font.cc | 12 +++++++++--- lily/pango-select.cc | 26 +++++++++----------------- lily/tfm.cc | 2 +- scm/framework-ps.scm | 6 ++++-- 9 files changed, 42 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index ca5108a5c3..111a47c507 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-01-01 Han-Wen Nienhuys + + * scm/framework-ps.scm (output-variables): separately scale the + page to mm + + * lily/pango-font.cc (Pango_font): fix scaling. + + * lily/font-metric.cc (design_size): design_size returns a + dimension now as well. + 2004-12-31 Han-Wen Nienhuys * mf/GNUmakefile ($(outdir)/%.otf-table): use findstring. Fixes diff --git a/lily/font-metric.cc b/lily/font-metric.cc index cc0ae4244f..415e2db6de 100644 --- a/lily/font-metric.cc +++ b/lily/font-metric.cc @@ -13,6 +13,7 @@ #include #include +#include "dimensions.hh" #include "modified-font-metric.hh" #include "open-type-font.hh" #include "stencil.hh" @@ -24,7 +25,7 @@ Real Font_metric::design_size () const { - return 1.0; + return 1.0 * point_constant; } String diff --git a/lily/font-select.cc b/lily/font-select.cc index 9ded64e067..348544e3e4 100644 --- a/lily/font-select.cc +++ b/lily/font-select.cc @@ -8,6 +8,7 @@ #include +#include "dimensions.hh" #include "all-font-metrics.hh" #include "output-def.hh" #include "font-interface.hh" @@ -47,11 +48,6 @@ wild_compare (SCM field_val, SCM val) || field_val == val); } -/* - TODO: this triggers a great number of font-loads (feta11 upto - parmesan23). We could make a Delayed_load_font_metric for which the - design size is specced in advance. - */ Font_metric * get_font_by_design_size (Output_def *layout, Real requested, SCM font_vector, @@ -144,7 +140,8 @@ select_encoded_font (Output_def *layout, SCM chain, SCM input_encoding) SCM font_encoding = scm_cdr (ly_chain_assoc (ly_symbol2scm ("font-encoding"), chain)); - return get_font_by_mag_step (layout, req, vec, scm_to_double (base_size), + return get_font_by_mag_step (layout, req, vec, + scm_to_double (base_size) * point_constant, font_encoding, input_encoding); } diff --git a/lily/include/pango-font.hh b/lily/include/pango-font.hh index 8b832dcbc4..55e566eb65 100644 --- a/lily/include/pango-font.hh +++ b/lily/include/pango-font.hh @@ -45,13 +45,12 @@ symbols_to_pango_font_description (SCM family, SCM style, SCM variant, SCM weight, - SCM stretch, - Real size); + SCM stretch); Font_metric * select_pango_font (Output_def *layout, SCM chain); -const int PANGO_DPI = 1200; +const int PANGO_RESOLUTION = 1200; #endif /* HAVE_PANGO16 */ #endif /* PANGO_FONT_HH */ diff --git a/lily/open-type-font.cc b/lily/open-type-font.cc index 9664dd43ba..627a35aae4 100644 --- a/lily/open-type-font.cc +++ b/lily/open-type-font.cc @@ -176,7 +176,7 @@ Open_type_font::get_indexed_char (int signed_idx) const Box b (Interval (-hb, m.width - hb), Interval (-vb, m.height - vb)); - b.scale (design_size () * Real (point_constant) / face_->units_per_EM); + b.scale (design_size () / Real (face_->units_per_EM)); return b; } @@ -214,7 +214,7 @@ Open_type_font::design_size () const quickly. --hwn. */ scm_from_int (1)); - return scm_to_double (entry); + return scm_to_double (entry) * Real (point_constant); } diff --git a/lily/pango-font.cc b/lily/pango-font.cc index 6957e8d00c..042ac350a6 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -29,10 +29,16 @@ Pango_font::Pango_font (PangoFT2FontMap *fontmap, ? PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL; context_ = - pango_ft2_get_context (PANGO_DPI, PANGO_DPI); + pango_ft2_get_context (PANGO_RESOLUTION, PANGO_RESOLUTION); // context_ = pango_ft2_font_map_create_context (fontmap); attribute_list_= pango_attr_list_new(); - scale_ = inch_constant / (Real (PANGO_SCALE) * Real (PANGO_DPI)); + + /* + urgh. I don't understand this. Why isn't this 1/(scale * resolution) + + --hwn + */ + scale_ = INCH_TO_BP / (Real (PANGO_SCALE) * Real (PANGO_RESOLUTION)); pango_context_set_language (context_, pango_language_from_string ("en_US")); pango_context_set_base_dir (context_, pango_dir); @@ -105,7 +111,7 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con PangoFontDescription *descr = pango_font_describe (pa->font); Real size = pango_font_description_get_size (descr) - / (Real (PANGO_SCALE)) ; + / (Real (PANGO_SCALE)); FcPattern *fcpat = fcfont->font_pattern; char *filename = 0; diff --git a/lily/pango-select.cc b/lily/pango-select.cc index 71553a1a91..402f788146 100644 --- a/lily/pango-select.cc +++ b/lily/pango-select.cc @@ -8,6 +8,7 @@ */ #include +#include "dimensions.hh" #include "all-font-metrics.hh" #include "output-def.hh" #include "pango-font.hh" @@ -22,13 +23,6 @@ select_pango_font (Output_def *layout, SCM chain) { String name_str = ly_scm2string (scm_cdr (name)); description = pango_font_description_from_string (name_str.to_str0 ()); - - - Real step = robust_scm2double (ly_symbol2scm ("font-size"), 0.0); - Real size = layout->get_dimension (ly_symbol2scm ("text-font-size")) - * pow (2.0, step / 6.0); - pango_font_description_set_size (description, - gint (size * PANGO_SCALE)); } else { @@ -42,16 +36,17 @@ select_pango_font (Output_def *layout, SCM chain) SCM weight = ly_chain_assoc_get (ly_symbol2scm ("font-series"), chain, SCM_BOOL_F); - Real step = robust_scm2double (ly_symbol2scm ("font-size"), 0.0); - Real size = layout->get_dimension (ly_symbol2scm ("text-font-size")) - * pow (2.0, step / 6.0); - description = symbols_to_pango_font_description (family, style, variant, weight, - SCM_BOOL_F, - size); + SCM_BOOL_F); } + Real step = robust_scm2double (ly_symbol2scm ("font-size"), 0.0); + Real size = layout->get_dimension (ly_symbol2scm ("text-font-size")) + * pow (2.0, step / 6.0) * point_constant; + pango_font_description_set_size (description, + gint (size * PANGO_SCALE)); + Font_metric * fm = all_fonts_global->find_pango_font (description); return find_scaled_font (layout, fm, 1.0, @@ -146,8 +141,7 @@ symbols_to_pango_font_description(SCM family, SCM style, SCM variant, SCM weight, - SCM stretch, - Real size) + SCM stretch) { PangoFontDescription * description = pango_font_description_new (); @@ -164,8 +158,6 @@ symbols_to_pango_font_description(SCM family, symbol_to_pango_weight (weight)); pango_font_description_set_stretch (description, symbol_to_pango_stretch (stretch)); - pango_font_description_set_size (description, - gint (size * PANGO_SCALE)); return description; } diff --git a/lily/tfm.cc b/lily/tfm.cc index 6770486f88..815edd3ca1 100644 --- a/lily/tfm.cc +++ b/lily/tfm.cc @@ -111,7 +111,7 @@ Tex_font_metric::make_tfm (String file_name) Real Tex_font_metric::design_size () const { - return info_.design_size; + return info_.design_size * point_constant; } String diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm index 4c53572606..4425cf8a11 100644 --- a/scm/framework-ps.scm +++ b/scm/framework-ps.scm @@ -156,14 +156,16 @@ (value->string (ly:output-def-lookup layout ly-key)) " def \n")) (string-append - "/lily-output-units " (number->string mm-to-bigpoint) " def %% milimeter \n" + "/lily-output-units " (number->string mm-to-bigpoint) " def %% milimeter +lily-output-units lily-output-units scale +" (output-entry "staff-line-thickness" 'linethickness) (output-entry "line-width" 'linewidth) (output-entry "paper-size" 'papersizename) (output-entry "staff-height" 'staffheight) ;junkme. "/output-scale " (number->string (ly:output-def-lookup layout 'outputscale)) - " lily-output-units mul def \n" + " def \n" (output-entry "page-height" 'vsize) (output-entry "page-width" 'hsize))) -- 2.39.2