Nitpick: ly:spanner-bound grob name slur -> spanner.
[lilypond.git] / lily / open-type-font-scheme.cc
blob2d33394fc80be313fdfaf8114abf222e063a721e
1 /*
2 open-type-font.cc -- implement Open_type_font
4 source file of the GNU LilyPond music typesetter
6 (c) 2004--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "modified-font-metric.hh"
10 #include "open-type-font.hh"
12 LY_DEFINE (ly_font_sub_fonts, "ly:font-sub-fonts", 1, 0, 0,
13 (SCM font),
14 "Given the font metric @var{font} of an OpenType font, return the"
15 " names of the subfonts within @var{font}.")
17 LY_ASSERT_SMOB (Font_metric, font, 1);
18 Font_metric *fm = unsmob_metrics (font);
19 return fm->sub_fonts ();
22 LY_DEFINE (ly_otf_font_glyph_info, "ly:otf-font-glyph-info", 2, 0, 0,
23 (SCM font, SCM glyph),
24 "Given the font metric @var{font} of an OpenType font, return the"
25 " information about named glyph @var{glyph} (a string).")
27 Modified_font_metric *fm
28 = dynamic_cast<Modified_font_metric *> (unsmob_metrics (font));
29 Open_type_font *otf = dynamic_cast<Open_type_font *> (fm->original_font ());
31 SCM_ASSERT_TYPE (otf, font, SCM_ARG1, __FUNCTION__, "OTF font-metric");
32 LY_ASSERT_TYPE (scm_is_string, glyph, 2);
34 SCM sym = scm_string_to_symbol (glyph);
35 return scm_hashq_ref (otf->get_char_table (), sym, SCM_EOL);
38 LY_DEFINE (ly_otf_font_table_data, "ly:otf-font-table-data", 2, 0, 0,
39 (SCM font, SCM tag),
40 "Extract a table @var{tag} from @var{font}. Return empty string"
41 " for non-existent @var{tag}.")
43 Modified_font_metric *fm
44 = dynamic_cast<Modified_font_metric *> (unsmob_metrics (font));
46 Open_type_font *otf = fm ? dynamic_cast<Open_type_font *> (fm->original_font ())
47 : dynamic_cast<Open_type_font *> (unsmob_metrics (font));
49 SCM_ASSERT_TYPE (otf, font, SCM_ARG1, __FUNCTION__, "Open type font");
50 LY_ASSERT_TYPE (scm_is_string, tag, 2);
52 char ctag [5] = " ";
54 string tag_string = ly_scm2string (tag);
55 strncpy (ctag, tag_string.c_str (), tag_string.length ());
57 string tab = otf->get_otf_table (string (ctag));
59 return scm_from_locale_stringn ((char const *) tab.data (), tab.length ());
62 LY_DEFINE (ly_otf_font_p, "ly:otf-font?", 1, 0, 0,
63 (SCM font),
64 "Is @var{font} an OpenType font?")
66 Modified_font_metric *fm
67 = dynamic_cast<Modified_font_metric *> (unsmob_metrics (font));
69 Open_type_font *otf = fm ? dynamic_cast<Open_type_font *> (fm->original_font ())
70 : dynamic_cast<Open_type_font *> (unsmob_metrics (font));
72 return scm_from_bool (otf);
75 LY_DEFINE (ly_otf_glyph_list, "ly:otf-glyph-list",
76 1, 0, 0, (SCM font),
77 "Return a list of glyph names for @var{font}.")
79 Modified_font_metric *fm
80 = dynamic_cast<Modified_font_metric *> (unsmob_metrics (font));
82 Open_type_font *otf = fm ? dynamic_cast<Open_type_font *> (fm->original_font ())
83 : dynamic_cast<Open_type_font *> (unsmob_metrics (font));
86 SCM_ASSERT_TYPE (otf, font, SCM_ARG1, __FUNCTION__, "OTF font");
87 return otf->glyph_list ();