]> git.donarmstrong.com Git - lilypond.git/commitdiff
*** empty log message ***
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 11 Dec 2004 17:58:14 +0000 (17:58 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 11 Dec 2004 17:58:14 +0000 (17:58 +0000)
lily/all-font-metrics.cc
lily/font-metric.cc
lily/include/open-type-font.hh
lily/kpath.cc
lily/main.cc
lily/open-type-font.cc
mf/merge.pe
scm/font.scm
scm/framework-ps.scm
scm/output-ps.scm

index bf2d36347130ed8683ba085f37f11c736f6df728..1935cc5972a097a8fa059070232e7bdef91429bd 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "all-font-metrics.hh"
 
-//#include "open-type-font.hh"
+#include "open-type-font.hh"
 #include "config.hh"
 #include "main.hh"
 #include "warn.hh"
@@ -120,8 +120,6 @@ All_font_metrics::find_afm (String name)
   return dynamic_cast<Adobe_font_metric*> (unsmob_metrics (val));
 }
 
-#if 0
-
 Open_type_font*
 All_font_metrics::find_otf (String name)
 {
@@ -154,7 +152,6 @@ All_font_metrics::find_otf (String name)
 
   return dynamic_cast<Open_type_font*> (unsmob_metrics (val));
 }
-#endif
 
 Tex_font_metric*
 All_font_metrics::find_tfm (String name)
