From 9304da2bf474a2aa4658e5de035fcbdc534aa99b Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sat, 21 Jan 2006 14:16:35 +0000 Subject: [PATCH] * lily/ttf.cc (LY_DEFINE): new function ly:font-glyph-list. * lily/ttf.cc (LY_DEFINE): ly:ttf-ps-name: new routine to extract PS name from TTF font. --- ChangeLog | 6 ++++++ lily/ttf.cc | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/ChangeLog b/ChangeLog index 17ac4de2e4..a4272d482c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2006-01-21 Han-Wen Nienhuys + * lily/ttf.cc (LY_DEFINE): new function ly:font-glyph-list. + + * VERSION (PACKAGE_NAME): release 2.7.28 + * scm/framework-ps.scm (write-preamble): use it to pick exactly the right font from a Mac dfont. (write-preamble): don't forget directory, only look at files. @@ -107,6 +111,8 @@ 2006-01-07 Han-Wen Nienhuys + * VERSION: release 2.7.27 + * lily/bar-line.cc (calc_bar_size): inspect staff->extent (Y_AXIS) for determining bar size. diff --git a/lily/ttf.cc b/lily/ttf.cc index 14d58411f7..f1163e884c 100644 --- a/lily/ttf.cc +++ b/lily/ttf.cc @@ -159,6 +159,39 @@ create_type42_font (void *out, String name) print_header (out, face); print_body (out, name); print_trailer (out, face); + + 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); + return retval; } LY_DEFINE (ly_ttf_ps_name, "ly:ttf-ps-name", @@ -177,9 +210,12 @@ LY_DEFINE (ly_ttf_ps_name, "ly:ttf-ps-name", if (be_verbose_global) progress_indication ("]"); + FT_Done_Face (face); return scm_makfrom0str (ps_name_str0 ? ps_name_str0 : ""); } + + LY_DEFINE (ly_ttf_to_pfa, "ly:ttf->pfa", 1, 0, 0, (SCM ttf_file_name), "Convert the contents of a TTF file to Type42 PFA, returning it as " -- 2.39.2