* lily/include/font-metric.hh (coding_scheme): New method.
2004-04-05 Jan Nieuwenhuizen <janneke@gnu.org>
+ * lily/font-metric.cc (get_encoded_index): New function.
+
+ * lily/include/font-metric.hh (coding_scheme): New method.
+
+ * scm/encoding.scm: New file.
+
* mf/feta-beugel.mf: Better error message (WAS: `foobar').
2004-04-05 Werner Lemberg <wl@gnu.org>
#include <string.h>
-#include "warn.hh" // error ()
+#include "warn.hh"
#include "libc-extension.hh"
#include "afm.hh"
#include "stencil.hh"
#include "dimensions.hh"
-Adobe_font_metric::Adobe_font_metric (AFM_Font_info * fi)
+Adobe_font_metric::Adobe_font_metric (AFM_Font_info *fi)
{
checksum_ = 0;
- font_inf_ = fi;
-
+ font_info_ = fi;
design_size_ = 1.0;
- for (int i= 256 >? fi->numOfChars; i--;)
+ for (int i = 256 >? fi->numOfChars; i--;)
ascii_to_metric_idx_.push (-1);
for (int i=0; i < fi->numOfChars; i++)
{
AFM_CharMetricInfo * c = fi->cmi + i;
- /*
- Some TeX afm files contain code = -1. We don't know why, let's
- ignore it.
-
- */
+ /* Some TeX afm files contain code = -1. We don't know why,
+ let's ignore it. */
if (c->code >= 0)
ascii_to_metric_idx_[c->code] = i;
name_to_metric_dict_[c->name] = i;
}
}
+Adobe_font_metric::~Adobe_font_metric ()
+{
+ AFM_free (font_info_);
+}
SCM
Adobe_font_metric::make_afm (AFM_Font_info *fi,
unsigned int checksum,
Real design_size)
{
- Adobe_font_metric * fm = new Adobe_font_metric (fi);
+ Adobe_font_metric *fm = new Adobe_font_metric (fi);
fm->checksum_ = checksum;
fm->design_size_ = design_size;
return fm->self_scm ();
}
-
-AFM_CharMetricInfo const *
+AFM_CharMetricInfo const*
Adobe_font_metric::find_ascii_metric (int a) const
{
if (ascii_to_metric_idx_[a] >=0)
{
int code = ascii_to_metric_idx_[a];
- if (code>=0)
- {
- return font_inf_->cmi + code;
- }
+ if (code >= 0)
+ return font_info_->cmi + code;
}
-
return 0;
}
-
-
-AFM_CharMetricInfo const *
+AFM_CharMetricInfo const*
Adobe_font_metric::find_char_metric (String nm) const
{
int idx = name_to_index (nm);
if (idx >= 0)
- return font_inf_->cmi+ idx;
- else
- return 0;
+ return font_info_->cmi + idx;
+ return 0;
}
int
-Adobe_font_metric::name_to_index (String nm)const
+Adobe_font_metric::name_to_index (String name) const
{
- std::map<String,int>::const_iterator ai = name_to_metric_dict_.find (nm);
-
+ std::map<String,int>::const_iterator ai = name_to_metric_dict_.find (name);
if (ai == name_to_metric_dict_.end ())
return -1;
- else
- return (*ai).second;
+ return (*ai).second;
}
int
Adobe_font_metric::count () const
{
- return font_inf_->numOfChars ;
+ return font_info_->numOfChars;
}
Box
Adobe_font_metric::get_ascii_char (int code) const
{
- AFM_CharMetricInfo const
- * c = find_ascii_metric (code);
- Box b (Interval (0,0),Interval (0,0));
+ AFM_CharMetricInfo const *c = find_ascii_metric (code);
+ Box b (Interval (0, 0), Interval (0, 0));
if (c)
- b = afm_bbox_to_box (c->charBBox);
-
+ b = afm_bbox_to_box (c->charBBox);
return b;
}
-
Box
Adobe_font_metric::get_indexed_char (int code) const
{
- if (code>= 0)
- return afm_bbox_to_box (font_inf_->cmi[code].charBBox);
+ if (code >= 0)
+ return afm_bbox_to_box (font_info_->cmi[code].charBBox);
else
- return Box (Interval (0,0),Interval (0,0));
+ return Box (Interval (0, 0), Interval (0, 0));
}
SCM
{
fgets (s, sizeof (s), f);
if (strncmp (s, check_key, strlen (check_key)) == 0)
- {
- sscanf (s + strlen (check_key), "%ud", &cs);
- }
+ sscanf (s + strlen (check_key), "%ud", &cs);
else if (strncmp (s, size_key, strlen (size_key)) == 0)
- {
- sscanf (s + strlen (size_key), "%lf", &ds);
- }
+ sscanf (s + strlen (size_key), "%lf", &ds);
}
rewind (f);
- AFM_Font_info * fi;
+ AFM_Font_info *fi;
int ok = AFM_parseFile (f, &fi, ~1);
if (ok)
}
-/*
- actually, AFMs will be printers point, usually, but our .py script dumps
- real points.
- */
+/* Actually, AFMs will be printers point, usually, but our .py script dumps
+ real points. */
Box
afm_bbox_to_box (AFM_BBox bb)
{
}
Offset
-Adobe_font_metric::get_indexed_wxwy (int k)const
+Adobe_font_metric::get_indexed_wxwy (int k) const
{
- AFM_CharMetricInfo const *mi = font_inf_->cmi+ k;
+ AFM_CharMetricInfo const *mi = font_info_->cmi+ k;
return 1/1000.0 PT * Offset (mi->wx, mi->wy);
}
-
-
-Adobe_font_metric::~Adobe_font_metric ()
-{
- AFM_free (font_inf_);
-}
-
/*
return a stencil, without fontification
*/
if (!cm)
{
- /*
- Why don't we return empty?
- */
-
+ /* FIXME: Why don't we return empty? */
Stencil m;
m.set_empty (false);
return m;
}
-
- SCM at = (scm_list_n (ly_symbol2scm ("char"),
- scm_int2num (cm->code),
- SCM_UNDEFINED));
-
- // at= fontify_atom ((Font_metric*)this, at);
- Box b = afm_bbox_to_box (cm->charBBox);
+ SCM at = (scm_list_2 (ly_symbol2scm ("char"), scm_int2num (cm->code)));
+
+#if 0
+ at = fontify_atom ((Font_metric*) this, at);
+#endif
+ Box b = afm_bbox_to_box (cm->charBBox);
return Stencil (b, at);
}
{
return design_size_;
}
+
+String
+Adobe_font_metric::coding_scheme () const
+{
+ return font_info_->gfi->encodingScheme;
+}
#include "scm-hash.hh"
#include "kpath.hh"
-static const char * default_font_str0_ = "cmr10";
+static const char *default_font_str0_ = "cmr10";
All_font_metrics::All_font_metrics (String path)
{
/*
TODO: our AFM handling is broken: the units in an AFM file are
relative to the design size (1000 units = 1 designsize). Hence we
- should include design size when generating an AFM metric.
+ should include design size when generating an AFM metric.
+
+ ugr: copied from find_tfm.
*/
Adobe_font_metric *
All_font_metrics::find_afm (String name)
{
SCM sname = ly_symbol2scm (name.to_str0 ());
-
SCM name_string = scm_makfrom0str (name.to_str0 ());
-
SCM val;
-
if (!afm_p_dict_->try_retrieve (sname, &val))
{
- String path;
+ String filename;
- if (path.is_empty ())
- path = search_path_.find (name + ".afm");
+ if (filename.is_empty ())
+ filename = search_path_.find (name + ".afm");
- if (path.is_empty ())
+ if (filename.is_empty ())
{
String p = kpathsea_find_afm (name.to_str0 ());
if (p.length ())
- path = p;
+ filename = p;
}
- if (path.is_empty ())
+ if (filename.is_empty ())
return 0;
if (verbose_global_b)
- progress_indication ("[" + path);
- val = read_afm_file (path);
- unsmob_metrics (val)->path_ = path;
+ progress_indication ("[" + filename);
+ val = read_afm_file (filename);
+ unsmob_metrics (val)->filename_ = filename;
- unsmob_metrics (val)->description_ = gh_cons (name_string, gh_double2scm (1.0));
+ unsmob_metrics (val)->description_ = gh_cons (name_string,
+ gh_double2scm (1.0));
if (verbose_global_b)
progress_indication ("]");
- afm_p_dict_->set (sname,val);
-
+ afm_p_dict_->set (sname, val);
scm_gc_unprotect_object (val);
-
Adobe_font_metric *afm
= dynamic_cast<Adobe_font_metric*> (unsmob_metrics (val));
- /*
- only check checksums if there is one. We take the risk that
- some file has valid checksum 0
- */
+ /* Only check checksums if there is one. We take the risk that
+ some file has valid checksum 0 */
if (afm->checksum_)
{
Tex_font_metric * tfm = find_tfm (name);
/* FIXME: better warning message
- (maybe check upon startup for feta16.afm, feta16.tfm?)
- */
+ (maybe check upon startup for feta16.afm, feta16.tfm?) */
if (tfm && tfm->info_.checksum != afm->checksum_)
{
+ // FIXME: broken sentence
String s = _f ("checksum mismatch for font file: `%s'",
- path.to_str0 ());
- s += " " + _f ("does not match: `%s'", tfm->path_.to_str0 ()); // FIXME
+ filename.to_str0 ());
+ s += " " + _f ("does not match: `%s'",
+ tfm->filename_.to_str0 ());
s += "\n";
s += " TFM: " + to_string ((int) tfm->info_.checksum);
s += " AFM: " + to_string ((int) afm->checksum_);
}
-Tex_font_metric *
+Tex_font_metric*
All_font_metrics::find_tfm (String name)
{
SCM sname = ly_symbol2scm (name.to_str0 ());
SCM name_string = scm_makfrom0str (name.to_str0 ());
-
SCM val;
if (!tfm_p_dict_->try_retrieve (sname, &val))
{
- String path;
+ String filename;
- if (path.is_empty ())
+ if (filename.is_empty ())
{
String p = kpathsea_find_tfm (name.to_str0 ());
if (p.length ())
- path = p;
+ filename = p;
}
- if (path.is_empty ())
- path = search_path_.find (name + ".tfm");
- if (path.is_empty ())
+ if (filename.is_empty ())
+ filename = search_path_.find (name + ".tfm");
+ if (filename.is_empty ())
return 0;
if (verbose_global_b)
- progress_indication ("[" + path);
+ progress_indication ("[" + filename);
- val = Tex_font_metric::make_tfm (path);
+ val = Tex_font_metric::make_tfm (filename);
if (verbose_global_b)
progress_indication ("]");
- unsmob_metrics (val)->path_ = path;
- unsmob_metrics (val)->description_ = gh_cons (name_string, gh_double2scm (1.0));
+ unsmob_metrics (val)->filename_ = filename;
+ unsmob_metrics (val)->description_ = gh_cons (name_string,
+ gh_double2scm (1.0));
tfm_p_dict_->set (sname, val);
-
scm_gc_unprotect_object (val);
}
- return
- dynamic_cast<Tex_font_metric*> (unsmob_metrics (val));
+ return dynamic_cast<Tex_font_metric*> (unsmob_metrics (val));
}
-
-
-Font_metric *
+Font_metric*
All_font_metrics::find_font (String name)
{
if ((name.left_string (4) == "feta") ||
(name.left_string (8) == "parmesan"))
{
- Font_metric * f = find_afm (name);
+ Font_metric *f = find_afm (name);
if (f)
return f;
else
if (f)
return f;
else
- f =find_afm (name);
+ f = find_afm (name);
if (f)
- return f ;
+ return f;
}
warning (_f ("can't find font: `%s'", name.to_str0 ()));
return 1.0;
}
+String
+Font_metric::coding_scheme () const
+{
+ return "FontSpecific";
+}
+
Box
Font_metric::text_dimension (String text) const
{
}
}
if (ydims.is_empty ())
- ydims = Interval (0,0);
+ ydims = Interval (0, 0);
return Box (Interval (0, w), ydims);
}
-
-Font_metric::~Font_metric ()
-{
-}
-
Font_metric::Font_metric ()
{
description_ = SCM_EOL;
{
}
+
+Font_metric::~Font_metric ()
+{
+}
+
int
Font_metric::count () const
{
Box
Font_metric::get_ascii_char (int) const
{
- return Box (Interval (0,0),Interval (0,0));
+ return Box (Interval (0, 0), Interval (0, 0));
}
Box
return get_ascii_char (k);
}
-
int
Font_metric::name_to_index (String) const
{
Offset
Font_metric::get_indexed_wxwy (int )const
{
- return Offset (0,0);
+ return Offset (0, 0);
}
void
Font_metric::derived_mark ()const
{
-
}
SCM
Font_metric::mark_smob (SCM s)
{
- Font_metric * m = (Font_metric*) SCM_CELL_WORD_1 (s);
-
+ Font_metric *m = (Font_metric*) SCM_CELL_WORD_1 (s);
m->derived_mark ();
return m->description_;
}
Stencil
Font_metric::find_by_name (String) const
{
- Stencil m ;
+ Stencil m;
return m;
}
-LY_DEFINE (ly_find_glyph_by_name, "ly:find-glyph-by-name", 2 , 0, 0,
+LY_DEFINE (ly_find_glyph_by_name, "ly:find-glyph-by-name",
+ 2, 0, 0,
(SCM font, SCM name),
"This function retrieves a Stencil for the glyph named @var{name} "
"in "
SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
SCM_ASSERT_TYPE (gh_string_p (name), name, SCM_ARG2, __FUNCTION__, "string");
- Stencil m = fm->find_by_name (ly_scm2string (name));
+ Stencil m = fm->find_by_name (ly_scm2string (name));
- /*
- TODO: make optional argument for default if not found.
- */
+ /* TODO: make optional argument for default if not found. */
return m.smobbed_copy ();
}
-LY_DEFINE (ly_get_glyph, "ly:get-glyph", 2 , 0, 0,
+LY_DEFINE (ly_get_glyph, "ly:get-glyph",
+ 2, 0, 0,
(SCM font, SCM index),
- "This function retrieves a Stencil for the glyph numbered @var{index} in "
-"@var{font}. ")
+ "Retrieve a Stencil for the glyph numbered @var{index} "
+ "in @var{font}.")
{
Font_metric *fm = unsmob_metrics (font);
SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
return fm->get_ascii_char_stencil (gh_scm2int (index)).smobbed_copy ();
}
-LY_DEFINE (ly_text_dimension,"ly:text-dimension", 2 , 0, 0,
+LY_DEFINE (ly_text_dimension,"ly:text-dimension",
+ 2, 0, 0,
(SCM font, SCM text),
- "Given the font metric in @var{font} and the string @var{text}, compute "
-"the extents of that text in that font. The return value is a pair of "
-"number-pairs.")
+ "Given the font metric in @var{font} and the string @var{text}, "
+ "compute the extents of that text in that font. "
+ "The return value is a pair of number-pairs.")
{
Box b;
Font_metric *fm = unsmob_metrics (font);
return gh_cons (ly_interval2scm (b[X_AXIS]), ly_interval2scm (b[Y_AXIS]));
}
-LY_DEFINE (ly_font_name,"ly:font-name", 1 , 0, 0,
- (SCM font),
- "Given the font metric @var{font}, return the corresponding file name. ")
+LY_DEFINE (ly_font_name,"ly:font-name",
+ 1, 0, 0,
+ (SCM font),
+ "Given the font metric @var{font}, "
+ "return the corresponding file name.")
{
Font_metric *fm = unsmob_metrics (font);
SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
{
Font_metric *fm = unsmob_metrics (font);
SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
- return gh_double2scm (fm->design_size ());
+ return gh_double2scm (fm->design_size ());
}
-
Stencil
-Font_metric::get_ascii_char_stencil (int code) const
+Font_metric::get_ascii_char_stencil (int code) const
{
- SCM at = scm_list_n (ly_symbol2scm ("char"), gh_int2scm (code),
- SCM_UNDEFINED);
+ SCM at = scm_list_2 (ly_symbol2scm ("char"), gh_int2scm (code));
at = fontify_atom (this, at);
Box b = get_ascii_char (code);
return Stencil (b, at);
}
Stencil
-Font_metric::get_indexed_char_stencil (int code) const
+Font_metric::get_indexed_char_stencil (int code) const
{
- SCM at = scm_list_n (ly_symbol2scm ("char"), gh_int2scm (code),
- SCM_UNDEFINED);
+ SCM at = scm_list_2 (ly_symbol2scm ("char"), gh_int2scm (code));
at = fontify_atom (this, at);
Box b = get_indexed_char (code);
return Stencil (b, at);
}
+
+int
+/*Font_metric::*/
+get_encoded_index (Font_metric *m, String input_coding, int code)
+{
+ String font_coding = m->coding_scheme ();
+ if (font_coding == input_coding)
+ return code;
+ SCM s = scm_call_3 (ly_scheme_function ("encoded-index"),
+ scm_makfrom0str (input_coding.to_str0 ()),
+ scm_makfrom0str (font_coding.to_str0 ()),
+ scm_int2num (code));
+ return gh_scm2int (s);
+}
{
String msg = _f ("can't find file: `%s'", s);
msg += "\n";
- msg += _f ("(search path: `%s')", global_sources->path_C_->to_string ().to_str0 ());
+ msg += _f ("(search path: `%s')", global_sources->path_->to_string ().to_str0 ());
msg += "\n";
LexerError (msg.to_str0 ());
#include "font-metric.hh"
#include "parse-afm.hh"
-struct Adobe_font_metric : Simple_font_metric
+class Adobe_font_metric : public Simple_font_metric
{
- AFM_Font_info * font_inf_;
+public:
+ AFM_Font_info *font_info_;
+ unsigned int checksum_;
+ Real design_size_;
+
+ ~Adobe_font_metric ();
virtual int name_to_index (String) const;
virtual int count () const;
virtual Box get_ascii_char (int) const;
virtual Box get_indexed_char (int) const;
virtual Offset get_indexed_wxwy (int) const;
+ virtual String coding_scheme () const;
AFM_CharMetricInfo const *find_char_metric (String name) const;
AFM_CharMetricInfo const *find_ascii_metric (int) const;
String to_string () const;
- ~Adobe_font_metric ();
static SCM make_afm (AFM_Font_info*, unsigned, Real);
virtual Real design_size () const;
- unsigned int checksum_;
- Real design_size_;
protected:
Array<int> ascii_to_metric_idx_;
std::map<String,int> name_to_metric_dict_;
- virtual Stencil find_by_name (String) const;
-
Adobe_font_metric (AFM_Font_info*);
+ virtual Stencil find_by_name (String) const;
};
-SCM read_afm_file (String fn);
-Box afm_bbox_to_box (AFM_BBox bb);
+SCM read_afm_file (String);
+Box afm_bbox_to_box (AFM_BBox);
-
#endif /* AFM_HH */
{
public:
SCM description_;
- String path_;
+ String filename_;
virtual int count () const;
virtual Offset get_indexed_wxwy (int) const;
virtual Real design_size () const;
virtual Stencil find_by_name (String) const;
virtual Stencil get_indexed_char_stencil (int k) const;
- virtual Stencil get_ascii_char_stencil (int k) const;
+ virtual Stencil get_ascii_char_stencil (int k) const;
+ virtual String coding_scheme () const;
+ //static int get_encoded_index (Font_metric *m, String input_coding, int code);
DECLARE_SMOBS (Font_metric,);
+
private:
- Font_metric (Font_metric const&); // no copy.
+ /* No copying, no implicit copy constructor. */
+ Font_metric (Font_metric const&);
+
protected:
virtual void derived_mark () const;
Font_metric ();
};
+int get_encoded_index (Font_metric *m, String input_coding, int code);
+
struct Simple_font_metric : public Font_metric
{
public:
+/*
+ lily-guile.hh encapsulate guile
-#ifndef PARSE_SCM
-#define PARSE_SCM
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+*/
+
+#ifndef PARSE_SCM_HH
+#define PARSE_SCM_HH
#include "input.hh"
#include "lily-guile.hh"
SCM catch_protected_parse_body (void *);
SCM protected_ly_parse_scm (Parse_start *, bool);
-
SCM ly_parse_scm (char const *, int *, Input, bool);
-#endif
+#endif /* PARSE_SCM_HH */
#include "font-metric.hh"
-/*
- Perhaps junk this, and move this to paper_def as interface?
- */
+/* Perhaps junk this, and move this to paper_def as interface? */
struct Scaled_font_metric : public Font_metric
{
virtual Box text_dimension (String) const;
virtual int count () const;
virtual Offset get_indexed_wxwy (int) const;
virtual int name_to_index (String) const;
+ virtual String coding_scheme () const;
+
protected:
virtual Real design_size () const;
virtual Box get_indexed_char (int)const;
Font_metric *orig_;
Real magnification_;
- Scaled_font_metric (Font_metric*,Real);
+ Scaled_font_metric (Font_metric*, Real);
};
-#endif
+
+#endif /* SCALED_FONT_METRIC_HH */
#include "cons.hh"
#include "flower-proto.hh"
-/*
- a set of sourcefiles.
- */
+/* A set of sourcefiles. */
class Sources
{
Sources (Sources const&) {}
+ Cons<Source_file> *sourcefile_list_;
+ bool is_binary_;
+
public:
Sources ();
~Sources ();
- Source_file * get_file (String &filename );
- Source_file* get_sourcefile (char const* str0 );
+ Source_file *get_file (String &filename );
+ Source_file *get_sourcefile (char const*);
void add (Source_file* sourcefile );
- void set_path (File_path*p);
+ void set_path (File_path*);
void set_binary (bool);
- const File_path * path_C_;
-private:
- Cons<Source_file> *sourcefile_list_;
- bool is_binary_ ;
+ const File_path *path_;
};
-#endif // SOURCE_HH //
+#endif /* SOURCE_HH */
void read_char_metrics ();
Tex_font_char_metric read_char_metric (Char_code code);
Tex_font_char_metric read_char ();
- void read_lig_kern_program (Array<Tfm_ligature>* ligatures, Array <Tfm_kern>* kerns);
-
+ void read_lig_kern_program (Array<Tfm_ligature>* ligatures,
+ Array <Tfm_kern>* kerns);
Binary_source_file input_;
public:
Tex_font_metric_reader ( String name);
-
Tfm_info info_;
Tfm_header header_;
Array<Tex_font_char_metric> char_metrics_;
Array<int> ascii_to_metric_idx_;
};
-
#endif /* TFM_READER_HH */
struct Tex_font_char_metric
{
- bool exists_b_;
+ bool exists_;
Char_code code_;
Real width_, height_, depth_, italic_correction_;
Fix width_fix_, height_fix_, depth_fix_, italic_correction_fix_;
virtual int count () const;
virtual Box get_ascii_char (int) const;
virtual Real design_size () const;
+ virtual String coding_scheme () const;
Tex_font_char_metric const *find_ascii (int ascii, bool warn=true) const;
Tfm_header header_;
Array<Tex_font_char_metric> char_metrics_;
Array<int> ascii_to_metric_idx_;
+
private:
Tex_font_metric ();
};
class Virtual_font_metric : public Font_metric
{
SCM font_list_;
+
public:
SCM get_font_list () const;
Virtual_font_metric (SCM namelist);
virtual Offset get_indexed_wxwy (int) const;
virtual int name_to_index (String)const;
virtual Stencil find_by_name (String) const;
+ virtual String coding_scheme () const;
+
protected:
virtual void derived_mark () const;
};
#include <ctype.h>
#include "lily-proto.hh"
+#include "version.hh"
-/* macosx fix:
-
+/* MacOS S fix:
+ source-file.hh includes cmath which undefines isinf and isnan
- source-file.hh includes cmath which undefines isinf and isnan
+ FIXME: #ifdef MACOS_X?
*/
inline int my_isinf (Real r) { return isinf (r); }
inline int my_isnan (Real r) { return isnan (r); }
-
#include "libc-extension.hh"
#include "lily-guile.hh"
#include "main.hh"
LY_DEFINE (ly_gulp_file, "ly:gulp-file",
1, 0, 0, (SCM name),
- "Read the file @var{name}, and return its contents in a string. "
+ "Read the file @var{name}, and return its contents in a string. "
"The file is looked up using the search path.")
{
return scm_makfrom0str (gulp_file_to_string (ly_scm2string (name)).to_str0 ());
return false;
}
-
Direction
to_dir (SCM s)
{
- return SCM_INUMP (s) ? (Direction) gh_scm2int (s) : CENTER;
+ return SCM_INUMP (s) ? (Direction) gh_scm2int (s) : CENTER;
}
Interval
ly_scm2interval (SCM p)
{
- return Interval (gh_scm2double (ly_car (p)),
- gh_scm2double (ly_cdr (p)));
+ return Interval (gh_scm2double (ly_car (p)), gh_scm2double (ly_cdr (p)));
}
Drul_array<Real>
ly_scm2realdrul (SCM p)
{
- return Drul_array<Real> (gh_scm2double (ly_car (p)),
- gh_scm2double (ly_cdr (p)));
+ return Drul_array<Real> (gh_scm2double (ly_car (p)),
+ gh_scm2double (ly_cdr (p)));
}
SCM
ly_interval2scm (Drul_array<Real> i)
{
- return gh_cons (gh_double2scm (i[LEFT]),
- gh_double2scm (i[RIGHT]));
+ return gh_cons (gh_double2scm (i[LEFT]), gh_double2scm (i[RIGHT]));
}
-
-
-
bool
to_boolean (SCM s)
{
return gh_boolean_p (s) && gh_scm2bool (s);
}
-/*
- Appendable list L: the cdr contains the list, the car the last cons
- in the list.
- */
+/* Appendable list L: the cdr contains the list, the car the last cons
+ in the list. */
SCM
appendable_list ()
{
static void *
greet_sweep (void *dummy1, void *dummy2, void *dummy3)
{
- fprintf (stderr, "entering sweep\n");
+ fprintf (stderr, "entering sweep\n");
}
static void *
wave_sweep_goodbye (void *dummy1, void *dummy2, void *dummy3)
{
- fprintf (stderr, "leaving sweep\n");
+ fprintf (stderr, "leaving sweep\n");
}
#endif
-#include "version.hh"
LY_DEFINE (ly_version, "ly:version", 0, 0, 0, (),
"Return the current lilypond version as a list, e.g. @code{(1 3 127 uu1)}. ")
{
- char const* vs = "\'(" MAJOR_VERSION " " MINOR_VERSION " " PATCH_LEVEL " " MY_PATCH_LEVEL ")" ;
+ char const* vs = "\'(" MAJOR_VERSION " " MINOR_VERSION " " PATCH_LEVEL " " MY_PATCH_LEVEL ")" ;
return gh_eval_str ((char*)vs);
}
ly_deep_copy (SCM src)
{
if (gh_pair_p (src))
- {
- return gh_cons (ly_deep_copy (ly_car (src)), ly_deep_copy (ly_cdr (src)));
- }
+ return gh_cons (ly_deep_copy (ly_car (src)), ly_deep_copy (ly_cdr (src)));
else if (gh_vector_p (src))
{
- int l = SCM_VECTOR_LENGTH (src);
- SCM nv = scm_c_make_vector (l, SCM_UNDEFINED);
- for (int i =0 ; i< l ; i++)
+ int len = SCM_VECTOR_LENGTH (src);
+ SCM nv = scm_c_make_vector (len, SCM_UNDEFINED);
+ for (int i =0 ; i < len ; i++)
{
SCM si = gh_int2scm (i);
scm_vector_set_x (nv, si, ly_deep_copy (scm_vector_ref (src, si)));
}
}
- else
- return src;
-
return src;
}
SCM
ly_assoc_cdr (SCM key, SCM alist)
{
- if (gh_pair_p (alist)) {
+ if (gh_pair_p (alist))
+ {
SCM trykey = ly_caar (alist);
- if (gh_pair_p (trykey) && to_boolean (scm_equal_p (key,ly_cdr (trykey))))
- return ly_car (alist);
+ if (gh_pair_p (trykey) && to_boolean (scm_equal_p (key, ly_cdr (trykey))))
+ return ly_car (alist);
else
- return ly_assoc_cdr (key, ly_cdr (alist));
+ return ly_assoc_cdr (key, ly_cdr (alist));
}
- else
- return SCM_BOOL_F;
+ return SCM_BOOL_F;
}
-/*
- LIST has the form "sym1 sym2 sym3\nsym4\nsym5"
-
- i.e. \n and ' ' can be used interchangeably as separators.
- */
+/* LST has the form "sym1 sym2 sym3\nsym4\nsym5"
+ i.e. \n and ' ' can be used interchangeably as separators. */
SCM
-parse_symbol_list (const char * list)
+parse_symbol_list (char const *lst)
{
- char * s = strdup (list);
+ char *s = strdup (lst);
char *orig = s;
SCM create_list = SCM_EOL;
char * e = s + strlen (s) - 1;
while (e >= s && isspace (*e))
- *e -- = 0;
+ *e-- = 0;
for (char * p = s; *p; p++)
- {
- if (*p == '\n')
- *p = ' ' ;
- }
+ if (*p == '\n')
+ *p = ' ';
- if (!s[0] )
+ if (!s[0])
s = 0;
-
-
while (s)
{
return create_list;
}
-
SCM
-ly_truncate_list (int k, SCM l )
+ly_truncate_list (int k, SCM lst)
{
if (k == 0)
- {
- l = SCM_EOL;
- }
+ lst = SCM_EOL;
else
{
- SCM s = l;
+ SCM s = lst;
k--;
for (; gh_pair_p (s) && k--; s = ly_cdr (s))
;
if (gh_pair_p (s))
- {
- gh_set_cdr_x (s, SCM_EOL);
- }
+ gh_set_cdr_x (s, SCM_EOL);
}
- return l;
+ return lst;
}
-
String
print_scm_val (SCM val)
{
String realval = ly_scm2string (ly_write2scm (val));
if (realval.length () > 200)
- realval = realval.left_string (100) + "\n :\n :\n" + realval.right_string (100);
-
+ realval = realval.left_string (100)
+ + "\n :\n :\n"
+ + realval.right_string (100);
return realval;
}
return gh_append2 (list, scm_list_n (s, SCM_UNDEFINED));
}
-
/* Split list at member s, removing s.
- Return (BEFORE . AFTER) */
+ Return (BEFORE . AFTER) */
SCM
ly_split_list (SCM s, SCM list)
{
Slice s;
s.set_empty ();
for (; gh_pair_p (l); l = gh_cdr (l))
- {
- if (gh_number_p (gh_car (l)))
- s.add_point (gh_scm2int (gh_car (l)));
- }
-
+ if (gh_number_p (gh_car (l)))
+ s.add_point (gh_scm2int (gh_car (l)));
return s;
}
-
-/*
- Return I-th element, or last elt L. If I < 0, then we take the first
- element.
-
- PRE: length (L) > 0
- */
+/* Return I-th element, or last elt L. If I < 0, then we take the first
+ element.
+
+ PRE: length (L) > 0 */
SCM
robust_list_ref (int i, SCM l)
{
while (i-- > 0 && gh_pair_p (gh_cdr (l)))
l = gh_cdr (l);
-
return gh_car (l);
}
-
-
Real
robust_scm2double (SCM k, double x)
{
{
if (is_number_pair (k))
o = ly_scm2offset (k);
-
return o;
}
-
int
robust_scm2int (SCM k, int o)
{
if (scm_integer_p (k) == SCM_BOOL_T)
o = gh_scm2int (k);
-
return o;
}
-
SCM
alist_to_hashq (SCM alist)
{
header_ = scm_call_2 (make_header, paper_->self_scm (),
scm_int2num (number_));
- // FIXME: why does this (generates Stencil) not trigger font load?
if (get_header ())
get_header ()->align_to (Y_AXIS, UP);
-/*
- scaled-font-metric.cc -- declare Scaled_font_metric
+/*
+ scaled-font-metric.cc -- declare Scaled_font_metric
source file of the GNU LilyPond music typesetter
}
SCM
-Scaled_font_metric::make_scaled_font_metric (Font_metric*m, Real s)
+Scaled_font_metric::make_scaled_font_metric (Font_metric *m, Real s)
{
- Scaled_font_metric *sfm = new Scaled_font_metric (m,s);
+ Scaled_font_metric *sfm = new Scaled_font_metric (m, s);
return sfm->self_scm ();
}
Box b = m.extent_box ();
b.scale (magnification_);
Stencil q (b,fontify_atom ((Font_metric*) this, m.get_expr ()));
-
- return q ;
+ return q;
}
Box
Scaled_font_metric::text_dimension (String t) const
{
Box b (orig_->text_dimension (t));
-
b.scale (magnification_);
return b;
}
{
return orig_->name_to_index (s);
}
+
+String
+Scaled_font_metric::coding_scheme () const
+{
+ return orig_->coding_scheme ();
+}
+
Sources::Sources ()
{
sourcefile_list_ = 0;
- path_C_= 0;
+ path_= 0;
is_binary_ = false;
}
void
Sources::set_path (File_path *f)
{
- path_C_ = f;
+ path_ = f;
}
/**
Source_file*
Sources::get_file (String &file_string) //UGH
{
- if ((file_string != "-") && path_C_)
+ if ((file_string != "-") && path_)
{
- String file_string_o = path_C_->find (file_string);
+ String file_string_o = path_->find (file_string);
if ((file_string_o == "") && (file_string != ""))
return 0;
file_string = file_string_o;
for (int i = info_.first_charcode; i <= info_.last_charcode; i++)
{
Tex_font_char_metric tfm_char = read_char_metric (i);
- if (tfm_char.exists_b_)
+ if (tfm_char.exists_)
ascii_to_metric_idx_[tfm_char.code_] = char_metrics_.size ();
char_metrics_.push (tfm_char);
}
/* Read the character. */
tfm_char = read_char ();
- if (tfm_char.exists_b_)
+ if (tfm_char.exists_)
tfm_char.code_ = code;
return tfm_char;
the first and last character codes given in the header. We've
already assumed that's true (or we couldn't be positioned at a
`char_info_word'). */
- tfm_char.exists_b_ = width_index != 0;
+ tfm_char.exists_ = width_index != 0;
if (tag == 1)
{
source file of the GNU LilyPond music typesetter
(c) 1999--2004 Jan Nieuwenhuizen <janneke@gnu.org>
-
some code shamelessly copied from GNU fontutils-0.6/tfm/tfm_input.c
*/
#include "warn.hh"
#include "dimensions.hh"
+static Tex_font_char_metric dummy_static_char_metric;
+
+Tex_font_char_metric::Tex_font_char_metric ()
+{
+ exists_ = false;
+ code_ = 0;;
+ width_ = 0;
+ height_ = 0;
+ depth_ = 0;
+ italic_correction_ = 0;
+ width_fix_ = 0;
+ height_fix_ = 0;
+ depth_fix_ = 0;
+ italic_correction_fix_ = 0;
+}
+
Box
Tex_font_char_metric::dimensions () const
{
- if (!exists_b_)
+ if (!exists_)
{
Box b;
b.set_empty ();
(d >? height_)*point_constant));
}
-Tex_font_char_metric::Tex_font_char_metric ()
-{
- exists_b_ = false;
- code_ = 0;;
- width_ = 0;
- height_ = 0;
- depth_ = 0;
- italic_correction_ = 0;
- width_fix_ = 0;
- height_fix_ = 0;
- depth_fix_ = 0;
- italic_correction_fix_ = 0;
-}
-
-#define APPEND_CHAR_METRIC_ELT(k) outstr += ::to_string (#k) + " " + ::to_string (k ## _) + "; "
+#define APPEND_CHAR_METRIC_ELT(k) \
+ outstr += ::to_string (#k) + " " + ::to_string (k ## _) + "; "
String
Tex_font_char_metric::to_string () const
{
- String outstr ;
+ String outstr;
- APPEND_CHAR_METRIC_ELT (exists_b);
+ APPEND_CHAR_METRIC_ELT (exists);
APPEND_CHAR_METRIC_ELT (code);
APPEND_CHAR_METRIC_ELT (width);
APPEND_CHAR_METRIC_ELT (height);
{
}
-
-static Tex_font_char_metric dummy_static_char_metric;
-
Tex_font_char_metric const *
Tex_font_metric::find_ascii (int ascii, bool warn) const
{
- if (ascii >= 0 && ascii < ascii_to_metric_idx_.size () && ascii_to_metric_idx_[ascii] >= 0)
+ if (ascii >= 0 && ascii < ascii_to_metric_idx_.size ()
+ && ascii_to_metric_idx_[ascii] >= 0)
return & char_metrics_[ascii_to_metric_idx_ [ascii]];
else if (warn)
- {
- warning (_f ("can't find ascii character: %d", ascii));
- }
+ warning (_f ("can't find ascii character: %d", ascii));
return &dummy_static_char_metric;
}
-
-/*
- UGH: glyphs need not be consecutive in TFM.
- */
+/* UGH: glyphs need not be consecutive in TFM. */
int
Tex_font_metric::count () const
{
for (int i = ascii_to_metric_idx_.size (); i--;)
- {
- if (ascii_to_metric_idx_[i] != -1)
- return i + 1;
- }
+ if (ascii_to_metric_idx_[i] != -1)
+ return i + 1;
return 0;
}
Box
Tex_font_metric::get_ascii_char (int a) const
{
- Box b = find_ascii (a)->dimensions () ;
+ Box b = find_ascii (a)->dimensions ();
return b;
}
String outstr;
for (int i=0; i < char_metrics_.size (); i++)
outstr += char_metrics_[i].to_string ();
-
return outstr;
}
-
-
-
SCM
-Tex_font_metric::make_tfm (String fn)
+Tex_font_metric::make_tfm (String filename)
{
- Tex_font_metric * tfm = new Tex_font_metric;
- Tex_font_metric_reader reader (fn);
+ Tex_font_metric *tfm = new Tex_font_metric;
+ Tex_font_metric_reader reader (filename);
tfm->info_ = reader.info_;
tfm->header_ = reader.header_;
tfm->char_metrics_ = reader.char_metrics_;
tfm->ascii_to_metric_idx_ = reader.ascii_to_metric_idx_;
-
+
return tfm->self_scm ();
}
Real
-Tex_font_metric::design_size ()const
+Tex_font_metric::design_size () const
{
return info_.design_size;
}
+
+String
+Tex_font_metric::coding_scheme () const
+{
+ return info_.coding_scheme;
+}
for (SCM s = font_list; gh_pair_p (s); s = gh_cdr (s))
{
- if (Font_metric*fm = unsmob_metrics (gh_car (s)))
+ if (Font_metric *fm = unsmob_metrics (gh_car (s)))
{
*tail = scm_cons (gh_car (s),SCM_EOL);
tail = SCM_CDRLOC (*tail);
if (!gh_number_p (mag))
- {
- mag = gh_cdr (fm->description_); // ugh.
- }
+ /* Ugh. */
+ mag = gh_cdr (fm->description_);
*name_tail = scm_cons (gh_car (fm->description_), SCM_EOL);
name_tail = SCM_CDRLOC (*name_tail);
return unsmob_metrics (gh_car (font_list_))-> design_size ();
}
-
void
Virtual_font_metric::derived_mark ()const
{
{
int k = 0;
for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s))
- {
- k+= unsmob_metrics (gh_car (s))->count ();
- }
-
+ k += unsmob_metrics (gh_car (s))->count ();
return k;
}
return m;
}
-
-
Box
Virtual_font_metric::get_ascii_char (int) const
return Stencil ();
}
-
Offset
Virtual_font_metric::get_indexed_wxwy (int code) const
{
int total = 0;
for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s))
{
- Font_metric* fm = unsmob_metrics (gh_car (s));
+ Font_metric *fm = unsmob_metrics (gh_car (s));
if (code < total + fm->count ())
- {
- return fm->get_indexed_wxwy (code - total);
- }
+ return fm->get_indexed_wxwy (code - total);
total += fm->count ();
}
-
-
return Offset (0,0);
}
int total = 0;
for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s))
{
- Font_metric* fm = unsmob_metrics (gh_car (s));
+ Font_metric *fm = unsmob_metrics (gh_car (s));
if (code < total + fm->count ())
- {
- return fm->get_indexed_char (code - total);
- }
+ return fm->get_indexed_char (code - total);
total += fm->count ();
}
-
-
return Box ();
}
-
int
Virtual_font_metric::name_to_index (String glyph) const
{
total += m->count ();
}
-
return -1;
}
-
Stencil
Virtual_font_metric::get_indexed_char_stencil (int code) const
for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s))
{
- Font_metric* fm = unsmob_metrics (gh_car (s));
+ Font_metric *fm = unsmob_metrics (gh_car (s));
if (code < total + fm->count ())
{
- m = fm->get_indexed_char_stencil (code - total); // ugh.
+ /* Ugh. */
+ m = fm->get_indexed_char_stencil (code - total);
break;
}
total += fm->count ();
}
-
return m;
}
return scm_gc_unprotect_object (fm->self_scm ());
}
+
+String
+Virtual_font_metric::coding_scheme () const
+{
+ Font_metric *fm = unsmob_metrics (gh_car (font_list_));
+ return fm->coding_scheme ();
+}
(interpret-markup paper props
(make-word-markup str)))
-; todo: use font recoding.
-; (make-line-markup
-; (map make-word-markup (string-tokenize str)))))
+;; TODO: use font recoding.
+;; (make-line-markup
+;; (map make-word-markup (string-tokenize str)))))
(define-public empty-markup
(make-simple-markup ""))
;;;;;;;;;;;;;;;;
; alist
-(define (uniqued-alist alist acc)
- (if (null? alist) acc
- (if (assoc (caar alist) acc)
- (uniqued-alist (cdr alist) acc)
- (uniqued-alist (cdr alist) (cons (car alist) acc)))))
-
-
(define-public (assoc-get key alist . default)
"Return value if KEY in ALIST, else DEFAULT (or #f if not specified)."
(let ((entry (assoc key alist)))
(if (pair? entry)
(cdr entry)
- (if (pair? default) (car default) #f)
- )))
+ (if (pair? default) (car default) #f))))
-(define-public (uniqued-alist alist acc)
+(define-public (uniqued-alist alist acc)
(if (null? alist) acc
(if (assoc (caar alist) acc)
(uniqued-alist (cdr alist) acc)
"clef.scm"
"slur.scm"
"font.scm"
+ "encoding.scm"
"define-markup-commands.scm"
"define-grob-properties.scm"
"define-grobs.scm"
"define-grob-interfaces.scm"
-
"page-layout.scm"
"paper.scm"
))