#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;
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}. ")
return fm->self_scm ();
}
+
#include <pango/pangoft2.h>
#endif
-/**
+
+/*
Interface to all .afm files living in the filesystem.
*/
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 ();
};
extern All_font_metrics *all_fonts_global;
+SCM ly_reset_all_fonts ();
#endif /* ALL_FONTS_HH */
#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
{
#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);
string get_otf_table (FT_Face face, string tag);
FT_Face open_ft_face (string str);
+
#endif /* OPEN_TYPE_FONT_HH */
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 ())
/* Ugh. */
#include "pango-font.hh"
-
-#include "open-type-font.hh" // Index_to_charcode_map
-
#include "dimensions.hh"
#include "file-name.hh"
#include "international.hh"
#include "main.hh"
#include "string-convert.hh"
#include "warn.hh"
+#include "all-font-metrics.hh"
#if HAVE_PANGO_FT2
#include "stencil.hh"
}
-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)
{
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;