X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lily%2Fvirtual-font-metric.cc;h=d63d8b74a00ec9e7540497ac60433bfe9741d065;hb=98ca84585c45f75503adff82fc0a8cec2a105769;hp=ba4580e92992bb9046d667c4eb3ad7919a75c363;hpb=304b5f3aa7eee7b0ff8d4ba7526a1410735f6e74;p=lilypond.git diff --git a/lily/virtual-font-metric.cc b/lily/virtual-font-metric.cc index ba4580e929..d63d8b74a0 100644 --- a/lily/virtual-font-metric.cc +++ b/lily/virtual-font-metric.cc @@ -11,25 +11,44 @@ source file of the GNU LilyPond music typesetter #include "virtual-font-metric.hh" #include "all-font-metrics.hh" #include "stencil.hh" -#include "paper-def.hh" +#include "output-def.hh" /* passing DEF is ughish. Should move into paperdef? */ -Virtual_font_metric::Virtual_font_metric (SCM name_list, - Real mag,Paper_def*def) +Virtual_font_metric::Virtual_font_metric (SCM font_list) { font_list_ = SCM_EOL; SCM *tail = &font_list_; - for (SCM s = name_list; gh_pair_p (s); s = gh_cdr (s)) + + SCM mag = SCM_EOL; + SCM name_list = SCM_EOL; + SCM *name_tail = &name_list; + + for (SCM s = font_list; ly_c_pair_p (s); s = ly_cdr (s)) { - SCM nm = gh_car (s); + if (Font_metric *fm = unsmob_metrics (ly_car (s))) + { + *tail = scm_cons (ly_car (s),SCM_EOL); + tail = SCM_CDRLOC (*tail); - Font_metric *fm = def->find_font (nm, mag); - *tail = scm_cons (fm->self_scm (),SCM_EOL); - tail = SCM_CDRLOC (*tail); + if (!ly_c_number_p (mag)) + /* Ugh. */ + mag = ly_cdr (fm->description_); + + *name_tail = scm_cons (ly_car (fm->description_), SCM_EOL); + name_tail = SCM_CDRLOC (*name_tail); + } } + + description_ = scm_cons (name_list, mag); +} + +Real +Virtual_font_metric::design_size () const +{ + return unsmob_metrics (ly_car (font_list_))-> design_size (); } void @@ -42,11 +61,8 @@ int Virtual_font_metric::count () const { int k = 0; - for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s)) - { - k+= unsmob_metrics (gh_car (s))->count (); - } - + for (SCM s = font_list_; ly_c_pair_p (s); s = ly_cdr (s)) + k += unsmob_metrics (ly_car (s))->count (); return k; } @@ -54,15 +70,13 @@ Stencil Virtual_font_metric::find_by_name (String glyph) const { Stencil m; - for (SCM s = font_list_; m.is_empty () && gh_pair_p (s); s = gh_cdr (s)) + for (SCM s = font_list_; m.is_empty () && ly_c_pair_p (s); s = ly_cdr (s)) { - m = unsmob_metrics (gh_car (s))->find_by_name (glyph); + m = unsmob_metrics (ly_car (s))->find_by_name (glyph); } return m; } - - Box Virtual_font_metric::get_ascii_char (int) const @@ -78,22 +92,17 @@ Virtual_font_metric::get_ascii_char_stencil (int ) const return Stencil (); } - Offset Virtual_font_metric::get_indexed_wxwy (int code) const { int total = 0; - for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s)) + for (SCM s = font_list_; ly_c_pair_p (s); s = ly_cdr (s)) { - Font_metric* fm = unsmob_metrics (gh_car (s)); + Font_metric *fm = unsmob_metrics (ly_car (s)); if (code < total + fm->count ()) - { - return fm->get_indexed_wxwy (code - total); - } + return fm->get_indexed_wxwy (code - total); total += fm->count (); } - - return Offset (0,0); } @@ -101,39 +110,32 @@ Box Virtual_font_metric::get_indexed_char (int code) const { int total = 0; - for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s)) + for (SCM s = font_list_; ly_c_pair_p (s); s = ly_cdr (s)) { - Font_metric* fm = unsmob_metrics (gh_car (s)); + Font_metric *fm = unsmob_metrics (ly_car (s)); if (code < total + fm->count ()) - { - return fm->get_indexed_char (code - total); - } + return fm->get_indexed_char (code - total); total += fm->count (); } - - return Box (); } - int Virtual_font_metric::name_to_index (String glyph) const { Stencil m; int total = 0; - for (SCM s = font_list_; m.is_empty () && gh_pair_p (s); s = gh_cdr (s)) + for (SCM s = font_list_; m.is_empty () && ly_c_pair_p (s); s = ly_cdr (s)) { - Font_metric *m =unsmob_metrics (gh_car (s)); + Font_metric *m =unsmob_metrics (ly_car (s)); int k = m->name_to_index (glyph); if (k >= 0) return total + k; total += m->count (); } - return -1; } - Stencil Virtual_font_metric::get_indexed_char_stencil (int code) const @@ -141,17 +143,39 @@ Virtual_font_metric::get_indexed_char_stencil (int code) const Stencil m ; int total = 0; - for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s)) + for (SCM s = font_list_; ly_c_pair_p (s); s = ly_cdr (s)) { - Font_metric* fm = unsmob_metrics (gh_car (s)); + Font_metric *fm = unsmob_metrics (ly_car (s)); if (code < total + fm->count ()) { - m = fm->get_indexed_char_stencil (code - total); // ugh. + /* Ugh. */ + m = fm->get_indexed_char_stencil (code - total); break; } total += fm->count (); } - return m; } - + + +SCM +Virtual_font_metric::get_font_list () const +{ + return font_list_; +} + +LY_DEFINE (ly_make_virtual_font, "ly:make-virtual-font", 0, 0, 1, + (SCM args), + "Make a virtual font metric from @var{args}, " + "a list of font objects.") +{ + Virtual_font_metric *fm = new Virtual_font_metric (args); + return scm_gc_unprotect_object (fm->self_scm ()); +} + +String +Virtual_font_metric::coding_scheme () const +{ + Font_metric *fm = unsmob_metrics (ly_car (font_list_)); + return fm->coding_scheme (); +}