source file of the GNU LilyPond music typesetter
- (c) 2003--2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ (c) 2003--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
*/
#include <math.h>
#include "main.hh"
-bool
-wild_compare (SCM field_val, SCM val)
-{
- return (val == SCM_BOOL_F
- || field_val == ly_symbol2scm ("*")
- || field_val == val);
-}
-
Font_metric *
get_font_by_design_size (Output_def *layout, Real requested,
SCM font_vector)
{
- int n = SCM_VECTOR_LENGTH (font_vector);
+ int n = scm_c_vector_length (font_vector);
Real size = 1e6;
Real last_size = -1e6;
int i = 0;
- String pango_description_string;
+ SCM pango_description_string = SCM_EOL;
for (; i < n; i++)
{
- SCM entry = SCM_VECTOR_REF (font_vector, i);
+ SCM entry = scm_c_vector_ref (font_vector, i);
if (scm_promise_p (entry) == SCM_BOOL_T)
{
{
size = scm_to_double (scm_car (entry));
pango_description_string
- = ly_scm2string (scm_cdr (entry));
+ = scm_cdr (entry);
}
#endif
}
Font_metric *fm = 0;
- if (pango_description_string != "")
+ if (scm_is_string (pango_description_string))
{
#if HAVE_PANGO_FT2
- PangoFontDescription *description
- = pango_font_description_from_string (pango_description_string.to_str0 ());
- fm = all_fonts_global->find_pango_font (description);
+ return find_pango_font (layout,
+ pango_description_string,
+ requested / size);
#else
error ("Trying to retrieve pango font without HAVE_PANGO_FT2.");
#endif
}
else
{
- fm = unsmob_metrics (scm_force (SCM_VECTOR_REF (font_vector, i)));
+ fm = unsmob_metrics (scm_force (scm_c_vector_ref (font_vector, i)));
}
return find_scaled_font (layout, fm, requested / size);
else
name = scm_cdr (name);
+#if HAVE_PANGO_FT2
if (scm_is_string (name)
&& is_pango_format_global)
{
- SCM mag = ly_chain_assoc (ly_symbol2scm ("font-magnification"), chain);
- Real rmag = (scm_is_pair (mag)
- ? robust_scm2double (scm_cdr (mag), 1.0)
- : 1);
- Font_metric *fm = all_fonts_global->find_font (ly_scm2string (name));
-
- return find_scaled_font (layout, fm, rmag);
- }
- else if (scm_instance_p (name))
- {
- SCM base_size = scm_slot_ref (name, ly_symbol2scm ("default-size"));
- SCM vec = scm_slot_ref (name, ly_symbol2scm ("size-vector"));
-
- SCM font_size = ly_chain_assoc (ly_symbol2scm ("font-size"), chain);
- Real req = 0;
- if (scm_is_pair (font_size))
- req = scm_to_double (scm_cdr (font_size));
-
- return get_font_by_mag_step (layout, req, vec,
- scm_to_double (base_size));
+ return select_pango_font (layout, chain);
}
+ else
+#endif
+ if (scm_is_string (name))
+ {
+ SCM mag = ly_chain_assoc (ly_symbol2scm ("font-magnification"), chain);
+ Real rmag = (scm_is_pair (mag)
+ ? robust_scm2double (scm_cdr (mag), 1.0)
+ : 1);
+ Font_metric *fm = all_fonts_global->find_font (ly_scm2string (name));
+
+ return find_scaled_font (layout, fm, rmag);
+ }
+ else if (scm_instance_p (name))
+ {
+ SCM base_size = scm_slot_ref (name, ly_symbol2scm ("default-size"));
+ SCM vec = scm_slot_ref (name, ly_symbol2scm ("size-vector"));
+
+ SCM font_size = ly_chain_assoc (ly_symbol2scm ("font-size"), chain);
+ Real req = 0;
+ if (scm_is_pair (font_size))
+ req = scm_to_double (scm_cdr (font_size));
+
+ return get_font_by_mag_step (layout, req, vec,
+ scm_to_double (base_size));
+ }
assert (0);
return 0;