* lily/open-type-font.cc (glyph_list): new function.
* lily/open-type-font-scheme.cc (LY_DEFINE): ly:otf-glyph-list function.
* lily/ttf.cc: remove ly:font-glyph-list scheme function
+2006-01-22 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * input/test/font-table.ly: use it.
+
+ * lily/open-type-font.cc (glyph_list): new function.
+
+ * lily/open-type-font-scheme.cc (LY_DEFINE): ly:otf-glyph-list function.
+
+ * lily/ttf.cc: remove ly:font-glyph-list scheme function
+
2006-01-22 Nicolas Sceaux <nicolas.sceaux@free.fr>
* ly/music-functions-init.ly (parallelMusic): new music function for parallel
#(let*
((lines (doc-chars
- (ly:font-glyph-list (format "~a/fonts/otf/emmentaler-20.otf"
- (getenv "LILYPONDPREFIX")
- ))
+ (ly:otf-glyph-list (ly:font-load "emmentaler-20"))
'()))
(pages (group-lines (reverse lines))))
*/
#include "lily-guile.hh"
+#include "string.hh"
#include <fontconfig/fontconfig.h>
}
+LY_DEFINE (ly_font_config_get_font_file, "ly:font-config-get-font-file", 1, 0, 0,
+ (SCM name),
+ "Get the file for font @var{name}")
+{
+ SCM_ASSERT_TYPE (scm_is_string (name), name,
+ SCM_ARG1, __FUNCTION__, "string");
+
+
+ FcPattern*pat = FcPatternCreate ();
+ FcValue val;
+
+ val.type = FcTypeString;
+ val.u.s = (const FcChar8*)ly_scm2string (name).to_str0 (); // FC_SLANT_ITALIC;
+ FcPatternAdd(pat, FC_FAMILY, val, FcFalse);
+
+ FcResult result;
+ SCM scm_result = SCM_BOOL_F;
+
+ FcConfigSubstitute (NULL, pat, FcMatchFont);
+ FcDefaultSubstitute (pat);
+
+ pat = FcFontMatch(NULL, pat, &result);
+ FcChar8 *str = 0;
+ if (FcPatternGetString (pat, FC_FILE, 0, &str) == FcResultMatch)
+ scm_result = scm_makfrom0str ((char const*) str);
+
+ FcPatternDestroy (pat);
+
+ return scm_result;
+}
+
LY_DEFINE (ly_font_config_display_fonts, "ly:font-config-display-fonts", 0, 0, 0,
(),
"Dump a list of all fonts visible to FontConfig.")
return SCM_UNSPECIFIED;
}
+
+
SCM get_subfonts () const;
SCM get_global_table () const;
SCM get_char_table () const;
-
+ SCM glyph_list () const;
+
String get_otf_table (String tag) const;
static SCM make_otf (String);
virtual String font_name () const;
return scm_from_bool (otf);
}
+
+LY_DEFINE (ly_otf_glyph_list, "ly:otf-glyph-list",
+ 1, 0, 0, (SCM font),
+ "Return a list of glyphnames for @var{font}.")
+{
+ Modified_font_metric *fm
+ = dynamic_cast<Modified_font_metric *> (unsmob_metrics (font));
+
+ Open_type_font *otf = fm ? dynamic_cast<Open_type_font *> (fm->original_font ())
+ : dynamic_cast<Open_type_font *> (unsmob_metrics (font));
+
+
+ SCM_ASSERT_TYPE (otf,font, SCM_ARG1, __FUNCTION__, "OTF font");
+ return otf->glyph_list ();
+
+}
return FT_Get_Postscript_Name (face_);
}
+
+SCM
+Open_type_font::glyph_list () const
+{
+ SCM retval = SCM_EOL;
+ SCM *tail = &retval;
+
+ for (int i = 0; i < face_->num_glyphs; i++)
+ {
+ const int len = 256;
+ char name[len];
+ int code = FT_Get_Glyph_Name (face_, i, name, len);
+ if (code)
+ warning (_f ("FT_Get_Glyph_Name() returned error: %d", code));
+
+ *tail = scm_cons (scm_makfrom0str (name), SCM_EOL);
+ tail = SCM_CDRLOC (*tail);
+ }
+
+ return retval;
+}
FT_Done_Face (face);
}
-LY_DEFINE (ly_font_glyph_list, "ly:font-glyph-list",
- 1, 0, 0, (SCM font_file_name),
- "Return a list of glyphnames for @var{font-file-name}.")
-{
- SCM_ASSERT_TYPE (scm_is_string (font_file_name), font_file_name,
- SCM_ARG1, __FUNCTION__, "string");
-
- String file_name = ly_scm2string (font_file_name);
- if (be_verbose_global)
- progress_indication ("[" + file_name);
-
- SCM retval = SCM_EOL;
- SCM *tail = &retval;
-
- FT_Face face = open_ft_face (file_name);
- for (int i = 0; i < face->num_glyphs; i++)
- {
- const int len = 256;
- char name[len];
- int code = FT_Get_Glyph_Name (face, i, name, len);
- if (code)
- warning (_f ("FT_Get_Glyph_Name() returned error: %d", code));
-
- *tail = scm_cons (scm_makfrom0str (name), SCM_EOL);
- tail = SCM_CDRLOC (*tail);
- }
-
- FT_Done_Face (face);
- if (be_verbose_global)
- progress_indication ("]");
- return retval;
-}
LY_DEFINE (ly_ttf_ps_name, "ly:ttf-ps-name",
1, 0, 0, (SCM ttf_file_name),