From c5d52711febce78e3beff59d635cc7669aa1da2f Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 13 Mar 2005 20:51:59 +0000 Subject: [PATCH] *** empty log message *** --- ChangeLog | 13 ++++ input/regression/lyric-hyphen-retain.ly | 9 ++- lily/accidental.cc | 4 +- lily/lyric-hyphen.cc | 62 +++++++++++------- lily/pango-font.cc | 86 +------------------------ mf/feta-params.mf | 2 +- scm/define-grobs.scm | 8 ++- scm/framework-svg.scm | 1 + scm/output-svg.scm | 46 ++++++++++--- scm/paper.scm | 2 +- 10 files changed, 107 insertions(+), 126 deletions(-) diff --git a/ChangeLog b/ChangeLog index c397bed89d..a636abbd2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2005-03-12 Han-Wen Nienhuys + + * scm/define-grobs.scm (all-grob-descriptions): switch off + Hyphen_spanner::set_spacing_rods + + * lily/lyric-hyphen.cc (print): add padding between syllable and + hyphen. + (print): shorten hyphen in tight situations (determine using + minimum-length) + + * scm/paper.scm (layout-set-staff-size): increase blotdiameter to + 0.4pt. + 2005-03-13 Jan Nieuwenhuizen * ly/titling-init.ly (bookTitleMarkup): Refinements. diff --git a/input/regression/lyric-hyphen-retain.ly b/input/regression/lyric-hyphen-retain.ly index f5142b896e..cd61a5ceb1 100644 --- a/input/regression/lyric-hyphen-retain.ly +++ b/input/regression/lyric-hyphen-retain.ly @@ -8,10 +8,13 @@ end of the line. Normally, lyrics are not typeset so tightly, but by tuning down @code{padding} of in @code{SeparationItem}, syllables are put closer together, and as a result hyphens may disappear. -In some languages (e.g. German and Hungarian), hyphens should not +In some languages (e.g. German and Hungarian), hyphens should not disappear, since spelling depends on hyphenation. For that purpose, -hyphens can be forced to remain by overriding @code{minimum-length} of -the @code{LyricHyphen} grob. +hyphens can be forced to remain setting @code{spacing-procedure} to +@code{Hyphen_spanner::set_spacing_rods} of the @code{LyricHyphen} +grob. The @code{minimum-length} property may be used to tune the +amount + " } diff --git a/lily/accidental.cc b/lily/accidental.cc index 0658b28bcf..e2f21a105a 100644 --- a/lily/accidental.cc +++ b/lily/accidental.cc @@ -99,8 +99,8 @@ Accidental_interface::accurate_boxes (Grob *a, Grob **common) rstem[Y_AXIS] *= 1.1; belly[Y_AXIS] *= 0.75; - lstem[X_AXIS][RIGHT] *= .5; - rstem[X_AXIS][LEFT] = lstem[X_AXIS][RIGHT]; + lstem[X_AXIS][RIGHT] *= .33; + rstem[X_AXIS][LEFT] = rstem[X_AXIS].linear_combination (1.0/3.0); lstem[Y_AXIS][DOWN] = belly[Y_AXIS][DOWN]; rstem[Y_AXIS][UP] = belly[Y_AXIS][UP]; boxes.push (belly); diff --git a/lily/lyric-hyphen.cc b/lily/lyric-hyphen.cc index 8dd88dc0c1..10e9c64580 100644 --- a/lily/lyric-hyphen.cc +++ b/lily/lyric-hyphen.cc @@ -16,7 +16,7 @@ #include "moment.hh" MAKE_SCHEME_CALLBACK (Hyphen_spanner, print, 1) - SCM +SCM Hyphen_spanner::print (SCM smob) { Spanner *me = unsmob_spanner (smob); @@ -31,10 +31,11 @@ Hyphen_spanner::print (SCM smob) Interval span_points; Direction d = LEFT; + Drul_array broken; do { Interval iv = bounds[d]->extent (common, X_AXIS); - + span_points[d] = iv.is_empty () ? bounds[d]->relative_coordinate (common, X_AXIS) : iv[-d]; @@ -47,18 +48,28 @@ Hyphen_spanner::print (SCM smob) // interval? - Real dp = robust_scm2double (me->get_property ("dash-period"), 1.0); - Real dl = robust_scm2double (me->get_property ("length"), .5); - - if (dp < dl) - dp = 1.5 * dl; + Real dash_period = robust_scm2double (me->get_property ("dash-period"), 1.0); + Real dash_length = robust_scm2double (me->get_property ("length"), .5); + Real padding = robust_scm2double (me->get_property ("padding"), 0.1); + + if (dash_period < dash_length) + dash_period = 1.5 * dash_length; + Real l = span_points.length (); - int n = int (ceil (l / dp - 0.5)); + + int n = int (ceil (l / dash_period - 0.5)); if (n <= 0) n = 1; - Real space_left = l - dl - (n - 1)* dp; + if (l < dash_length + 2*padding + && !bounds[RIGHT]->break_status_dir ()) + { + Real minimum_length = robust_scm2double (me->get_property ("minimum-length"), .3); + dash_length = (l - 2*padding) >? minimum_length; + } + + Real space_left = l - dash_length - (n - 1) * dash_period; /* If there is not enough space, the hyphen should disappear, but not @@ -70,14 +81,14 @@ Hyphen_spanner::print (SCM smob) space_left = space_left >? 0.0; - Box b (Interval (0, dl), Interval (h, h + th)); + Box b (Interval (0, dash_length), Interval (h, h + th)); Stencil dash_mol (Lookup::round_filled_box (b, 0.8 * lt)); Stencil total; for (int i = 0; i < n; i++) { Stencil m (dash_mol); - m.translate_axis (span_points[LEFT] + i * dp + space_left / 2, X_AXIS); + m.translate_axis (span_points[LEFT] + i * dash_period + space_left / 2, X_AXIS); total.add_stencil (m); } @@ -96,23 +107,28 @@ Hyphen_spanner::set_spacing_rods (SCM smob) r.distance_ = robust_scm2double (me->get_property ("minimum-length"), 0); - Direction d = LEFT; - do + if (r.distance_ > 0.0) { - r.item_drul_[d] = sp->get_bound (d); - if (r.item_drul_[d]) - r.distance_ += r.item_drul_[d]->extent (r.item_drul_[d], X_AXIS)[-d]; + Real padding = robust_scm2double (me->get_property ("padding"), 0.1); + r.distance_ += 2*padding; + Direction d = LEFT; + do + { + r.item_drul_[d] = sp->get_bound (d); + if (r.item_drul_[d]) + r.distance_ += r.item_drul_[d]->extent (r.item_drul_[d], X_AXIS)[-d]; + } + while (flip (&d) != LEFT); + + if (r.item_drul_[LEFT] + && r.item_drul_[RIGHT]) + r.add_to_cols (); } - while (flip (&d) != LEFT); - - if (r.item_drul_[LEFT] - && r.item_drul_[RIGHT]) - r.add_to_cols (); - + return SCM_UNSPECIFIED; } ADD_INTERFACE (Hyphen_spanner, "lyric-hyphen-interface", "A centred hyphen is a simple line between lyrics used to divide syllables", - "thickness height dash-period minimum-length length"); + "padding thickness height dash-period minimum-length length"); diff --git a/lily/pango-font.cc b/lily/pango-font.cc index d5d01499d5..6eba7c8780 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -237,6 +237,9 @@ Pango_font::text_stencil (String str) const if (!dest.extent_box ()[X_AXIS].is_empty ()) { Stencil frame = Lookup::frame (dest.extent_box (), 0.1, 0.1); + Box empty; + empty.set_empty(); + Stencil dimless_frame (empty, frame.expr()); dest.add_stencil (frame); } #endif @@ -251,86 +254,3 @@ Pango_font::font_file_name () const } #endif - -#if 0 -void test_pango () -{ - int dpi = 1200; - - char *font_family = "Emmentaler"; - PangoContext *pango_context - = pango_ft2_get_context (dpi, dpi); - PangoFontDescription *font_description; - font_description = pango_font_description_new (); - pango_font_description_set_family (font_description, g_strdup (font_family)); - pango_font_description_set_style (font_description, (PangoStyle) 20); - pango_context_set_font_description (pango_context, font_description); - - PangoAttrList *attr_list = pango_attr_list_new (); - char *str = "sfz"; - GList *items = pango_itemize (pango_context, str, 0, strlen (str), - attr_list, NULL); - - GList *ptr = items; - while (ptr) - { - PangoItem *item = (PangoItem *)ptr->data; - printf ("off %d len %d num %d\n", item->offset, item->length, item->num_chars); - - PangoAnalysis paobj = item->analysis; - PangoAnalysis *pa = &paobj; - - PangoFontDescription *descr = pango_font_describe (pa->font); - // assert (font_description == descr); - printf ("font descr string '%s' fname '%s'", - pango_font_description_to_string (descr), - pango_font_description_to_filename (descr)); - - printf ("type name %s\n", g_type_name (G_TYPE_FROM_INSTANCE (pa->font))); - PangoFcFont *fcfont = G_TYPE_CHECK_INSTANCE_CAST (pa->font, - PANGO_TYPE_FC_FONT, - PangoFcFont); - - FcPattern *fcpat = fcfont->font_pattern; - FcPatternPrint (fcpat); - char *retval ="bla"; - - FcPatternGetString (fcpat, FC_FILE, 0, (FcChar8 **) &retval); - printf ("retval %s\n", retval); - - FT_Face ftface = pango_fc_font_lock_face (fcfont); - - printf ("shape %ux %s lang %ux font %ux languagae %ux\nft face %ux\n", pa->shape_engine, - G_OBJECT_TYPE_NAME (pa->shape_engine), - pa->lang_engine, pa->font, pa->language, ftface); - - PangoGlyphString *pgs = pango_glyph_string_new (); - pango_shape (str, strlen (str), pa, pgs); - - int i; - for (i = 0; i < pgs->num_glyphs; i++) - { - PangoGlyphInfo *pgi = pgs->glyphs + i; - - PangoGlyph pg = pgi->glyph; - PangoGlyphGeometry ggeo = pgi->geometry; - - printf ("c %d w %d x %d y %d\n", pg, ggeo.width, ggeo.x_offset, - ggeo.y_offset); - - char str[1024]; - FT_Get_Glyph_Name (ftface, pg, str, 1024); - printf ("glyph %s\n", str); - } - printf ("\nPS name %s\n", FT_Get_Postscript_Name (ftface)); - - PangoRectangle r1; - PangoRectangle r2; - - pango_glyph_string_extents (pgs, pa->font, &r1, &r2); - - ptr = ptr->next; - printf ("\nnext item\n"); - } -} -#endif diff --git a/mf/feta-params.mf b/mf/feta-params.mf index 1323b7f41e..64cc51b079 100644 --- a/mf/feta-params.mf +++ b/mf/feta-params.mf @@ -73,7 +73,7 @@ fi; % I don't think we do this anywhere -- jcn % -blot_diameter# = .35 pt#; +blot_diameter# = .40 pt#; if (blot_diameter# * hppp) < 1: blot_diameter# := 1 / hppp; fi diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 1bbd3b5aa7..e715554fb7 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -428,7 +428,7 @@ (time-signature . (extra-space . 0.0)) (staff-bar . (extra-space . 0.0)) (breathing-sign . (minimum-space . 0.0)) - (clef . (extra-space . 0.85)) + (clef . (extra-space . 0.7)) (first-note . (fixed-space . 1.0)) (right-edge . (extra-space . 0.0)) (key-signature . (extra-space . 0.0)) @@ -574,7 +574,7 @@ (Y-extent-callback . #f) (minimum-length-fraction . 0.25) (length-fraction . 0.25) -; (spacing-procedure . ,Ledger_line_spanner::set_spacing_rods) + (spacing-procedure . ,Ledger_line_spanner::set_spacing_rods) (print-function . ,Ledger_line_spanner::print) (layer . 0) (meta . ((interfaces . (spanner-interface ledger-line-interface)))) @@ -601,7 +601,9 @@ (height . 0.42) (dash-period . 10.0) (length . 0.66) - (spacing-procedure . ,Hyphen_spanner::set_spacing_rods) + (minimum-length . 0.3) + (padding . 0.07) +; (spacing-procedure . ,Hyphen_spanner::set_spacing_rods) (print-function . ,Hyphen_spanner::print) (Y-extent . (0 . 0)) (meta . ((interfaces . (lyric-interface lyric-hyphen-interface diff --git a/scm/framework-svg.scm b/scm/framework-svg.scm index c514619daa..f159a5059d 100644 --- a/scm/framework-svg.scm +++ b/scm/framework-svg.scm @@ -38,6 +38,7 @@ `(begin (set! lily-unit-length ,unit-length) "")) (dump (eo 'svg '(xmlns . "http://www.w3.org/2000/svg") + '(xmlns:xlink . "http://www.w3.org/1999/xlink") '(version . "1.2") ;; Argggghhhh: SVG takes the px <-> mm mapping from the windowing system diff --git a/scm/output-svg.scm b/scm/output-svg.scm index 3da3cda684..56665a6a79 100644 --- a/scm/output-svg.scm +++ b/scm/output-svg.scm @@ -50,12 +50,15 @@ attributes-alist))) (define-public (eo entity . attributes-alist) + "o = open" (format #f "<~S~a>\n" entity (attributes attributes-alist))) (define-public (eoc entity . attributes-alist) + " oc = open/close" (format #f "<~S~a/>\n" entity (attributes attributes-alist))) (define-public (ec entity) + "c = close" (format #f "\n" entity)) (define-public (entity entity string . attributes-alist) @@ -105,8 +108,7 @@ (match-2 (regexp-exec pango-description-regexp-nocomma str)) (match (if match-1 match-1 - match-2)) - ) + match-2))) (if (regexp-match? match) (begin @@ -152,11 +154,35 @@ ;;; catch-all for missing stuff ;;; comment this out to see find out what functions you miss :-) -(define (dummy . foo) "") -(map (lambda (x) (module-define! this-module x dummy)) - (append - (ly:all-stencil-expressions) - (ly:all-output-backend-commands))) + +(if #f + (begin + (define (dummy . foo) "") + (map (lambda (x) (module-define! this-module x dummy)) + (append + (ly:all-stencil-expressions) + (ly:all-output-backend-commands))) + )) + +(define (url-link url x y) + (string-append + (eo 'a `(xlink:href . ,url)) + (eoc 'rect + `(x . ,(car x)) + `(y . ,(car y)) + `(width . ,(- (cdr x) (car x))) + `(height . ,(- (cdr y) (car y))) + '(fill . "none") + '(stroke . "none") + '(stroke-width . "0.0")) + (ec 'a))) + +(define (grob-cause offset grob) + "") + +(define (no-origin) + "") + (define (rect-beam width slope thick blot-diameter) (let* ((x width) @@ -177,7 +203,7 @@ `(height . ,(+ thick (* (abs z) (/ thick 2)))) `(rx . ,(/ blot-diameter 2)) `(transform . ,(format #f "matrix (1, ~f, 0, 1, 0, 0)" z) - )))) + )))) (define (beam width slope thick blot-diameter) (let* ((b blot-diameter) @@ -215,7 +241,7 @@ 0 (- t) (- w) h 0 t)) - ))) + ))) (define (bezier-sandwich lst thick) (let* ((first (list-tail lst 4)) @@ -229,7 +255,7 @@ '(fill . "black") `(d . ,(string-append (svg-bezier first #f) (svg-bezier second first-c0))) - ))) + ))) (define (char font i) (dispatch diff --git a/scm/paper.scm b/scm/paper.scm index 04ab27045b..569ebcd743 100644 --- a/scm/paper.scm +++ b/scm/paper.scm @@ -47,7 +47,7 @@ ;; !! synchronize with feta-params.mf (module-define! m 'linethickness lt) (module-define! m 'ledgerlinethickness (+ (* 0.5 pt) (/ ss 10))) - (module-define! m 'blotdiameter (* 0.35 pt)) + (module-define! m 'blotdiameter (* 0.4 pt)) (module-define! m 'interscoreline (* 4 mm)))) (define-safe-public (set-global-staff-size sz) -- 2.39.2