]> git.donarmstrong.com Git - lilypond.git/commitdiff
put cmap handling into all_fonts too.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 2 Dec 2006 16:14:17 +0000 (17:14 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 2 Dec 2006 16:14:17 +0000 (17:14 +0100)
lily/all-font-metrics.cc
lily/include/all-font-metrics.hh
lily/include/font-metric.hh
lily/include/open-type-font.hh
lily/main.cc
lily/pango-font.cc

index 4d95f9e6c1c00fd4aab59a5b1f3e7f6e0d38f202..bf2aadd4bb057cc6252538665fe756f2fb9b6b67 100644 (file)
 #include "scm-hash.hh"
 #include "warn.hh"
 
+
+Index_to_charcode_map const *
+All_font_metrics::get_index_to_charcode_map (string filename, FT_Face face)
+{
+  if (filename_charcode_maps_map_.find (filename)
+      == filename_charcode_maps_map_.end ())
+    filename_charcode_maps_map_[filename] = make_index_to_charcode_map (face);
+
+  return &filename_charcode_maps_map_[filename];
+}
+
+
 All_font_metrics::All_font_metrics (string path)
 {
   otf_dict_ = new Scheme_hash_table;
@@ -166,6 +178,17 @@ All_font_metrics::find_font (string name)
 
 All_font_metrics *all_fonts_global;
 
+LY_DEFINE (ly_reset_all_fonts, "ly:reset-all-fonts", 0, 0, 0,
+          (),
+          "Forget all about previously loaded fonts. ")
+{
+  delete all_fonts_global;
+  all_fonts_global = new All_font_metrics (global_path.to_string ());
+
+  return SCM_UNSPECIFIED;
+}
+
+
 LY_DEFINE (ly_font_load, "ly:font-load", 1, 0, 0,
           (SCM name),
           "Load the font @var{name}. ")
@@ -177,3 +200,4 @@ LY_DEFINE (ly_font_load, "ly:font-load", 1, 0, 0,
   return fm->self_scm ();
 }
 
+
index c8c0de2f0a78f748bb61d70b9423c8666e1541c1..34a05e701f21cb1a5ae16b276ceaa8122b0ab729 100644 (file)
@@ -18,7 +18,8 @@
 #include <pango/pangoft2.h>
 #endif
 
-/**
+
+/*
    Interface to all .afm files living in the filesystem.
 */
 class All_font_metrics
@@ -32,8 +33,13 @@ class All_font_metrics
   int pango_dpi_;
 #endif
 
+  map<string, Index_to_charcode_map > filename_charcode_maps_map_;
+  
   All_font_metrics (All_font_metrics const &);
 public:
+
+  Index_to_charcode_map const *get_index_to_charcode_map (string filename, FT_Face face);
+
   All_font_metrics (string search_path);
   ~All_font_metrics ();
 
@@ -49,6 +55,7 @@ public:
 };
 
 extern All_font_metrics *all_fonts_global;
+SCM ly_reset_all_fonts ();
 
 #endif /* ALL_FONTS_HH */
 
index dfcd1e80035378121974ec2347826cc368dab0b4..1107ba9af8e4d08fd6231f60f7ed2279078cbd0d 100644 (file)
 #include "lily-proto.hh"
 #include "smobs.hh"
 #include "virtual-methods.hh"
+#include "freetype.hh"
+
+#include <map>
+using namespace std;
+
+typedef map<FT_UInt, FT_ULong> Index_to_charcode_map;
 
 class Font_metric
 {
index c0490be6e5042f0c28c4908ad2313841888015a6..9cd34497ab26240a7dbfb605af528d5370a42fbf 100644 (file)
@@ -9,13 +9,9 @@
 #ifndef OPEN_TYPE_FONT_HH
 #define OPEN_TYPE_FONT_HH
 
-#include <map>
-using namespace std;
 
-#include "freetype.hh"
 #include "font-metric.hh"
 
-typedef map<FT_UInt, FT_ULong> Index_to_charcode_map;
 Index_to_charcode_map make_index_to_charcode_map (FT_Face face);
 void get_unicode_name (char*s, FT_ULong code);
 void get_glyph_index_name (char*s, FT_ULong code);
@@ -58,4 +54,5 @@ public:
 string get_otf_table (FT_Face face, string tag);
 FT_Face open_ft_face (string str);
 
+
 #endif /* OPEN_TYPE_FONT_HH */
index 9a21728eb308e2c370d1cbda54ae3c67128f007f..9344a1ec4bd1c91e3ad4512c5f8c17f98ba78539 100644 (file)
@@ -393,8 +393,7 @@ main_with_guile (void *, int, char **)
   init_fontconfig ();
 
   init_freetype ();
-
-  all_fonts_global = new All_font_metrics (global_path.to_string ());
+  ly_reset_all_fonts ();
 
   if (!init_scheme_variables.empty ()
       || !init_scheme_code_string.empty ())
index ca08a4b0d23c8fc42357d77d38a3b57456d9406d..3d58e0dd0ed69cbbd4a701b425d6c94e3d27549e 100644 (file)
@@ -15,9 +15,6 @@
 /* Ugh.  */
 
 #include "pango-font.hh"
-
-#include "open-type-font.hh"   // Index_to_charcode_map
-
 #include "dimensions.hh"
 #include "file-name.hh"
 #include "international.hh"
@@ -25,6 +22,7 @@
 #include "main.hh"
 #include "string-convert.hh"
 #include "warn.hh"
+#include "all-font-metrics.hh"
 
 #if HAVE_PANGO_FT2
 #include "stencil.hh"
@@ -82,22 +80,6 @@ Pango_font::derived_mark () const
 }
 
 
-map<string, Index_to_charcode_map > filename_charcode_maps_map;
-Index_to_charcode_map const *get_index_to_charcode_map (string postscript_name, FT_Face face);
-
-
-Index_to_charcode_map const *
-get_index_to_charcode_map (string filename, FT_Face face)
-{
-  if (filename_charcode_maps_map.find (filename) == filename_charcode_maps_map.end ())
-    filename_charcode_maps_map[filename] = make_index_to_charcode_map (face);
-
-  if (filename_charcode_maps_map.find (filename) == filename_charcode_maps_map.end ())
-    return 0;
-  
-  return &filename_charcode_maps_map[filename];
-}
-
 void
 get_glyph_index_name (char *s, FT_ULong code)
 {
@@ -165,7 +147,7 @@ Pango_font::pango_item_string_stencil (PangoItem const *item, string str,
   Index_to_charcode_map const *cmap = 0;
   bool has_glyph_names = ftface->face_flags & FT_FACE_FLAG_GLYPH_NAMES;
   if  (! has_glyph_names)
-    cmap = get_index_to_charcode_map (file_name, ftface);
+    cmap = all_fonts_global->get_index_to_charcode_map (file_name, ftface);
 
   bool is_ttf = string (FT_Get_X11_Font_Format (ftface)) == "TrueType";
   bool cid_keyed = false;