From: Han-Wen Nienhuys Date: Tue, 6 Apr 2004 21:55:58 +0000 (+0000) Subject: * scm/output-tex.scm: remove fontify; text and char take a font X-Git-Tag: release/2.3.0~80 X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=commitdiff_plain;h=22ec58a860e744f90ab8900ab00576e5d1a78d16;p=lilypond.git * scm/output-tex.scm: remove fontify; text and char take a font argument. * lily/tfm.cc (name_to_index): new function, use encoding_table_. * lily/scaled-font-metric.cc (text_dimension): init coding_{permutation,table}_ too (LY_DEFINE): ly:font-encoding, new function return --- diff --git a/ChangeLog b/ChangeLog index 294b2d3c26..45e66a739e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2004-04-06 Han-Wen Nienhuys + * scm/output-tex.scm: remove fontify; text and char take a font + argument. + + * lily/tfm.cc (name_to_index): new function, use encoding_table_. + + * lily/scaled-font-metric.cc (text_dimension): init + coding_{permutation,table}_ too + (LY_DEFINE): ly:font-encoding, new function return + + * lily/paper-def.cc (find_scaled_font): take input coding from + inputcoding paper var. + * lily/performance.cc (output): remap modulo 16. * lily/text-item.cc (interpret_markup): whoops, variable diff --git a/lily/scaled-font-metric.cc b/lily/scaled-font-metric.cc index 4562a5f510..3e6f2caa6f 100644 --- a/lily/scaled-font-metric.cc +++ b/lily/scaled-font-metric.cc @@ -185,6 +185,10 @@ Modified_font_metric::text_dimension (String text) w += b[X_AXIS].length (); ydims.unite (b[Y_AXIS]); } + if (ydims.is_empty ()) + ydims = Interval (0, 0); + + b = Box(Interval(0,w), ydims); } else { @@ -217,21 +221,28 @@ Modified_font_metric::text_dimension (String text) Box char_box; - if (!gh_symbol_p (sym)) + if (!gh_symbol_p (sym) && !gh_string_p (sym)) continue; - - int idx = orig_->name_to_index (SCM_SYMBOL_CHARS(sym)); + char const * chars = gh_symbol_p (sym) + ? SCM_SYMBOL_CHARS(sym) : SCM_STRING_CHARS(sym); + + + int idx = orig_->name_to_index (chars); if (idx >= 0) { char_box = orig_->get_indexed_char (idx); } + if (!char_box[X_AXIS].is_empty ()) w += char_box[X_AXIS][RIGHT]; // length ? ydims.unite (char_box[Y_AXIS]); } + if (ydims.is_empty ()) + ydims = Interval (0, 0); + b = Box (Interval (0, w), ydims); } @@ -246,9 +257,10 @@ LY_DEFINE (ly_font_enccoding, "ly:font-encoding", 1 , 0, 0, "Given the Modified_font_metric @var{font}, return a " "list containing (input-coding, output-coding, permutation).") { - Modified_font_metric * fm = dynamic_cast ( unsmob_metrics (font)); - SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "Modified_font_metric"); + Modified_font_metric * fm + = dynamic_cast (unsmob_metrics (font)); + SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "Modified_font_metric"); return scm_list_3 (fm->coding_vector_, fm->coding_table_, fm->coding_permutation_); diff --git a/lily/stencil.cc b/lily/stencil.cc index fade2d75ea..a01e13a9aa 100644 --- a/lily/stencil.cc +++ b/lily/stencil.cc @@ -115,7 +115,9 @@ Stencil Stencil::moved_to_edge (Axis a, Direction d, Stencil const &s, Real padding, Real minimum) const { - Real my_extent= is_empty () ? 0.0 : dim_[a][d]; + Interval my_extent= dim_[a]; + + Interval i (s.extent (a)); Real his_extent; if (i.is_empty ()) @@ -126,7 +128,8 @@ Stencil::moved_to_edge (Axis a, Direction d, Stencil const &s, Real padding, else his_extent = i[-d]; - Real offset = (my_extent - his_extent) + d * padding; + Real offset = (my_extent. is_empty () ? 0.0 : my_extent[d] - his_extent) + + d * padding; Stencil toadd (s); toadd.translate_axis (offset,a); @@ -142,7 +145,7 @@ Stencil::moved_to_edge (Axis a, Direction d, Stencil const &s, Real padding, /* See scheme Function. */ void Stencil::add_at_edge (Axis a, Direction d, Stencil const &s, Real padding, - Real minimum) + Real minimum) { add_stencil (moved_to_edge (a,d,s,padding, minimum)); } diff --git a/lily/tfm.cc b/lily/tfm.cc index 276b62236a..2e0bf25167 100644 --- a/lily/tfm.cc +++ b/lily/tfm.cc @@ -125,12 +125,12 @@ Tex_font_metric::coding_scheme () const int Tex_font_metric::name_to_index (String s) const { - SCM sym = ly_symbol2scm (s.to_str0 ()); + SCM sym = scm_makfrom0str (s.to_str0 ()); SCM idx = scm_hash_ref (encoding_table_, sym, SCM_BOOL_F); - if (scm_integer_p (idx) == SCM_BOOL_T) + if (gh_char_p (idx)) { - return gh_scm2int (idx); + return (unsigned char) gh_scm2char (idx); } else return -1; diff --git a/scm/output-ps.scm b/scm/output-ps.scm index f784997a40..628700cfab 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -176,11 +176,6 @@ (inexact->exact (round (* 1000 (ly:font-magnification font))))))) (define (define-fonts paper font-list) - - (define (fontname->designsize fontname) - (let ((i (string-index fontname char-numeric?))) - (string->number (substring fontname i)))) - (define (define-font command fontname scaling) (string-append "/" command " { /" fontname " findfont " diff --git a/scm/output-tex.scm b/scm/output-tex.scm index 0a81c82ea5..a65863f383 100644 --- a/scm/output-tex.scm +++ b/scm/output-tex.scm @@ -313,7 +313,6 @@ (define (text font s) (let* ((perm (caddr (ly:font-encoding font)))) - (display (ly:font-encoding font)) (string-append "\\hbox{\\" (font-command font) "{}" (output-tex-string (if (vector? perm)