@@ -201,9 +198,8 @@ All_font_metrics::find_tfm (String name)
 Font_metric*
 All_font_metrics::find_font (String name)
 {
-  //Font_metric *f = find_otf (name);
-  Font_metric *f = 0;
-  
+  Font_metric *f = find_otf (name);
+   
   if (!f &&
       (name.left_string (4) == "feta"
        || name.left_string (8) == "parmesan"
index 2e25dfac9c848f2e30693ed7a36a42897ec6b54a..0bf62ae2a0e4d8e17c022185a8f14ad13208772b 100644 (file)
@@ -42,9 +42,10 @@ Font_metric::find_by_name (String s) const
   SCM expr = SCM_EOL;
   if (idx >= 0)
     {
-      expr = scm_list_3 (ly_symbol2scm ("char"),
+      expr = scm_list_3 (ly_symbol2scm ("named-glyph"),
                         self_scm (),
-                        scm_int2num (index_to_ascii (idx)));
+                        scm_makfrom0str (s.to_str0 ())
+                        );
       b = get_indexed_char (idx);
     }
   
index 7fab468a1f5be728b53fe77613f057e2ba1aace3..e50166ad73445d612259d9336f8b6e01be71be36 100644 (file)
@@ -21,13 +21,14 @@ public:
   virtual ~Open_type_font();
   virtual Box get_indexed_char (int) const;
   virtual int name_to_index (String) const;
+
 #if 0
   virtual int count () const;
   virtual int index_to_ascii (int) const;
   virtual Box get_ascii_char (int) const;
   virtual Offset get_indexed_wxwy (int) const;
-  virtual Real design_size () const;
 #endif
+  virtual Real design_size () const;
 };
 
 
index 22910f95fcb8a6266a365217e4b272e79ef769e4..592d70d09a3a20d2295c12631dc1a13122ee767e 100644 (file)
@@ -141,6 +141,22 @@ kpathsea_gulp_file_to_string (String name)
   return string;
 }
 
+
+LY_DEFINE (ly_find_file, "ly:find-file",
+          1, 0, 0, (SCM name),
+          "Return the absolute file name of @var{name},"
+          "or @code{#f} if not found.")
+{
+  SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
+
+  String nm = ly_scm2string (name);
+  String file_name = global_path.find (nm);
+  if (file_name.is_empty ())
+    return SCM_BOOL_F;
+  
+  return scm_makfrom0str (file_name.to_str0 ());
+}
+
 LY_DEFINE (ly_kpathsea_find_file, "ly:kpathsea-find-file",
           1, 0, 0, (SCM name),
           "Return the absolute file name of @var{name},"
index f0a209bbde09ec0c772a5f49ca32ac11382857a3..4b2df95954b8c51a314884c999fe6eebec3abb71 100644 (file)
@@ -28,6 +28,7 @@
 #include "misc.hh"
 #include "output-def.hh"
 #include "warn.hh"
+#include "freetype.hh"
 
 /*
  * Global options that can be overridden through command line.
@@ -313,7 +314,7 @@ main_with_guile (void *, int, char **)
   ly_c_init_guile ();
   call_constructors ();
   init_global_tweak_registry ();
-  
+  init_freetype ();
   determine_output_options ();  
   all_fonts_global = new All_font_metrics (global_path.to_string ());
 
index 6c2d34aa4eaf3e5c66c79558ad2149e1459c905a..b870342cba633cec288a1a1379733dc7d113c2ff 100644 (file)
 
 #include <stdio.h>
 
-#if 0
-
-void
-enumerate_glyphs (FT_Face face)
-{
-  FT_UInt glyph_index;
-  FT_ULong char_code = FT_Get_First_Char (face, &glyph_index);
-  while (gindex != 0)                                       
-  {                                                                
-    // ... do something with (charcode,gindex) pair ...               
-    FT_Get
-    charcode = FT_Get_Next_Char( face, charcode, &gindex );        
-  }                                                                
-}
-
-#endif
-
 SCM
 Open_type_font::make_otf (String str)
 {
   Open_type_font * otf = new Open_type_font;
   int error_code = FT_New_Face(freetype2_library, str.to_str0(),
                               0, &(otf->face_));
-
-  //  int code = FT_Set_Charmap (otf->face_, );   
-
   
   if (error_code == FT_Err_Unknown_File_Format)
     {
@@ -58,25 +38,26 @@ Open_type_font::~Open_type_font()
 
 
 Box
-Open_type_font::get_indexed_char (int signed_idx)
+Open_type_font::get_indexed_char (int signed_idx) const
 {
   FT_UInt idx = signed_idx;
-  int code = 
-    FT_Load_Glyph (face_,
+  FT_Load_Glyph (face_,
                   idx,
                   FT_LOAD_NO_SCALE);
 
-  FT_Glyph_Metrics m = face->glyph->metrics;
-  Box b (Interval (0, m->width) - m->horiBearingX,
-        Interval (0, m->height) - m->horiBearingY);
+  FT_Glyph_Metrics m = face_->glyph->metrics;
+  int hb = m.horiBearingX;
+  int vb = m.horiBearingY;
+  Box b (Interval (-hb, m.width - hb),
+        Interval (-vb, m.height - vb));
   
   return b;
 }
 
 int
-Open_type_font::name_to_index (String nm)
+Open_type_font::name_to_index (String nm) const
 {
-  FT_String * nm_str = nm.to_str0 ();
+  char * nm_str = (char * )nm.to_str0 ();
   int idx = FT_Get_Name_Index (face_, nm_str);
 
   if (idx == 0)
@@ -87,7 +68,7 @@ Open_type_font::name_to_index (String nm)
 
 
 Real
-Open_type_font::get_design_size () const
+Open_type_font::design_size () const
 {
   return 20.0;
 }
index e0fe6234063630d4dcde62b986fccee21f9ed5fa..46020ff5041d4ad0eab9da262cfed613aefcdd9e 100644 (file)
@@ -3,7 +3,7 @@ New();
 
 // TODO: set version
 // TODO: GPL?
-SetFontNames("Feta", "LilyPond", "", "", "This font is in the public domain.", "");
+SetFontNames("bigcheese20", "", "", "", "This font is in the public domain.", "");
 
 MergeFonts("feta20.pfa");
 MergeFonts("parmesan20.pfa");
@@ -11,6 +11,6 @@ MergeFonts("feta-nummer10.pfa");
 MergeFonts("feta-din14.pfa");
 MergeKern("feta-din14.tfm");
 LoadTableFromFile("LILC", "feta20.otf-table")
-Generate("feta20.otf");
-Generate("feta20.t42");
+Generate("bigcheese20.otf");
+Generate("bigcheese20.t42");
 
index 76690df7983bbe3486ba11cb1a918d1070c89753..c804c7a77b6564e02c9cfe69d427e28d073e37a3 100644 (file)
                  ,(delay (ly:make-virtual-font
                           (ly:font-load "feta20")
                           (ly:font-load "parmesan20")))
+;                ,(delay (ly:make-virtual-font (ly:font-load "bigcheese20")))
                  ,(delay (ly:make-virtual-font
                           (ly:font-load "feta23")
                           (ly:font-load "parmesan23")))
index 626ecfca65cf3b6c76988035772c5b1d8c79d7a3..fa0ba97114752aac859ff7671b6b374905eec978 100644 (file)
         (font-names (uniq-list (sort (map ly:font-file-name fonts) string<?)))
         (pfas (map
                (lambda (x)
-               
-                 (let* ((aname (string-append x ".pfa"))
+
+                 (let* ((t42name (string-append x ".t42"))
+                        (aname (string-append x ".pfa"))
+                        (bname (string-append x ".pfb"))
+                        (t42path (ly:find-file t42name))
                         (apath (ly:kpathsea-find-file aname))
-                        
-                        (bpath (if (not apath)
-                                   (ly:kpathsea-find-file
-                                    (string-append x ".pfb"))
-                                   #f)))
+                        (bpath (ly:kpathsea-find-file bname)))
                    (cond
+                    (t42path (ly:gulp-file t42path))
                     (apath (ly:gulp-file apath))
                     (bpath (ly:pfb->pfa bpath))
                     (else
-                     (ly:warn "cannot find PFA font ~S" x)
+                     (ly:warn "cannot find T42/PFA/PFB font ~S" x)
                      ""))))
                (filter string? font-names))))
   
index 60ba6747213eca596267a66574eeadff8a2cbe0d..75251dcbfa0b081bb8d9bafdfda2e7514d20f868 100644 (file)
@@ -27,6 +27,7 @@
             bracket
             dashed-slur
             char
+            named-glyph
             dashed-line
             zigzag-line
             ez-ball
     (ps-font-command font) " setfont " 
    "(\\" (ly:inexact->string i 8) ") show" ))
 
+(define (named-glyph font glyph)
+  (string-append 
+    (ps-font-command font) " setfont " 
+   "/" glyph " glyphshow "))
+
 (define (dashed-line thick on off dx dy)
   (string-append 
    (ly:number->string dx) " "