From: Han-Wen Nienhuys Date: Sat, 25 Dec 2004 02:38:23 +0000 (+0000) Subject: * flower/file-path.cc (find): try to open directly as well, so we X-Git-Tag: release/2.5.14~355 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=98ba77f9a972c75e431f29a47df18676c3d65621;p=lilypond.git * flower/file-path.cc (find): try to open directly as well, so we find absolute path files. * lily/pango-select.cc: new file. * scm/framework-ps.scm: remove all encoding code. load pfb/pfa for PangoFont too. * lily/lily-guile.cc (ly_chain_assoc_get): new function. --- diff --git a/ChangeLog b/ChangeLog index 7e7fdd754f..c0de0c6935 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-12-25 Han-Wen Nienhuys + + * scm/framework-ps.scm: remove all encoding code. + load pfb/pfa for PangoFont too. + + * lily/lily-guile.cc (ly_chain_assoc_get): new function. + 2004-12-22 Werner Lemberg Prepare glyph shapes for mf2pt1 conversion. diff --git a/Documentation/user/invoking.itely b/Documentation/user/invoking.itely index 7fcc0bcd8e..7359b9ac67 100644 --- a/Documentation/user/invoking.itely +++ b/Documentation/user/invoking.itely @@ -57,7 +57,7 @@ information. @item -f,--format=@var{format} -A comma separated list of back-end output formats to use. Choices are +the output format to use for the back-end. Choices are @table @code @item tex for @TeX{} output, to be processed with La@TeX{} @@ -65,7 +65,7 @@ for @TeX{} output, to be processed with La@TeX{} for PostScript @cindex PostScript output @item svg - for SVG (Scalable Vector Graphics.) + for SVG (Scalable Vector Graphics) @cindex SVG (Scalable Vector Graphics) @item scm for a dump of the raw, internal Scheme-based drawing commands. diff --git a/VERSION b/VERSION index 509cbde46e..189da5b16f 100644 --- a/VERSION +++ b/VERSION @@ -1,6 +1,6 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=2 MINOR_VERSION=5 -PATCH_LEVEL=4 +PATCH_LEVEL=5 MY_PATCH_LEVEL= diff --git a/config.hh.in b/config.hh.in index 6dcc94c183..cb6a64eafe 100644 --- a/config.hh.in +++ b/config.hh.in @@ -76,5 +76,8 @@ /* define if you have pango 1.6 */ #define HAVE_PANGO16 0 +/* define if you have pango FT2 binding */ +#define HAVE_PANGO_FT2 0 + /* define if you have pango_fc_font_map_add_decoder_find_func */ #define HAVE_PANGO_FC_FONT_MAP_ADD_DECODER_FIND_FUNC 0 diff --git a/flower/file-path.cc b/flower/file-path.cc index eb08b9251a..25b3931dbc 100644 --- a/flower/file-path.cc +++ b/flower/file-path.cc @@ -54,8 +54,17 @@ File_path::find (String name) const { if (!name.length () || (name == "-") ) return name; - int n = size (); - for (int i = 0; i < n; i++) + + /* + TODO: should check for absolute path + */ + if (FILE *f =fopen (name.to_str0 (), "r")) + { + fclose (f); + return name; + } + + for (int i = 0; i < size (); i++) { String file_name = elem (i); String sep = ::to_string (DIRSEP); diff --git a/lily/all-font-metrics.cc b/lily/all-font-metrics.cc index a59738536e..c9b4b5d5e0 100644 --- a/lily/all-font-metrics.cc +++ b/lily/all-font-metrics.cc @@ -25,7 +25,7 @@ All_font_metrics::All_font_metrics (String path) tfm_dict_ = new Scheme_hash_table; otf_dict_ = new Scheme_hash_table; -#ifdef HAVE_PANGO16 +#if HAVE_PANGO_FT2 PangoFontMap*pfm = pango_ft2_font_map_new (); pango_ft2_fontmap_ = @@ -53,7 +53,7 @@ All_font_metrics::All_font_metrics (All_font_metrics const&) { } -#ifdef HAVE_PANGO16 +#if HAVE_PANGO_FT2 Pango_font * All_font_metrics::find_pango_font (PangoFontDescription*description) { diff --git a/lily/font-metric.cc b/lily/font-metric.cc index 1a6e215041..277c2cadfc 100644 --- a/lily/font-metric.cc +++ b/lily/font-metric.cc @@ -227,7 +227,13 @@ LY_DEFINE (ly_font_file_name, "ly:font-file-name", { Font_metric *fm = unsmob_metrics (font); SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric"); - return scm_car (fm->description_); + return fm->font_file_name(); +} + +SCM +Font_metric::font_file_name () const +{ + return scm_car (description_); } String diff --git a/lily/font-select.cc b/lily/font-select.cc index 3b17dedc25..c05f0b1f20 100644 --- a/lily/font-select.cc +++ b/lily/font-select.cc @@ -109,7 +109,7 @@ properties_to_font_size_family (SCM fonts, SCM alist_chain) Font_metric * select_encoded_font (Output_def *layout, SCM chain, SCM input_encoding) { - SCM name = ly_assoc_chain (ly_symbol2scm ("font-name"), chain); + SCM name = ly_chain_assoc (ly_symbol2scm ("font-name"), chain); if (!scm_is_pair (name) || !scm_is_string (scm_cdr (name))) { @@ -121,14 +121,14 @@ select_encoded_font (Output_def *layout, SCM chain, SCM input_encoding) if (scm_is_string (name)) { - SCM mag = ly_assoc_chain (ly_symbol2scm ("font-magnification"), chain); + SCM mag = ly_chain_assoc (ly_symbol2scm ("font-magnification"), chain); Real rmag = (scm_is_pair (mag) ? robust_scm2double (scm_cdr (mag), 1.0) : 1); Font_metric *fm = all_fonts_global->find_font (ly_scm2string (name)); SCM font_encoding - = scm_cdr (ly_assoc_chain (ly_symbol2scm ("font-encoding"), chain)); + = scm_cdr (ly_chain_assoc (ly_symbol2scm ("font-encoding"), chain)); return find_scaled_font (layout, fm, rmag, font_encoding, input_encoding); } else if (scm_instance_p (name)) @@ -136,13 +136,13 @@ select_encoded_font (Output_def *layout, SCM chain, SCM input_encoding) SCM base_size = scm_slot_ref (name, ly_symbol2scm ("default-size")); SCM vec = scm_slot_ref (name, ly_symbol2scm ("size-vector")); - SCM font_size = ly_assoc_chain (ly_symbol2scm ("font-size"), chain); + SCM font_size = ly_chain_assoc (ly_symbol2scm ("font-size"), chain); Real req = 0; if (scm_is_pair (font_size)) req = scm_to_double (scm_cdr (font_size)); SCM font_encoding - = scm_cdr (ly_assoc_chain (ly_symbol2scm ("font-encoding"), chain)); + = scm_cdr (ly_chain_assoc (ly_symbol2scm ("font-encoding"), chain)); return get_font_by_mag_step (layout, req, vec, scm_to_double (base_size), font_encoding, input_encoding); diff --git a/lily/include/font-metric.hh b/lily/include/font-metric.hh index cb20aa5f5e..b9da9002b9 100644 --- a/lily/include/font-metric.hh +++ b/lily/include/font-metric.hh @@ -38,7 +38,7 @@ public: virtual Stencil get_ascii_char_stencil (int k) const; virtual String coding_scheme () const; virtual SCM sub_fonts () const; - + virtual SCM font_file_name () const; DECLARE_SMOBS (Font_metric,); private: diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index 40b9bcc13d..d813ed44cf 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -96,7 +96,8 @@ String ly_scm2string (SCM s); String ly_symbol2string (SCM); SCM ly_offset2scm (Offset); Offset ly_scm2offset (SCM); -SCM ly_assoc_chain (SCM key, SCM achain); +SCM ly_chain_assoc (SCM key, SCM achain); +SCM ly_chain_assoc_get (SCM key, SCM achain, SCM dfault); SCM ly_assoc_cdr (SCM key, SCM alist); SCM ly_assoc_get (SCM key, SCM alist, SCM def); Interval ly_scm2interval (SCM); diff --git a/lily/include/output-def.hh b/lily/include/output-def.hh index 15b35f1eac..92a5f13996 100644 --- a/lily/include/output-def.hh +++ b/lily/include/output-def.hh @@ -58,7 +58,7 @@ public: void set_variable (SCM sym, SCM val); Real get_dimension (SCM symbol) const; }; - +SCM get_font_table (Output_def *def); void assign_context_def (Output_def *m, SCM transdef); SCM find_context_def (Output_def const *m, SCM name); diff --git a/lily/include/pango-font.hh b/lily/include/pango-font.hh index de97e0bf57..e6241c9493 100644 --- a/lily/include/pango-font.hh +++ b/lily/include/pango-font.hh @@ -24,7 +24,12 @@ struct Pango_font : Font_metric PangoContext *context_; PangoAttrList *attribute_list_; Real scale_; + SCM subfonts_; public: + virtual SCM sub_fonts () const; + SCM font_file_name () const; + virtual void derived_mark () const; + void register_font_file (String, String); Stencil text_stencil (String) const; Pango_font (PangoFT2FontMap *, int dpi, @@ -38,7 +43,10 @@ symbols_to_pango_font_description(SCM family, SCM variant, SCM weight, SCM stretch, - SCM size); + Real size); + +Font_metric * +select_pango_font (Output_def *layout, SCM chain); #endif #endif /* PANGO_FONT_HH */ diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index 2d7455019d..a5cd70e2e9 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -446,11 +446,23 @@ ly_deep_copy (SCM src) return src; } - - +SCM +ly_chain_assoc_get (SCM key, SCM achain, SCM dfault) +{ + if (scm_is_pair (achain)) + { + SCM handle = scm_assoc (key, scm_car (achain)); + if (scm_is_pair (handle)) + return scm_cdr (handle); + else + return ly_chain_assoc (key, scm_cdr (achain)); + } + else + return dfault; +} SCM -ly_assoc_chain (SCM key, SCM achain) +ly_chain_assoc (SCM key, SCM achain) { if (scm_is_pair (achain)) { @@ -458,7 +470,7 @@ ly_assoc_chain (SCM key, SCM achain) if (scm_is_pair (handle)) return handle; else - return ly_assoc_chain (key, scm_cdr (achain)); + return ly_chain_assoc (key, scm_cdr (achain)); } else return SCM_BOOL_F; diff --git a/lily/pango-font.cc b/lily/pango-font.cc index d9944caaab..7529ae8115 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -7,142 +7,55 @@ */ -#include - -#include "pango-font.hh" -#include "stencil.hh" - -PangoStyle -symbol_to_pango_style (SCM style) -{ - PangoStyle pstyle = PANGO_STYLE_NORMAL; - if (style == ly_symbol2scm ("italic")) - { - pstyle = PANGO_STYLE_NORMAL; - } - else if (style == ly_symbol2scm ("oblique") - || style == ly_symbol2scm ("slanted") - ) - { - pstyle = PANGO_STYLE_OBLIQUE; - } - - return pstyle; -} -PangoVariant -symbol_to_pango_variant (SCM variant) -{ - PangoVariant pvariant; - if (variant == ly_symbol2scm ("caps")) - { - pvariant = PANGO_VARIANT_SMALL_CAPS; - } - return pvariant; -} - - -PangoWeight -symbol_to_pango_weight (SCM weight) -{ - PangoWeight pw = PANGO_WEIGHT_NORMAL; - if (weight == ly_symbol2scm ("bold")) - { - pw = PANGO_WEIGHT_BOLD; - } - if (weight == ly_symbol2scm ("heavy")) - { - pw = PANGO_WEIGHT_HEAVY; - } - if (weight == ly_symbol2scm ("ultrabold")) - { - pw = PANGO_WEIGHT_ULTRABOLD; - } - if (weight == ly_symbol2scm ("light")) - { - pw = PANGO_WEIGHT_LIGHT; - } - if (weight == ly_symbol2scm ("ultralight")) - { - pw = PANGO_WEIGHT_ULTRALIGHT; - } - - return pw; -} +#define PANGO_ENABLE_BACKEND // ugh, why necessary? -PangoStretch -symbol_to_pango_stretch (SCM stretch) -{ - PangoStretch ps = PANGO_STRETCH_NORMAL; - - /* - // TODO - - PANGO_STRETCH_ULTRA_CONDENSED, - PANGO_STRETCH_EXTRA_CONDENSED, - PANGO_STRETCH_CONDENSED, - PANGO_STRETCH_SEMI_CONDENSED, - - PANGO_STRETCH_SEMI_EXPANDED, - PANGO_STRETCH_EXPANDED, - PANGO_STRETCH_EXTRA_EXPANDED, - PANGO_STRETCH_ULTRA_EXPANDED - */ - return ps; -} +#include +#include "pango-font.hh" +#if HAVE_PANGO_FT2 +#include "stencil.hh" -PangoFontDescription* -symbols_to_pango_font_description(SCM family, - SCM style, - SCM variant, - SCM weight, - SCM stretch, - SCM size) -{ - PangoFontDescription * description = pango_font_description_new (); - - pango_font_description_set_family (description, - ly_symbol2string (family).to_str0 ()); - pango_font_description_set_style (description, - symbol_to_pango_style (style)); - pango_font_description_set_variant (description, - symbol_to_pango_variant (variant)); - pango_font_description_set_weight (description, - symbol_to_pango_weight (weight)); - pango_font_description_set_stretch (description, - symbol_to_pango_stretch (stretch)); - pango_font_description_set_size (description, - gint (scm_to_double (size) * PANGO_SCALE)); - - return description; -} Pango_font::Pango_font (PangoFT2FontMap *fontmap, int resolution, Direction dir, PangoFontDescription * description) { + subfonts_ = SCM_EOL; PangoDirection pango_dir = (dir==RIGHT) ? PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL; context_ = pango_ft2_font_map_create_context (fontmap); attribute_list_= pango_attr_list_new(); - scale_ = PANGO_SCALE * resolution * 72.27; + scale_ = 1.0 / (PANGO_SCALE * resolution * 72.27); pango_context_set_language (context_, pango_language_from_string ("en_US")); pango_context_set_base_dir (context_, pango_dir); pango_context_set_font_description (context_, description); } + Pango_font::~Pango_font () { g_object_unref (context_); pango_attr_list_unref (attribute_list_); } +void +Pango_font::register_font_file (String filename, String ps_name) +{ + subfonts_ = scm_cons (//scm_cons (scm_makfrom0str (ps_name.to_str0 ()), + scm_makfrom0str (filename.to_str0 ()), + subfonts_); +} +void +Pango_font::derived_mark () const +{ + scm_gc_mark (subfonts_); +} Stencil Pango_font::text_stencil (String str) const { @@ -154,15 +67,14 @@ Pango_font::text_stencil (String str) const const int GLYPH_NAME_LEN = 256; char glyph_name[GLYPH_NAME_LEN]; - Box dest_extent; - dest_extent.set_empty (); GList * ptr = items; - SCM glyph_exprs = SCM_EOL; + Stencil dest; while (ptr) { PangoItem *item = (PangoItem*) ptr->data; PangoAnalysis *pa = &(item->analysis); PangoGlyphString *pgs = pango_glyph_string_new(); + pango_shape (str.to_str0 (), str.length (), pa, pgs); PangoRectangle logical_rect; @@ -178,8 +90,9 @@ Pango_font::text_stencil (String str) const b.translate (Offset (- logical_rect.x, -logical_rect.y)); b.scale (scale_); - dest_extent.unite (b); - + + SCM glyph_exprs = SCM_EOL; + SCM *tail = &glyph_exprs; for (int i = 0; i < pgs->num_glyphs; i++) { PangoGlyphInfo *pgi = pgs->glyphs + i; @@ -188,19 +101,53 @@ Pango_font::text_stencil (String str) const PangoGlyphGeometry ggeo = pgi->geometry; FT_Get_Glyph_Name (ftface, pg, glyph_name, GLYPH_NAME_LEN); - glyph_exprs = scm_cons (scm_list_5 (ly_symbol2scm ("named-ps-glyph"), - scm_from_int (ggeo.x_offset), - scm_from_int (ggeo.y_offset), - scm_makfrom0str (glyph_name), - scm_makfrom0str (FT_Get_Postscript_Name (ftface))), - glyph_exprs); + *tail = scm_cons (scm_list_3 (scm_from_double (ggeo.x_offset * scale_), + scm_from_double (ggeo.y_offset * scale_), + scm_makfrom0str (glyph_name)), + SCM_EOL); + tail = SCM_CDRLOC(*tail); } + FcPattern *fcpat = fcfont->font_pattern; + char *filename = 0; + FcPatternGetString(fcpat, FC_FILE, 0, (FcChar8 **) &filename); + char const *ps_name = FT_Get_Postscript_Name (ftface); + ((Pango_font *) this)->register_font_file (filename, ps_name); + + SCM expr = scm_list_3 (ly_symbol2scm ("glyph-string"), + scm_makfrom0str (ps_name), + ly_quote_scm (glyph_exprs)); + + Stencil item_stencil (b, expr); + + dest.add_stencil (item_stencil); + + pango_fc_font_unlock_face (fcfont); ptr = ptr->next; } - Stencil dest (dest_extent, - scm_cons (ly_symbol2scm ("combine-stencil"), - glyph_exprs)); return dest; } + +SCM +Pango_font::sub_fonts () const +{ + return subfonts_; +} + +SCM +Pango_font::font_file_name () const +{ + return SCM_BOOL_F; +} + +LY_DEFINE(ly_pango_font_p, "ly:pango-font?", + 1,0,0, + (SCM f), + "Is @var{f} a pango font?") + +{ + return scm_from_bool (dynamic_cast (unsmob_metrics (f))); +} + +#endif diff --git a/lily/pango-select.cc b/lily/pango-select.cc new file mode 100644 index 0000000000..0e1aa8929c --- /dev/null +++ b/lily/pango-select.cc @@ -0,0 +1,180 @@ +/* + pango-select.cc -- implement lily font selection for Pango_fonts. + + source file of the GNU LilyPond music typesetter + + (c) 2004 Han-Wen Nienhuys + +*/ +#include + +#include "all-font-metrics.hh" +#include "output-def.hh" +#include "pango-font.hh" + +Font_metric * +select_pango_font (Output_def *layout, SCM chain) +{ + SCM name = ly_chain_assoc (ly_symbol2scm ("font-name"), chain); + + PangoFontDescription *description = 0; + if (scm_is_pair (name) && scm_is_string (scm_cdr (name))) + { + String name_str = ly_scm2string (scm_cdr (name)); + description = pango_font_description_from_string (name_str.to_str0 ()); + } + else + { + SCM family = ly_chain_assoc_get (ly_symbol2scm ("font-family"), chain, + SCM_BOOL_F); + SCM variant = ly_chain_assoc_get (ly_symbol2scm ("font-shape"), chain, + SCM_BOOL_F); + + SCM style = ly_chain_assoc_get (ly_symbol2scm ("font-shape"), chain, + SCM_BOOL_F); + 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); + } + + Font_metric * fm = all_fonts_global->find_pango_font (description); + + /* + Klutz the pango font into font table, otherwise it doesn't show up + in the output. + */ + SCM font_table = get_font_table (layout); + SCM sizes = scm_hashq_ref (font_table, fm->self_scm (), SCM_BOOL_F); + if (sizes != SCM_BOOL_F) + { + SCM met = scm_assoc (scm_make_real (1.0), sizes); + if (scm_is_pair (met)) + return unsmob_metrics (scm_cdr (met)); + } + else + sizes = SCM_EOL; + + sizes = scm_acons (scm_make_real (1.0), fm->self_scm(), sizes); + scm_hashq_set_x (font_table, fm->self_scm (), sizes); + + return fm; +} + + +PangoStyle +symbol_to_pango_style (SCM style) +{ + PangoStyle pstyle = PANGO_STYLE_NORMAL; + if (style == ly_symbol2scm ("italic")) + { + pstyle = PANGO_STYLE_NORMAL; + } + else if (style == ly_symbol2scm ("oblique") + || style == ly_symbol2scm ("slanted") + ) + { + pstyle = PANGO_STYLE_OBLIQUE; + } + + return pstyle; +} + +PangoVariant +symbol_to_pango_variant (SCM variant) +{ + PangoVariant pvariant; + if (variant == ly_symbol2scm ("caps")) + { + pvariant = PANGO_VARIANT_SMALL_CAPS; + } + return pvariant; +} + + +PangoWeight +symbol_to_pango_weight (SCM weight) +{ + PangoWeight pw = PANGO_WEIGHT_NORMAL; + if (weight == ly_symbol2scm ("bold")) + { + pw = PANGO_WEIGHT_BOLD; + } + if (weight == ly_symbol2scm ("heavy")) + { + pw = PANGO_WEIGHT_HEAVY; + } + if (weight == ly_symbol2scm ("ultrabold")) + { + pw = PANGO_WEIGHT_ULTRABOLD; + } + if (weight == ly_symbol2scm ("light")) + { + pw = PANGO_WEIGHT_LIGHT; + } + if (weight == ly_symbol2scm ("ultralight")) + { + pw = PANGO_WEIGHT_ULTRALIGHT; + } + + return pw; +} + +PangoStretch +symbol_to_pango_stretch (SCM) // stretch) +{ + PangoStretch ps = PANGO_STRETCH_NORMAL; + + /* + // TODO + + PANGO_STRETCH_ULTRA_CONDENSED, + PANGO_STRETCH_EXTRA_CONDENSED, + PANGO_STRETCH_CONDENSED, + PANGO_STRETCH_SEMI_CONDENSED, + + PANGO_STRETCH_SEMI_EXPANDED, + PANGO_STRETCH_EXPANDED, + PANGO_STRETCH_EXTRA_EXPANDED, + PANGO_STRETCH_ULTRA_EXPANDED + */ + return ps; +} + + + +PangoFontDescription* +symbols_to_pango_font_description(SCM family, + SCM style, + SCM variant, + SCM weight, + SCM stretch, + Real size) +{ + PangoFontDescription * description = pango_font_description_new (); + + String family_str = scm_is_symbol (family) + ? ly_symbol2string (family) + : String("roman"); + pango_font_description_set_family (description, + family_str.to_str0 ()); + pango_font_description_set_style (description, + symbol_to_pango_style (style)); + pango_font_description_set_variant (description, + symbol_to_pango_variant (variant)); + pango_font_description_set_weight (description, + 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/paper-def.cc b/lily/paper-def.cc index 84ef5f298d..bfe6e5c13b 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -10,6 +10,7 @@ #include "ly-module.hh" #include "output-def.hh" #include "modified-font-metric.hh" +#include "pango-font.hh" Real output_scale (Output_def *od) @@ -17,6 +18,21 @@ output_scale (Output_def *od) return scm_to_double (od->lookup_variable (ly_symbol2scm ("outputscale"))); } + +SCM +get_font_table (Output_def *def) +{ + SCM font_table = def->lookup_variable (ly_symbol2scm ("scaled-fonts")); + if (scm_hash_table_p (font_table) != SCM_BOOL_T) + { + font_table = scm_c_make_hash_table (11); + def->set_variable (ly_symbol2scm ("scaled-fonts"), font_table); + } + return font_table; +} + + + /* TODO: should add nesting for Output_def here too. */ Font_metric * find_scaled_font (Output_def *mod, Font_metric *f, Real m, @@ -27,14 +43,9 @@ find_scaled_font (Output_def *mod, Font_metric *f, Real m, Real lookup_mag = m / output_scale (mod); - - SCM font_table = mod->lookup_variable (ly_symbol2scm ("scaled-fonts")); - if (scm_hash_table_p (font_table) != SCM_BOOL_T) - { - font_table = scm_c_make_hash_table (11); - mod->set_variable (ly_symbol2scm ("scaled-fonts"), font_table); - } + + SCM font_table = get_font_table (mod); SCM sizes = scm_hashq_ref (font_table, f->self_scm (), SCM_BOOL_F); if (sizes != SCM_BOOL_F) { @@ -92,7 +103,8 @@ LY_DEFINE (ly_paper_fonts, "ly:paper-fonts", { Font_metric *fm = unsmob_metrics (scm_cdar (t)); - if (dynamic_cast (fm)) + if (dynamic_cast (fm) + || dynamic_cast (fm)) ell = scm_cons (fm->self_scm (), ell); } } diff --git a/lily/text-item.cc b/lily/text-item.cc index 505b2ec7cd..7203d7b8e0 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -11,6 +11,9 @@ #include +#include "main.hh" +#include "config.hh" +#include "pango-font.hh" #include "warn.hh" #include "grob.hh" #include "font-interface.hh" @@ -18,6 +21,7 @@ #include "modified-font-metric.hh" #include "ly-module.hh" + MAKE_SCHEME_CALLBACK (Text_interface, interpret_string, 4) SCM Text_interface::interpret_string (SCM layout_smob, @@ -32,12 +36,17 @@ Text_interface::interpret_string (SCM layout_smob, String str = ly_scm2string (markup); -#if 0 +#if HAVE_PANGO_FT2 + if (output_format_global != "tex") + { + Font_metric *fm = select_pango_font (layout, props); + return fm->text_stencil (str).smobbed_copy (); + } +#endif + SCM_ASSERT_TYPE (input_encoding == SCM_EOL || scm_is_symbol (input_encoding), input_encoding, SCM_ARG2, __FUNCTION__, "symbol"); - - String str = ly_scm2string (markup); if (!scm_is_symbol (input_encoding)) { SCM enc = layout->lookup_variable (ly_symbol2scm ("inputencoding")); @@ -49,33 +58,9 @@ Text_interface::interpret_string (SCM layout_smob, Font_metric *fm = select_encoded_font (layout, props, input_encoding); - SCM lst = SCM_EOL; - Box b; - if (Modified_font_metric* mf = dynamic_cast (fm)) - { - lst = scm_list_3 (ly_symbol2scm ("text"), - mf->self_scm (), - markup); - - b = mf->text_dimension (str); - } - else - { - /* ARGH. */ - programming_error ("Must have Modified_font_metric for text."); - scm_display (fm->description_, scm_current_error_port ()); - } - - return Stencil (b, lst).smobbed_copy (); -#else - - - Font_metric *fm = select_encoded_font (layout, props, input_encoding); - return fm->text_stencil (str).smobbed_copy (); -#endif + return fm->text_stencil (str).smobbed_copy(); } - MAKE_SCHEME_CALLBACK (Text_interface, interpret_markup, 3) SCM Text_interface::interpret_markup (SCM layout_smob, SCM props, SCM markup) diff --git a/ps/lilyponddefs.ps b/ps/lilyponddefs.ps index f4897127c9..542513c4e2 100644 --- a/ps/lilyponddefs.ps +++ b/ps/lilyponddefs.ps @@ -85,6 +85,6 @@ staff-line-thickness setlinewidth staff-height init-paper - +pstack % end lilyponddefs.ps diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm index ade34dcba0..4bab9cb734 100644 --- a/scm/framework-ps.scm +++ b/scm/framework-ps.scm @@ -26,19 +26,12 @@ (define-public (ps-font-command font . override-coding) (let* ((name (ly:font-file-name font)) - (magnify (ly:font-magnification font)) - (coding-alist (ly:font-encoding-alist font)) - (input-encoding (assoc-get 'input-name coding-alist)) - (font-encoding (assoc-get 'output-name coding-alist)) - (coding-command (if (null? override-coding) - (if (equal? input-encoding font-encoding) - #f font-encoding) - (car override-coding)))) + (magnify (ly:font-magnification font))) (string-append "magfont" (string-encode-integer (hashq name 1000000)) "m" (string-encode-integer (inexact->exact (round (* 1000 magnify)))) - (if (not coding-command) "" (string-append "e" coding-command))))) + ))) (define (tex-font? fontname) (or @@ -67,7 +60,7 @@ font-set-name font-set-name version (string-length binary-data) ) binary-data - "%%EndData + "\n%%EndData %%EndResource %%EOF " @@ -77,16 +70,30 @@ (define (load-fonts paper) (let* ((fonts (ly:paper-fonts paper)) - (font-names (uniq-list (sort (map ly:font-file-name fonts) stringpfa bare-file-name) + (ly:gulp-file bare-file-name))) (cff-file-name (ps-embed-cff (ly:gulp-file cff-file-name) x 0)) (a-file-name (ly:gulp-file a-file-name)) (b-file-name (ly:pfb->pfa b-file-name)) @@ -98,19 +105,13 @@ (string-join pfas "\n"))) (define (define-fonts paper) - + (define font-list (ly:paper-fonts paper)) (define (define-font command fontname scaling) (string-append "/" command " { /" fontname " findfont " (ly:number->string scaling) " output-scale div scalefont } bind def\n")) - (define (reencode-font fontname encoding scaling command) - (let ((coding-vector (get-coding-command encoding))) - (string-append - "/" fontname " findfont " coding-vector " /" command " reencode-font\n" - "/" command "{ /" command " findfont " (ly:number->string scaling) " output-scale div scalefont } bind def\n"))) - (define (standard-tex-font? x) (or (equal? (substring x 0 2) "ms") (equal? (substring x 0 2) "cm"))) @@ -120,11 +121,8 @@ (fontname (if specced-font-name specced-font-name (ly:font-file-name font))) - - (coding-alist (ly:font-encoding-alist font)) - (input-encoding (assoc-get 'input-name coding-alist)) - (font-encoding (assoc-get 'output-name coding-alist)) (command (ps-font-command font)) + ;; FIXME -- see (ps-font-command ) (plain (ps-font-command font #f)) (designsize (ly:font-design-size font)) @@ -132,42 +130,19 @@ (ops (ly:output-def-lookup paper 'outputscale)) (scaling (* ops magnification designsize))) + ;; Bluesky pfbs have UPCASE names (sigh.) ;; (if (standard-tex-font? fontname) (set! fontname (string-upcase fontname))) - ;; debugging: [output]encoding is broken - ;; found so far: coding-alist is empty! - (pdebug "font: ~S\n" font) - (pdebug "fontname: ~S\n" fontname) - (pdebug "input-encoding:~S\n" input-encoding) - (pdebug "font-encoding:~S\n" font-encoding) - - (pdebug "coding-alist:~S\n" coding-alist) - (string-append - (define-font plain fontname scaling) - (if (equal? input-encoding font-encoding) - "" - (reencode-font fontname input-encoding scaling command))))) - - (define (font-load-encoding encoding) - (let ((file-name (get-coding-file-name encoding))) - (ly:gulp-file (ly:kpathsea-find-file file-name)))) - - (let* ((encoding-list (map (lambda (x) - (assoc-get 'input-name - (ly:font-encoding-alist x))) - font-list)) - (encodings (uniq-list (sort-list (filter string? encoding-list) - string