From 72bd1ea165831738260e671737d84dbaffe6a6fc Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 28 Mar 2006 14:50:49 +0000 Subject: [PATCH] * mf/feta-bolletjes.mf (overdone_heads): add small style (ugly) note heads, for uniform widths in shape note output. * scripts/lilypond-book.py (output): add links to filenames. * scripts/lilypond-book.py (get_option_parser): init output_name to ''. Backportme. --- ChangeLog | 5 ++++ flower/std-string.cc | 1 + lily/include/pango-font.hh | 6 ++++- lily/open-type-font.cc | 12 --------- lily/pango-font.cc | 49 ++++++++++++++++++++++++++---------- lily/ttf.cc | 51 +++++++++++++++++++++++++++++--------- mf/feta-bolletjes.mf | 35 +++++++++++++++++++++++++- mf/feta-test-generic.mf | 4 +-- scripts/lilypond-book.py | 9 ++++++- 9 files changed, 130 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8c871723e3..6d302b4d3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2006-03-28 Han-Wen Nienhuys + * mf/feta-bolletjes.mf (overdone_heads): add small style (ugly) + note heads, for uniform widths in shape note output. + + * scripts/lilypond-book.py (output): add links to filenames. + * Documentation/topdocs/INSTALL.texi (Top): update versions. * lily/note-collision.cc (get_clash_groups): only consider when diff --git a/flower/std-string.cc b/flower/std-string.cc index 855193ecb0..304ddf33cf 100644 --- a/flower/std-string.cc +++ b/flower/std-string.cc @@ -101,6 +101,7 @@ string_compare (string const &a, string const &b) } #include "std-vector.hh" + vector string_split (string str, char c) { diff --git a/lily/include/pango-font.hh b/lily/include/pango-font.hh index fd8ad69527..dc21ccf684 100644 --- a/lily/include/pango-font.hh +++ b/lily/include/pango-font.hh @@ -27,7 +27,11 @@ class Pango_font : public Font_metric Real scale_; Real output_scale_; SCM physical_font_tab_; - Direction text_direction_; + Direction text_direction_; + + map charcode_maps_; + + Index_to_charcode_map const *get_index_to_charcode_map (string postscript_name, FT_Face face); public: SCM physical_font_tab () const; Pango_font (PangoFT2FontMap *, diff --git a/lily/open-type-font.cc b/lily/open-type-font.cc index 8e50a1a576..1a61c07884 100644 --- a/lily/open-type-font.cc +++ b/lily/open-type-font.cc @@ -68,18 +68,6 @@ load_scheme_table (char const *tag_str, FT_Face face) return tab; } -Index_to_charcode_map -make_index_to_charcode_map (FT_Face face) -{ - Index_to_charcode_map m; - FT_ULong charcode; - FT_UInt gindex; - - for (charcode = FT_Get_First_Char (face, &gindex); gindex != 0; - charcode = FT_Get_Next_Char (face, charcode, &gindex)) - m[gindex] = charcode; - return m; -} Open_type_font::~Open_type_font () { diff --git a/lily/pango-font.cc b/lily/pango-font.cc index 86c4bf61f5..76ccfbc66d 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -75,6 +75,19 @@ Pango_font::derived_mark () const scm_gc_mark (physical_font_tab_); } + +Index_to_charcode_map const * +Pango_font::get_index_to_charcode_map (string key, FT_Face face) +{ + if (charcode_maps_.find (key) == charcode_maps_.end ()) + charcode_maps_[key] = make_index_to_charcode_map (face); + + if (charcode_maps_.find (key) == charcode_maps_.end ()) + return 0; + + return &charcode_maps_[key]; +} + Stencil Pango_font::pango_item_string_stencil (PangoItem const *item, string str) const { @@ -101,10 +114,25 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, string str) const PANGO_ASCENT (ink_rect))); b.scale (scale_); + char const *ps_name_str0 = FT_Get_Postscript_Name (ftface); + FcPattern *fcpat = fcfont->font_pattern; + char *file_name_as_ptr = 0; + FcPatternGetString (fcpat, FC_FILE, 0, (FcChar8 **) & file_name_as_ptr); + string file_name; + if (file_name_as_ptr) + { + /* Normalize file name. */ + file_name = File_name (file_name_as_ptr).to_string (); + } + SCM glyph_exprs = SCM_EOL; SCM *tail = &glyph_exprs; - + + Index_to_charcode_map const *cmap = 0; + if (! (ftface->face_flags & FT_FACE_FLAG_GLYPH_NAMES)) + cmap = ((Pango_font*)this)->get_index_to_charcode_map (file_name, ftface); + bool cid_keyed = false; for (int i = 0; i < pgs->num_glyphs; i++) { @@ -116,6 +144,13 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, string str) const FT_Get_Glyph_Name (ftface, pg, glyph_name, GLYPH_NAME_LEN); SCM char_id; + if (glyph_name[0] == '\0' && cmap) + { + FT_ULong char_code = cmap->find (pg)->second; + + sprintf (glyph_name, "uni%04lX", char_code); + } + if (glyph_name[0] == '\0') { /* @@ -140,18 +175,6 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, string str) const Real size = pango_font_description_get_size (descr) / (Real (PANGO_SCALE)); - FcPattern *fcpat = fcfont->font_pattern; - char *file_name_as_ptr = 0; - FcPatternGetString (fcpat, FC_FILE, 0, (FcChar8 **) & file_name_as_ptr); - - string file_name; - if (file_name_as_ptr) - { - /* Normalize file name. */ - file_name = File_name (file_name_as_ptr).to_string (); - } - - char const *ps_name_str0 = FT_Get_Postscript_Name (ftface); if (!ps_name_str0) warning (_f ("no PostScript font name for font `%s'", file_name)); diff --git a/lily/ttf.cc b/lily/ttf.cc index 82bc78dce2..8d22ccee18 100644 --- a/lily/ttf.cc +++ b/lily/ttf.cc @@ -15,6 +15,22 @@ #include "warn.hh" #include "lily-guile.hh" #include "main.hh" +#include "open-type-font.hh" + + +Index_to_charcode_map +make_index_to_charcode_map (FT_Face face) +{ + Index_to_charcode_map m; + FT_ULong charcode; + FT_UInt gindex; + + FT_Select_Charmap(face, FT_ENCODING_UNICODE); + for (charcode = FT_Get_First_Char (face, &gindex); gindex != 0; + charcode = FT_Get_Next_Char (face, charcode, &gindex)) + m[gindex] = charcode; + return m; +} /* Based on ttfps by Juliusz Chroboczek @@ -132,20 +148,31 @@ print_trailer (void *out, lily_cookie_fprintf (out, "/CharStrings %d dict dup begin\n", mp->numGlyphs); + Index_to_charcode_map ic_map (make_index_to_charcode_map (face)); + + for (int i = 0; i < mp->numGlyphs; i++) + { + glyph_name[0] = 0; + if (face->face_flags & FT_FACE_FLAG_GLYPH_NAMES) + { + FT_Error error = FT_Get_Glyph_Name (face, i, glyph_name, + GLYPH_NAME_LEN); + if (error) + programming_error ("print_trailer(): FT_Get_Glyph_Name() returned error"); + else + glyph_name[0] = 0; + } - if (face->face_flags & FT_FACE_FLAG_GLYPH_NAMES) - for (int i = 0; i < mp->numGlyphs; i++) - { - FT_Error error = FT_Get_Glyph_Name (face, i, glyph_name, - GLYPH_NAME_LEN); - if (error) - programming_error ("print_trailer(): FT_Get_Glyph_Name() returned error"); - else - lily_cookie_fprintf (out, "/%s %d def ", glyph_name, i); + if (!glyph_name[0]) + { + sprintf (glyph_name, "uni%04lX", ic_map[i]); + } + + lily_cookie_fprintf (out, "/%s %d def ", glyph_name, i); - if (! (i % 5)) - lily_cookie_fprintf (out, "\n"); - } + if (! (i % 5)) + lily_cookie_fprintf (out, "\n"); + } lily_cookie_fprintf (out, "end readonly def\n"); lily_cookie_fprintf (out, "FontName currentdict end definefont pop\n"); diff --git a/mf/feta-bolletjes.mf b/mf/feta-bolletjes.mf index 8a1bd2883b..98107ff8a4 100644 --- a/mf/feta-bolletjes.mf +++ b/mf/feta-bolletjes.mf @@ -207,6 +207,8 @@ if test > 0: fi; + + fet_beginchar ("Half notehead", "s1"); draw_outside_ellipse (1.53 - puff_up_factor / 3.0, 34, 0.66, 0.17); undraw_inside_ellipse (3.25, 33, 0.81, 2.5 stafflinethickness#); @@ -235,7 +237,6 @@ fet_beginchar ("Quart notehead", "s2"); draw_staff (-2, 2, 0); fet_endchar; - if test > 0: fet_beginchar ("Quart notehead", "s2"); draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31, @@ -245,6 +246,38 @@ if test > 0: fet_endchar; fi; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%% +%% fonts for "small style" +%% + +fet_beginchar ("Half notehead (quarter size)", "s1small"); + draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31, 0.707, 0.0); + undraw_inside_ellipse (3.25, 33, 0.81, 2.8 stafflinethickness#); + + draw_staff (-2, 2, 0); +fet_endchar; + + +%% copy of normal. +fet_beginchar ("Quart notehead (quarter size)", "s2small"); + % used to have 32. With 31, they are slightly bolder. + draw_outside_ellipse (1.49 - puff_up_factor / 3.0, 31, 0.707, 0); + black_notehead_width# := charwd; + + draw_staff (-2, 2, 0); +fet_endchar; + +%% smaller. +fet_beginchar ("Whole notehead (quarter size)", "s0small"); + draw_outside_ellipse (1.60 - puff_up_factor / 3.0, 0, 0.707, 0); + undraw_inside_ellipse (1.30, 125 - puff_up_factor * 10, + 0.68, 2 stafflinethickness#); + + draw_staff (-2, 2, 0); +fet_endchar; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/mf/feta-test-generic.mf b/mf/feta-test-generic.mf index 44b0168dd2..552731486d 100644 --- a/mf/feta-test-generic.mf +++ b/mf/feta-test-generic.mf @@ -6,8 +6,8 @@ %input feta-eindelijk; %input feta-toevallig; %input feta-puntje; -%input feta-bolletjes; -input feta-arrow; +input feta-bolletjes; +%input feta-arrow; %input feta-schrift; %input feta-schrift; %input feta-banier; diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index efe7e5c784..4fbadf9813 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -603,7 +603,14 @@ output = { @end html ''', - PRINTFILENAME: '''@file{%(filename)s} + PRINTFILENAME: ''' +@html + +@end html +@file{%(filename)s} +@html + +@end html ''', QUOTE: r'''@quotation -- 2.39.2