]> git.donarmstrong.com Git - lilypond.git/commitdiff
* buildscripts/gen-bigcheese-scripts.py (i): load .subfonts table.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 13 Dec 2004 23:02:38 +0000 (23:02 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 13 Dec 2004 23:02:38 +0000 (23:02 +0000)
* lily/open-type-font.cc (LY_DEFINE): new function
ly:font-sub-fonts

* lily/include/font-metric.hh (struct Font_metric): new method
sub_fonts()

ChangeLog
buildscripts/gen-bigcheese-scripts.py
buildscripts/mf-to-table.py
lily/font-metric.cc
lily/include/font-metric.hh
lily/include/modified-font-metric.hh
lily/include/open-type-font.hh
lily/modified-font-metric.cc
lily/open-type-font.cc
scm/output-tex.scm

index ab0ea7a7ecf569ae87c3d0b5d910c06d26d94408..beff39089b75d67a0c455cf1ab30c6e3b898d8ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2004-12-13  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * buildscripts/gen-bigcheese-scripts.py (i): load .subfonts table. 
+
+       * lily/open-type-font.cc (LY_DEFINE): new function
+       ly:font-sub-fonts
+
+       * lily/include/font-metric.hh (struct Font_metric): new method
+       sub_fonts()
+
        * lily/vaticana-ligature-engraver.cc (transform_heads): replace
        . with - in add.stem.
        
index 01a1cc5b8e257db09b90920ebad5a02ca0be92f6..8d590fe0e3da792f7b9020604aec57ba49ce3e00 100644 (file)
@@ -3,6 +3,7 @@ import sys
 import getopt
 import re 
 import os
+import string
 
 (options, files) = \
   getopt.getopt (sys.argv[1:],
@@ -59,6 +60,7 @@ endloop
 MergeFonts("feta-alphabet%(design_size)d.pfa");
 MergeKern("feta-alphabet%(design_size)d.tfm");
 
+LoadTableFromFile("LILF", "%(name)s%(design_size)d.subfonts")
 LoadTableFromFile("LILC", "feta%(design_size)d.otf-table")
 LoadTableFromFile("LILY", "feta%(design_size)d.otf-gtable")
 
@@ -68,6 +70,19 @@ Generate("%(name)s%(design_size)d.cff");''' % vars()
        path = os.path.join (outdir, name + '%d' % design_size +  '.pe')
        open (path, 'w').write (script)
 
+
+       subfonts = ['feta%(design_size)d',
+                   'parmesan%(design_size)d',
+                   'feta-alphabet%(design_size)d']
+
+       ns = []
+       for s in subfonts:
+               ns.append (s % vars())
+               
+       subfonts_str = string.join (ns)
+       
+       open (os.path.join (outdir, '%(name)s%(design_size)d.subfonts' % vars()), 'w').write (subfonts_str)
+
        path = os.path.join (outdir, name + '%d' % design_size +  '.dep')
 
        deps = r'''%(name)s%(design_size)d.otf: $(outdir)/feta%(design_size)d.pfa \
index 163f48d111a0f8640dd88283992cc9281b04d06e..e19a96b0efbc69db76e8356aa5a5cf1d5df3ebe6 100644 (file)
@@ -153,8 +153,6 @@ def write_afm_metric (file, global_info, charmetrics):
 
 
 def write_tex_defs (file, global_info, charmetrics):
-       nm = global_info['font
-       ## nm = global_info['FontFamily']
        nm = font_family
        for m in charmetrics:
                
index e334548fbb75601c2803dba7ca49223ba7634a40..55084aad4ded3bd7c1564191d3d3cc142ad4c905 100644 (file)
@@ -183,7 +183,7 @@ LY_DEFINE (ly_font_index_to_charcode, "ly:font-index-to-charcode",
   SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
   SCM_ASSERT_TYPE (scm_is_integer (index), index, SCM_ARG2, __FUNCTION__, "index");
 
-  return scm_from_unsigned_integer (fm->index_to_charcode (ly_scm2int (index)));
+  return scm_from_unsigned_integer (fm->index_to_charcode (scm_to_int (index)));
 }
 
 LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode",
@@ -329,3 +329,9 @@ Font_metric::attachment_point (String) const
 {
   return Offset (0, 0);
 }
+
+SCM
+Font_metric::sub_fonts () const
+{
+  return SCM_EOL;
+}
index ad56d8f931c80870a99c6ee7523287d1581b7a88..183815d42dacb061c07aa8f411d574ee4370ad55 100644 (file)
@@ -33,6 +33,7 @@ public:
   virtual Stencil get_indexed_char_stencil (int k) const;
   virtual Stencil get_ascii_char_stencil (int k) const;
   virtual String coding_scheme () const;
+  virtual SCM sub_fonts () const;
   
   DECLARE_SMOBS (Font_metric,);
 
index 277d61f8942fef4efd95c941f955759a60fdd3e4..2d6215fc571fc4be0d85f18a30e2e4c287ebc3f7 100644 (file)
@@ -39,6 +39,7 @@ protected:
     
   Modified_font_metric (Font_metric *fm, Real magnification,
                        String font_encoding, String input_encoding);
+  virtual SCM sub_fonts () const;
   virtual Real design_size () const;
   virtual void derived_mark () const; 
   virtual Box get_indexed_char (int) const;
index fddb9b2ce8cee6c81fee5692e4177e51893bf4bf..a369d4849428e0bab2d983b6f98c895730bb54ad 100644 (file)
@@ -21,6 +21,7 @@ class Open_type_font : public Font_metric
 {
   FT_Face face_; /* handle to face object */
 
+  SCM lily_subfonts_; 
   SCM lily_character_table_; 
   SCM lily_global_table_;
   Index_to_charcode_map index_to_charcode_map_;
@@ -36,6 +37,7 @@ public:
   //virtual unsigned glyph_name_to_charcode (String) const;
   virtual unsigned index_to_charcode (int) const;
   virtual void derived_mark () const;
+  virtual SCM sub_fonts () const;
 #if 0
   virtual int count () const;
   virtual int index_to_ascii (int) const;
index bac7d43993910ae76ae56836a4cc89c00e2067ac..a28ae42a601fe4bd85c6643d0b8044b8dd730b0a 100644 (file)
@@ -333,3 +333,9 @@ LY_DEFINE (ly_font_encoding, "ly:font-encoding",
   return ly_symbol2scm (fm->original_font ()->coding_scheme ().to_str0 ());
 }
 
+SCM
+Modified_font_metric::sub_fonts () const
+{
+  return orig_->sub_fonts();
+}
+  
index 4c5c9e24f1069520c9b510a81f0fb5e7e09e1432..36eeafb52267baa6d186a6426f3f60754cda37dd 100644 (file)
@@ -55,13 +55,13 @@ load_scheme_table (char const *tag_str, FT_Face face)
       String contents ((Byte const*)buffer, length);
       contents = "(quote (" +  contents + "))";
 
-      SCM alist = scm_c_eval_string (contents.to_str0 ());
-      tab = alist_to_hashq (alist);
+      SCM expr = scm_c_eval_string (contents.to_str0 ());
       free (buffer);
     }
-  return tab;
+  return expr;
 }
 
+
 Index_to_charcode_map
 make_index_to_charcode_map (FT_Face face)
 {
@@ -98,18 +98,6 @@ make_glyph_name_to_charcode_map (FT_Face face)
 }
 #endif
 
-Open_type_font::Open_type_font (FT_Face face)
-{
-  face_ = face;
-  lily_character_table_ = SCM_EOL;
-  lily_global_table_ = SCM_EOL;
-
-  lily_character_table_ = load_scheme_table ("LILC", face_);
-  lily_global_table_ = load_scheme_table ("LILY", face_);
-  index_to_charcode_map_ = make_index_to_charcode_map (face_);
-  //glyph_name_to_charcode_map_ = make_glyph_name_to_charcode_map (face_);
-}
-
 Open_type_font::~Open_type_font()
 {
   FT_Done_Face (face_);
@@ -136,15 +124,19 @@ Open_type_font::make_otf (String str)
   return otf->self_scm ();
 }
 
-Open_type_font::Open_type_font(FT_Face face)
+
+Open_type_font::Open_type_font (FT_Face face)
 {
   face_ = face;
   lily_character_table_ = SCM_EOL;
   lily_global_table_ = SCM_EOL;
+
+  lily_character_table_ = alist_to_hashq (load_scheme_table ("LILC", face_));
+  lily_global_table_ = alist_to_hashq (load_scheme_table ("LILY", face_));
+  lily_subfonts_ = load_scheme_table ("LILF", face_);
+  index_to_charcode_map_ = make_index_to_charcode_map (face_);
   
-  lily_character_table_ = load_scheme_table ("LILC", face_);
-  lily_global_table_ = load_scheme_table ("LILY", face_);
-  index_to_charcode_map_ = make_index_to_charcode_map (face_);  
+  //glyph_name_to_charcode_map_ = make_glyph_name_to_charcode_map (face_);
 }
 
 void
@@ -152,6 +144,7 @@ Open_type_font::derived_mark () const
 {
   scm_gc_mark (lily_character_table_);
   scm_gc_mark (lily_global_table_);
+  scm_gc_mark (lily_subfonts_);
 }
 
 Offset
@@ -220,3 +213,21 @@ Open_type_font::design_size () const
                             ly_symbol2scm ("staffsize"), SCM_BOOL_F);
   return scm_to_double (entry);
 }
