OLD | NEW |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl> | 4 Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 "Note that this command can only be used to access glyphs from" | 54 "Note that this command can only be used to access glyphs from" |
55 " fonts loaded with @code{ly:system-font-load}; currently, this" | 55 " fonts loaded with @code{ly:system-font-load}; currently, this" |
56 " means either the Emmentaler or Emmentaler-Brace fonts, correspondin
g" | 56 " means either the Emmentaler or Emmentaler-Brace fonts, correspondin
g" |
57 " to the font encodings @code{fetaMusic} and @code{fetaBraces}," | 57 " to the font encodings @code{fetaMusic} and @code{fetaBraces}," |
58 " respectively.") | 58 " respectively.") |
59 { | 59 { |
60 Font_metric *fm = unsmob<Font_metric> (font); | 60 Font_metric *fm = unsmob<Font_metric> (font); |
61 LY_ASSERT_SMOB (Font_metric, font, 1); | 61 LY_ASSERT_SMOB (Font_metric, font, 1); |
62 LY_ASSERT_TYPE (scm_is_string, name, 2); | 62 LY_ASSERT_TYPE (scm_is_string, name, 2); |
63 | 63 |
64 return scm_from_int (fm->name_to_index (ly_scm2string (name))); | 64 size_t glyph_index = fm->name_to_index (ly_scm2string (name)); |
| 65 if (glyph_index != GLYPH_INDEX_INVALID) |
| 66 return scm_from_size_t (glyph_index); |
| 67 else |
| 68 return scm_from_int (-1); |
65 } | 69 } |
66 | 70 |
67 LY_DEFINE (ly_font_index_to_charcode, "ly:font-index-to-charcode", | 71 LY_DEFINE (ly_font_index_to_charcode, "ly:font-index-to-charcode", |
68 2, 0, 0, | 72 2, 0, 0, |
69 (SCM font, SCM index), | 73 (SCM font, SCM index), |
70 "Return the character code for @var{index} in @var{font}.\n" | 74 "Return the character code for @var{index} in @var{font}.\n" |
71 "\n" | 75 "\n" |
72 "Note that this command can only be used to access glyphs from" | 76 "Note that this command can only be used to access glyphs from" |
73 " fonts loaded with @code{ly:system-font-load}; currently, this" | 77 " fonts loaded with @code{ly:system-font-load}; currently, this" |
74 " means either the Emmentaler or Emmentaler-Brace fonts, correspondin
g" | 78 " means either the Emmentaler or Emmentaler-Brace fonts, correspondin
g" |
75 " to the font encodings @code{fetaMusic} and @code{fetaBraces}," | 79 " to the font encodings @code{fetaMusic} and @code{fetaBraces}," |
76 " respectively.") | 80 " respectively.") |
77 { | 81 { |
78 Font_metric *fm = unsmob<Font_metric> (font); | 82 Font_metric *fm = unsmob<Font_metric> (font); |
79 LY_ASSERT_SMOB (Font_metric, font, 1); | 83 LY_ASSERT_SMOB (Font_metric, font, 1); |
80 LY_ASSERT_TYPE (scm_is_integer, index, 2); | 84 LY_ASSERT_TYPE (scm_is_integer, index, 2); |
81 | 85 |
82 return scm_from_unsigned_integer (fm->index_to_charcode (scm_to_int (index))); | 86 int i = scm_to_int (index); |
| 87 size_t glyph_index ((i >= 0) ? i : GLYPH_INDEX_INVALID); |
| 88 size_t charcode = fm->index_to_charcode (glyph_index); |
| 89 return scm_from_size_t (charcode); |
83 } | 90 } |
84 | 91 |
85 LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode", | 92 LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode", |
86 2, 0, 0, | 93 2, 0, 0, |
87 (SCM font, SCM name), | 94 (SCM font, SCM name), |
88 "Return the character code for glyph @var{name} in @var{font}.\n" | 95 "Return the character code for glyph @var{name} in @var{font}.\n" |
89 "\n" | 96 "\n" |
90 "Note that this command can only be used to access glyphs from" | 97 "Note that this command can only be used to access glyphs from" |
91 " fonts loaded with @code{ly:system-font-load}; currently, this" | 98 " fonts loaded with @code{ly:system-font-load}; currently, this" |
92 " means either the Emmentaler or Emmentaler-Brace fonts, correspondin
g" | 99 " means either the Emmentaler or Emmentaler-Brace fonts, correspondin
g" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 (SCM font), | 151 (SCM font), |
145 "Given the font metric @var{font}, return the" | 152 "Given the font metric @var{font}, return the" |
146 " design size, relative to the current output-scale.") | 153 " design size, relative to the current output-scale.") |
147 { | 154 { |
148 LY_ASSERT_SMOB (Font_metric, font, 1); | 155 LY_ASSERT_SMOB (Font_metric, font, 1); |
149 | 156 |
150 Font_metric *fm = unsmob<Font_metric> (font); | 157 Font_metric *fm = unsmob<Font_metric> (font); |
151 return scm_from_double (fm->design_size ()); | 158 return scm_from_double (fm->design_size ()); |
152 } | 159 } |
153 | 160 |
OLD | NEW |