]> git.donarmstrong.com Git - lilypond.git/commitdiff
* input/test/font-table.ly: use it.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 22 Jan 2006 18:46:37 +0000 (18:46 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 22 Jan 2006 18:46:37 +0000 (18:46 +0000)
* 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

ChangeLog
input/test/font-table.ly
lily/font-config-scheme.cc
lily/include/open-type-font.hh
lily/open-type-font-scheme.cc
lily/open-type-font.cc
lily/ttf.cc

index 6e932bd1057569ba80d77a3b3822c4ef82ef95a9..45a5a2dc27d7c6b324b7f004066a2616861367fc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+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
index a21d1791414c7a247915749b7d1825a88b6d4b56..6bb5ef83a235d660dbb5bd1526a5ae51e7a6a7ad 100644 (file)
@@ -56,9 +56,7 @@
                        
 #(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))))
 
index 99e8f453c69bad2a8657bed148c2a225fbb480d8..a31bfa6e696dbf5ca98cce471d9447cf5d29eacc 100644 (file)
@@ -8,6 +8,7 @@
 */
 
 #include "lily-guile.hh"
+#include "string.hh"
 
 #include <fontconfig/fontconfig.h>
 
@@ -73,6 +74,37 @@ display_list (FcConfig *fcc)
 }
 
 
+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.")
@@ -82,3 +114,5 @@ LY_DEFINE (ly_font_config_display_fonts, "ly:font-config-display-fonts", 0, 0, 0
   
   return SCM_UNSPECIFIED;
 }
+
+
index 03cf0daaf2a3c2e49952c3444909c6169a527657..c27c9a66ffa55a14b3011731b35a2d6e0144546e 100644 (file)
@@ -36,7 +36,8 @@ public:
   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;
index 44d3353770bcfd2e65143fc6a6a599d14b4873fa..43f8c32f8d884d56d81393db8f0874a49cffde4f 100644 (file)
@@ -71,3 +71,19 @@ LY_DEFINE (ly_otf_font_p, "ly:otf-font?", 1, 0, 0,
 
   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 ();
+
+}
index aa7291dd70162cbb115bd2b1b3798490cfd059a2..85e38042f4fb3c3f1d62927e2736233af69e9102 100644 (file)
@@ -288,3 +288,24 @@ Open_type_font::font_name () const
   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;
+}
index 31fc47b07bb12b13ba662514303055baf0271404..677f4d0179eaa3e82163a576d924224ff3681644 100644 (file)
@@ -163,38 +163,6 @@ create_type42_font (void *out, String name)
   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),