+
+
+SCM
+Open_type_font::sub_fonts () const
+{
+  return lily_subfonts_;
+}
+
+LY_DEFINE (ly_font_magnification, "ly:font-sub-fonts", 1, 0, 0,
+         (SCM font),
+          "Given the font metric @var{font}, return the "
+          "magnification, relative to the current outputscale.")
+{
+  Font_metric *fm = unsmob_metrics (font);
+  SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
+  return scm_cdr (fm->description_);
+}
+
index c8ac8ec04ed1dce379ff0d3127b992cbc0aa647d..e4aab9f61395a9784a31d7e24f5cf142b2669799 100644 (file)
@@ -29,7 +29,7 @@
             beam
             bracket
             dashed-slur
-            char
+            named-glyph
             dashed-line
             zigzag-line
             ez-ball
 (define (dashed-slur thick dash l)
   (embedded-ps (list 'dashed-slur thick dash `(quote ,l))))
 
-(define (char font i)
+(define (digits->letters str)
+    (regexp-substitute/global
+     #f "([0-9])" str
+     'pre
+     (lambda (match)
+       (make-string
+       1
+       (integer->char
+        (+ (char->integer #\A)
+           (- (char->integer #\0))
+           (char->integer (string-ref (match:substring match 1) 0)))
+        )))
+     'post))
+
+(define (named-glyph font name)
   (string-append "\\" (tex-font-command font)
-                "\\char" (ly:inexact->string i 10) " "))
+                "\\"
+                (string-append
+;                (digits->letters (ly:font-name font))
+                 (regexp-substitute/global
+                  #f "[\\._]"
+                  (digits->letters name)
+                  'pre ""
+                  'post))))
 
 (define (dashed-line thick on off dx dy)
   (embedded-ps (list 'dashed-line  thick on off dx dy)))