From 07c8d2d3826d9dad1cfe1a4924d4b5990386f88c Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Fri, 9 Apr 2004 22:35:54 +0000 Subject: [PATCH] (markup): take encoding from lexer. --- ChangeLog | 8 ++++++-- input/test/title-markup.ly | 8 ++++++-- lily/include/my-lily-lexer.hh | 3 ++- lily/my-lily-lexer.cc | 10 ++++++++-- lily/parser.yy | 24 ++++++++++++------------ 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index d072246ac0..3eac569fac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-04-10 Han-Wen Nienhuys + + * lily/parser.yy (markup): take encoding from lexer. + 2004-04-09 Jan Nieuwenhuizen * lily/kpath.cc (kpathsea_find_tfm): Do not trigger TMF generation. @@ -6,6 +10,8 @@ 2004-04-09 Han-Wen Nienhuys + * lily/kpath.cc (kpathsea_find_tfm): don't make unfound TFMs/AFMs. + * Documentation/user/lilypond.tely (Top): manual for v2.3 (backportme) 2004-04-09 Jan Nieuwenhuizen @@ -20,8 +26,6 @@ * scripts/convert-ly.py: limited old-style markup convert. (Thanks to Erik Sandberg) - * Documentation/user/lilypond.tely (Top): update, - * lily/font-metric.cc (LY_DEFINE): new function, return fontName. * scm/output-ps.scm (define-fonts): remove hack for feta/parmesan. diff --git a/input/test/title-markup.ly b/input/test/title-markup.ly index 8382a9b2c6..6cc1f21b3d 100644 --- a/input/test/title-markup.ly +++ b/input/test/title-markup.ly @@ -1,4 +1,5 @@ \version "2.2.0" + %{ Experimental markup titles are available in direct PostScript output: @@ -11,14 +12,17 @@ PostScript fonts: WIP. * Nonstandardised install directory / how to locate a ps font? * Nonstandardised filenames? + For century schoolbook font: Debian: cp -pv /usr/share/fonts/type1/gsfonts/c*.{afm,pfb} mf/out Red Hat (untested): - cp -pv /usr/share/fonts/afms/adobe/c*.afm mf/out/ - cp -pv /usr/share/fonts/default/ghostscript/c*.pfb mf/out + + cp -pv /usr/share/fonts/afms/adobe/c*.{afm,pfb} mf/out/ + + cp -pv /usr/share/fonts/default/Type1/c*.{pfb,afm} mf/out %} diff --git a/lily/include/my-lily-lexer.hh b/lily/include/my-lily-lexer.hh index e8aa8c10b8..600e3dec3f 100644 --- a/lily/include/my-lily-lexer.hh +++ b/lily/include/my-lily-lexer.hh @@ -28,9 +28,9 @@ void set_lexer (); class My_lily_lexer : public Includable_lexer { Protected_scm scopes_; + Protected_scm encoding_; public: String main_input_name_; - String encoding_; void *lexval; bool main_input_b_; @@ -65,6 +65,7 @@ public: void pop_state (); void LexerError (char const *); void set_encoding (String); + SCM encoding () const; void set_identifier (SCM name_string, SCM); bool is_note_state () const; bool is_chord_state () const; diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index d957e4b3de..242167bf5f 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -95,7 +95,7 @@ static Keyword_ent the_key_tab[] = { My_lily_lexer::My_lily_lexer () { keytable_ = new Keyword_table (the_key_tab); - + encoding_ = SCM_EOL; chordmodifier_tab_ = scm_make_vector (scm_int2num (1), SCM_EOL); pitchname_tab_stack_ = SCM_EOL; @@ -107,6 +107,12 @@ My_lily_lexer::My_lily_lexer () main_input_b_ = false; } +SCM +My_lily_lexer::encoding () const +{ + return encoding_ ; +} + void My_lily_lexer::add_scope (SCM module) { @@ -240,5 +246,5 @@ My_lily_lexer::prepare_for_next_token () void My_lily_lexer::set_encoding (String s) { - encoding_ = s; + encoding_ = ly_symbol2scm (s.to_str0 ()); } diff --git a/lily/parser.yy b/lily/parser.yy index 0a32cc0322..347c3445c0 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -103,18 +103,18 @@ is_regular_identifier (SCM id) } SCM -make_simple_markup (SCM a) +make_simple_markup (SCM encoding, SCM a) { SCM simple = ly_scheme_function ("simple-markup"); - SCM markup = scm_list_2 (simple, a); -#if 0 - if (THIS->lexer_->encoding_ != "") - return scm_list_2 - (scm_cons (ly_scheme_function ("encoding"), - scm_makfrom0str (THIS->lexer_->encoding_.to_str0 ())), - markup); -#endif -return markup; + SCM markup = + if (gh_symbol_p (encoding)) + { + return scm_list_3 (ly_scheme_function ("encoded-simple-markup"), + encoding, a); + } else + return scm_list_2 (simple, a); + + return markup; } @@ -1756,7 +1756,7 @@ gen_text_def: } | string { Music *t = MY_MAKE_MUSIC ("TextScriptEvent"); - t->set_property ("text", make_simple_markup ($1)); + t->set_property ("text", make_simple_markup (THIS->lexer_->encoding (), $1)); t->set_spot (THIS->here_input ()); $$ = t; @@ -2286,7 +2286,7 @@ This should be done more dynamically if possible. */ markup: STRING { - $$ = make_simple_markup ($1); + $$ = make_simple_markup (THIS->lexer_->encoding (), $1); } | MARKUP_HEAD_EMPTY { $$ = scm_list_1 ($1); -- 2.39.5