#include "font-metric.hh"
/* Perhaps junk this, and move this to layout_def as interface? */
-struct Modified_font_metric : public Font_metric
+struct Modified_font_metric : public Preinit<Modified_font_metric>,
+ public Font_metric
{
public:
Stencil text_stencil (Output_def *output_state, const string&, bool) const;
size_t name_to_index (string) const;
size_t index_to_charcode (size_t) const;
Font_metric *original_font () const;
+ void pre_init ();
protected:
Font_metric *orig_;
void get_unicode_name (char *s, FT_ULong code);
void get_glyph_index_name (char *s, FT_ULong code);
-class Open_type_font : public Font_metric
+class Open_type_font : public Preinit<Open_type_font>, public Font_metric
{
/* handle to face object */
FT_Face face_;
DECLARE_CLASSNAME (Open_type_font);
public:
+ void pre_init ();
Real get_units_per_EM () const;
SCM get_subfonts () const;
SCM get_global_table () const;
#include "font-metric.hh"
-class Pango_font : public Font_metric
+class Pango_font : public Preinit<Pango_font>, public Font_metric
{
PangoContext *context_;
PangoFontDescription *pango_description_;
public:
SCM physical_font_tab () const;
+ void pre_init ();
Pango_font (PangoFT2FontMap *,
PangoFontDescription const *,
Real);
#include "main.hh"
#include "program-option.hh"
+void Modified_font_metric::pre_init ()
+{
+ orig_ = 0;
+}
+
Modified_font_metric::Modified_font_metric (Font_metric *fm,
Real magnification)
{
void
Modified_font_metric::derived_mark () const
{
+ if (orig_)
+ scm_gc_mark (orig_->self_scm ());
}
Stencil
return otf->self_scm ();
}
-Open_type_font::Open_type_font (FT_Face face)
+void
+Open_type_font::pre_init ()
{
- face_ = face;
lily_character_table_ = SCM_EOL;
lily_global_table_ = SCM_EOL;
lily_subfonts_ = SCM_EOL;
lily_index_to_bbox_table_ = SCM_EOL;
+}
+
+Open_type_font::Open_type_font (FT_Face face)
+{
+ face_ = face;
lily_character_table_ = alist_to_hashq (load_scheme_table ("LILC", face_));
lily_global_table_ = alist_to_hashq (load_scheme_table ("LILY", face_));
#if HAVE_PANGO_FT2
#include "stencil.hh"
+void
+Pango_font::pre_init ()
+{
+ physical_font_tab_ = SCM_EOL;
+}
+
Pango_font::Pango_font (PangoFT2FontMap *fontmap,
PangoFontDescription const *description,
Real output_scale)
{
- // This line looks stupid, but if we don't initialize physical_font_tab_ before
- // we allocate memory in scm_c_make_hash_table, then that could trigger a garbage
- // collection.
- physical_font_tab_ = SCM_EOL;
physical_font_tab_ = scm_c_make_hash_table (11);
PangoDirection pango_dir = PANGO_DIRECTION_LTR;
context_ = pango_context_new ();