block.
* lily/font-select.cc (select_encoded_font)
(get_font_by_mag_step, get_font_by_design_size):
* lily/modified-font-metric.cc (Modified_font_metric):
* lily/paper-def.cc (find_scaled_font): Add font_encoding parameter.
* scm/encoding.scm (coding-alist): Add fetaDynamic.
(read-encoding-file): Bugfix: do not require space after bracket.
* scm/font.scm (add-cork-lm-fonts): Remove unexistent fonts.
+2004-11-21 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ * lily/all-font-metrics.cc (find_font): Add "lm" to try-AFM-first
+ block.
+
+ * lily/font-select.cc (select_encoded_font)
+ (get_font_by_mag_step, get_font_by_design_size):
+ * lily/modified-font-metric.cc (Modified_font_metric):
+ * lily/paper-def.cc (find_scaled_font): Add font_encoding parameter.
+
+ * scm/encoding.scm (coding-alist): Add fetaDynamic.
+ (read-encoding-file): Bugfix: do not require space after bracket.
+
+ * scm/font.scm (add-cork-lm-fonts): Remove unexistent fonts.
+
2004-11-20 Graham Percival <gperlist@shaw.ca>
* Documentation/user/notation.itely: added info about typesetting
%%
\relative {
- a'2 ~ a4( e8[ )e] a,16[ a a a]
+ a'2 ~ a4( e8[) e] a,16[ a a a]
}
/*
-
all-font-metrics.cc -- implement All_font_metrics
source file of the GNU LilyPond music typesetter
(c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
+*/
#include "all-font-metrics.hh"
Font_metric*
All_font_metrics::find_font (String name)
{
- if ((name.left_string (4) == "feta") ||
- (name.left_string (8) == "parmesan"))
+ Font_metric *f = 0;
+ if ((name.left_string (4) == "feta")
+ || (name.left_string (8) == "parmesan")
+ || (name.left_string (2) == "lm"))
{
- Font_metric *f = find_afm (name);
- if (f)
- return f;
- else
- f =find_tfm (name);
- if (f)
- return f ;
+ f = find_afm (name);
+ if (!f)
+ f = find_tfm (name);
}
else
{
- Font_metric * f = find_tfm (name);
- if (f)
- return f;
- else
- f = find_afm (name);
- if (f)
- return f;
+ f = find_tfm (name);
+ if (!f)
+ f = find_afm (name);
}
- warning (_f ("can't find font: `%s'", name.to_str0 ()));
- warning (_ ("Loading default font"));
+ if (!f)
+ {
+ warning (_f ("can't find font: `%s'", name.to_str0 ()));
+ warning (_ ("Loading default font"));
+ }
String def_name = default_font_str0_;
- /*
- we're in emergency recovery mode here anyway, so don't try to do
- anything smart that runs the risk of failing. */
- Font_metric* f= find_afm (def_name);
- if (f)
- return f;
+ /* We're in emergency recovery mode here anyway, so don't try to do
+ anything smart that runs the risk of failing. */
+ if (!f)
+ f = find_afm (def_name);
- f = find_tfm (def_name);
- if (f)
- return f;
+ if (!f)
+ f = find_tfm (def_name);
- error (_f ("can't find default font: `%s'", def_name.to_str0 ()));
- error (_f ("(search path: `%s')", search_path_.to_string ()));
- error (_ ("Giving up"));
+ if (!f)
+ {
+ error (_f ("can't find default font: `%s'", def_name.to_str0 ()));
+ error (_f ("(search path: `%s')", search_path_.to_string ()));
+ error (_ ("Giving up"));
+ }
- return 0;
+ return f;
}
All_font_metrics *all_fonts_global;
-/*
+/*
font-select.cc -- implement property -> font_metric routines.
source file of the GNU LilyPond music typesetter
(c) 2003--2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
-
- */
+*/
#include <cmath>
*/
Font_metric *
get_font_by_design_size (Output_def *layout, Real requested,
- SCM font_vector, SCM input_encoding)
+ SCM font_vector,
+ SCM font_encoding, SCM input_encoding)
{
int n = SCM_VECTOR_LENGTH (font_vector);
Real size = 1e6;
Real last_size = -1e6;
int i = 0;
-
+
for (; i < n; i++)
{
SCM entry = SCM_VECTOR_REF (font_vector, i);
Font_metric *fm = unsmob_metrics (scm_force (entry));
size = fm->design_size ();
-
+
if (size > requested)
break;
- last_size = size;
+ last_size = size;
}
if (i == n)
Font_metric *fm = unsmob_metrics (scm_force (SCM_VECTOR_REF (font_vector,
i)));
- return find_scaled_font (layout, fm, requested / size, input_encoding);
+ return find_scaled_font (layout, fm, requested / size,
+ font_encoding, input_encoding);
}
-Font_metric*
+Font_metric *
get_font_by_mag_step (Output_def *layout, Real requested_step,
SCM font_vector, Real default_size,
- SCM input_encoding)
+ SCM font_encoding, SCM input_encoding)
{
return get_font_by_design_size (layout, default_size
* pow (2.0, requested_step / 6.0),
- font_vector, input_encoding);
+ font_vector, font_encoding, input_encoding);
}
SCM
Font_metric *
select_encoded_font (Output_def *layout, SCM chain, SCM input_encoding)
{
- SCM name = ly_assoc_chain (ly_symbol2scm ("font-name"), chain);
-
+ SCM name = ly_assoc_chain (ly_symbol2scm ("font-name"), chain);
+
if (!scm_is_pair (name) || !scm_is_string (scm_cdr (name)))
{
SCM fonts = layout->lookup_variable (ly_symbol2scm ("fonts"));
? robust_scm2double (scm_cdr (mag), 1.0)
: 1);
Font_metric *fm = all_fonts_global->find_font (ly_scm2string (name));
-
- return find_scaled_font (layout, fm, rmag, input_encoding);
+
+ SCM font_encoding
+ = scm_cdr (ly_assoc_chain (ly_symbol2scm ("font-encoding"), chain));
+ return find_scaled_font (layout, fm, rmag, font_encoding, input_encoding);
}
else if (scm_instance_p (name))
{
SCM base_size = scm_slot_ref (name, ly_symbol2scm ("default-size"));
SCM vec = scm_slot_ref (name, ly_symbol2scm ("size-vector"));
-
+
SCM font_size = ly_assoc_chain (ly_symbol2scm ("font-size"), chain);
Real req = 0;
if (scm_is_pair (font_size))
req = scm_to_double (scm_cdr (font_size));
+ SCM font_encoding
+ = scm_cdr (ly_assoc_chain (ly_symbol2scm ("font-encoding"), chain));
+
return get_font_by_mag_step (layout, req, vec, scm_to_double (base_size),
- input_encoding);
+ font_encoding, input_encoding);
}
assert (0);
Scheme_hash_table *afm_p_dict_;
Scheme_hash_table *tfm_p_dict_;
File_path search_path_;
+
public:
- ~All_font_metrics ();
+ All_font_metrics (String search_path);
+ ~All_font_metrics ();
+
Adobe_font_metric *find_afm (String name);
Tex_font_metric *find_tfm (String);
Font_metric *find_font (String name);
-
-
- All_font_metrics (String search_path);
-
SCM font_descriptions () const;
};
#ifndef GUILE_COMPATIBILITY_HH
#define GUILE_COMPATIBILITY_HH
-
-
#if SCM_MINOR_VERSION < 7
/* guile-1.6.x compatibility */
inline SCM scm_cdr (SCM x)
{
- if (SCM_NCONSP(x))
- abort();
+ if (SCM_NCONSP (x))
+ abort ();
return SCM_CDR (x);
}
inline SCM scm_car (SCM x)
{
- if (SCM_NCONSP(x))
- abort();
+ if (SCM_NCONSP (x))
+ abort ();
return SCM_CAR (x);
}
inline SCM scm_caar (SCM x) { return SCM_CAAR (x); }
inline SCM scm_cadar (SCM x) { return SCM_CADAR (x); }
#define scm_gc_unregister_collectable_memory(a, b, c) scm_done_free (b)
#define scm_gc_register_collectable_memory(a, b, c) scm_done_malloc (b)
-#define SCM_VECTOR_REF(v,i) (SCM_VELTS ((v))[(i)])
+#define SCM_VECTOR_REF(v, i) (SCM_VELTS ((v))[(i)])
#define scm_from_int(x) SCM_MAKINUM (x)
#define scm_is_integer(x) SCM_INUMP (x)
-#define scm_is_string(x) SCM_STRINGP(x)
+#define scm_is_string(x) SCM_STRINGP (x)
#define scm_hash_table_p scm_vector_p
-#define scm_i_string_chars(x) SCM_STRING_CHARS(x)
-#define scm_i_string_length(x) SCM_STRING_LENGTH(x)
+#define scm_i_string_chars(x) SCM_STRING_CHARS (x)
+#define scm_i_string_length(x) SCM_STRING_LENGTH (x)
inline bool ly_c_number_p (SCM x) { return SCM_NUMBERP (x); }
-#define scm_is_number(x) (scm_number_p(x)==SCM_BOOL_T)
+#define scm_is_number(x) (scm_number_p (x) == SCM_BOOL_T)
inline int ly_scm2int (SCM x) { return scm_num2int (x, 0, "ly_scm2int"); }
-#define scm_to_int(x) (ly_scm2int(x))
+#define scm_to_int(x) (ly_scm2int (x))
inline bool ly_c_symbol_p (SCM x) { return SCM_SYMBOLP (x); }
-#define scm_is_symbol(x) ly_c_symbol_p(x)
+#define scm_is_symbol(x) ly_c_symbol_p (x)
inline bool ly_c_boolean_p (SCM x) { return SCM_BOOLP (x); }
#define scm_is_bool(x) ly_c_boolean_p(x)
inline bool ly_c_eq_p (SCM x, SCM y) { return SCM_EQ_P (x, y); }
-#define scm_is_eq(x,y) (SCM_EQ_P((x), (y)))
+#define scm_is_eq(x,y) (SCM_EQ_P ((x), (y)))
-#define scm_c_string_length(x) SCM_STRING_LENGTH(x)
-#define scm_is_pair(x) (SCM_CONSP(x))
+#define scm_c_string_length(x) SCM_STRING_LENGTH (x)
+#define scm_is_pair(x) (SCM_CONSP (x))
inline double ly_scm2double (SCM x) { return scm_num2dbl (x, "ly_scm2double"); }
-#define scm_to_double(x) (ly_scm2double(x))
-#define scm_from_double(x) (scm_make_real(x))
-
-
+#define scm_to_double(x) (ly_scm2double (x))
+#define scm_from_double(x) (scm_make_real (x))
#endif /* SCM_MINOR_VERSION < 7 */
+
#endif /* GUILE_COMPATIBILITY_HH */
class String;
-String kpathsea_find_afm (char const * name);
-String kpathsea_find_tfm (char const * name);
+String kpathsea_find_afm (char const *name);
+String kpathsea_find_tfm (char const *name);
void initialize_kpathsea (char *av0);
#endif /* KPATH_HH */
public:
Box text_dimension (String);
-
- static SCM make_scaled_font_metric (SCM, Font_metric*, Real);
+ static SCM make_scaled_font_metric (Font_metric *fm, Real magnification,
+ SCM font_encoding, SCM input_encoding);
virtual int count () const;
virtual Offset get_indexed_wxwy (int) const;
virtual int name_to_index (String) const;
virtual String coding_scheme () const;
-
- virtual Font_metric * original_font () const;
+ virtual Font_metric *original_font () const;
protected:
-
SCM coding_vector_;
SCM coding_table_;
SCM coding_mapping_;
SCM coding_description_;
+ Font_metric *orig_;
+ Real magnification_;
+ String input_encoding_;
friend SCM ly_font_encoding_alist (SCM);
+ Modified_font_metric (Font_metric *fm, Real magnification,
+ String font_encoding, String input_encoding);
virtual Real design_size () const;
virtual void derived_mark () const;
virtual Box get_indexed_char (int) const;
virtual int index_to_ascii (int) const;
virtual Box get_ascii_char (int) const;
- Font_metric *orig_;
- Real magnification_;
- String coding_scheme_;
-
-
- Modified_font_metric (String, Font_metric*, Real);
Box tex_kludge (String) const;
};
DECLARE_UNSMOB (Output_def, output_def);
-Font_metric *find_scaled_font (Output_def * od,
- Font_metric *f, Real m, SCM input_enc_name);
+Font_metric *find_scaled_font (Output_def *od,
+ Font_metric *f, Real magnification,
+ SCM font_encoding, SCM input_encoding);
Output_def *scale_output_def (Output_def *def, Real scale);
Real output_scale (Output_def*);
#include "warn.hh"
String
-kpathsea_find_afm (char const * name)
+kpathsea_find_afm (char const *name)
{
#if (KPATHSEA && HAVE_KPSE_FIND_FILE)
- char * name_ptr = kpse_find_file (name, kpse_afm_format, false);
- if (!name_ptr)
- {
- /*
- don't mutter about afms, since we try to find them first, and lots of
- TFMs don't have AFMs.
- */
- // warning (_f ("kpathsea couldn't find AFM file `%s'", name));
- }
- else
- return name_ptr;
-
+ if (char *afm = kpse_find_file (name, kpse_afm_format, false))
+ return afm;
+#if 0 /* Do not mutter about afms, since we try to find them first, and
+ lots of TFMs don't have AFMs. */
+ warning (_f ("kpathsea can not find AFM file `%s'", name));
+#endif
#endif
return "";
}
but we assume that if there is a .PFA, there is also a .TFM,
and it's no use generating TFMs on the fly, because PFAs cannot
be generated on the fly. */
- char *p = kpse_find_file (name, kpse_tfm_format, false);
- if (!p)
- warning (_f ("kpathsea can not find TFM file: `%s'", name));
- else
- file_name = p;
+ if (char *tfm = kpse_find_file (name, kpse_tfm_format, false))
+ return tfm;
+ warning (_f ("kpathsea can not find TFM file: `%s'", name));
}
#endif
return file_name;
#include "warn.hh"
#include "stencil.hh"
-Modified_font_metric::Modified_font_metric (String input_encoding,
- Font_metric *m, Real magn)
+Modified_font_metric::Modified_font_metric (Font_metric *fm,
+ Real magnification,
+ String font_encoding,
+ String input_encoding)
{
- /* UGR, FIXME:
-
- THIS.coding_scheme == input encoding.
- ORIG.coding_scheme () == font_encoding.
-
- encoding is hairy enough by itself, should fix treacherous naming. */
-
- coding_scheme_ = input_encoding;
-
+ input_encoding_ = input_encoding;
coding_vector_ = SCM_EOL;
coding_mapping_ = SCM_EOL;
coding_table_ = SCM_EOL;
coding_description_ = SCM_EOL;
+ magnification_ = magnification;
- magnification_ = magn;
-
- SCM desc = m->description_;
+ SCM desc = fm->description_;
- Real total_mag = magn * scm_to_double (scm_cdr (desc));
+ Real total_mag = magnification * scm_to_double (scm_cdr (desc));
assert (total_mag);
description_ = scm_cons (scm_car (desc), scm_make_real (total_mag));
- orig_ = m;
-
- if (coding_scheme_ != ""
- && coding_scheme_ != "TeX"
- && coding_scheme_ != "ASCII"
- && coding_scheme_ != orig_->coding_scheme ())
+ orig_ = fm;
+
+ String metric_coding = orig_->coding_scheme ();
+ if (metric_coding != "FontSpecific"
+ && metric_coding != font_encoding)
+ warning (_f ("conflicting metric coding (%s) and font_encoding (%s)",
+ metric_coding, font_encoding));
+
+ if (input_encoding_ != ""
+ && input_encoding_ != "TeX"
+ && input_encoding_ != "ASCII"
+ && input_encoding_ != font_encoding)
{
- /* FIXME: this is broken, cannot get font encoding from font/AFM file,
- should use encoding from font-tree in fonts.scm. */
-
- coding_vector_
- = scm_call_1 (ly_scheme_function ("get-coding-vector"),
- scm_makfrom0str (coding_scheme_.to_str0 ()));
+ coding_vector_ = scm_call_1 (ly_scheme_function ("get-coding-vector"),
+ scm_makfrom0str (font_encoding.to_str0 ()));
if (!ly_c_vector_p (coding_vector_))
{
coding_vector_ = scm_c_make_vector (256, ly_symbol2scm (".notdef"));
}
- coding_table_
- = scm_call_1 (ly_scheme_function ("get-coding-table"),
- scm_makfrom0str (orig_->coding_scheme ().to_str0 ()));
+ coding_table_ = scm_call_1 (ly_scheme_function ("get-coding-table"),
+ scm_makfrom0str (font_encoding.to_str0 ()));
coding_mapping_
= scm_call_2 (ly_scheme_function ("make-encoding-mapping"),
coding_description_ = SCM_EOL;
coding_description_
= scm_acons (ly_symbol2scm ("input-name"),
- scm_makfrom0str (coding_scheme_.to_str0 ()),
+ scm_makfrom0str (input_encoding_.to_str0 ()),
coding_description_);
coding_description_
= scm_acons (ly_symbol2scm ("input-vector"),
coding_description_);
}
}
+
SCM
-Modified_font_metric::make_scaled_font_metric (SCM coding,
- Font_metric *m, Real s)
+Modified_font_metric::make_scaled_font_metric (Font_metric *fm, Real scaling,
+ SCM font_encoding,
+ SCM input_encoding)
{
/*
UGH.
*/
- if (scm_is_symbol (coding))
- coding = scm_symbol_to_string (coding);
-
- String scheme = scm_is_string (coding) ? ly_scm2string (coding) : "";
+ if (scm_is_symbol (input_encoding))
+ input_encoding = scm_symbol_to_string (input_encoding);
- Modified_font_metric *sfm = new Modified_font_metric (scheme, m, s);
+ String font_encoding_str = ly_symbol2string (font_encoding);
+ String input_encoding_str
+ = scm_is_string (input_encoding) ? ly_scm2string (input_encoding) : "";
+ Modified_font_metric *sfm = new Modified_font_metric (fm, scaling,
+ font_encoding_str,
+ input_encoding_str);
return sfm->self_scm ();
}
String
Modified_font_metric::coding_scheme () const
{
- return coding_scheme_;
+ return input_encoding_;
}
void
Modified_font_metric::text_dimension (String text)
{
Box b;
- if (coding_scheme_ == "TeX")
+ if (input_encoding_ == "TeX")
b = tex_kludge (text);
- else if (coding_scheme_ == "ASCII"
- || coding_scheme_ == ""
- || coding_scheme_ == orig_->coding_scheme ())
+ else if (input_encoding_ == "ASCII"
+ || input_encoding_ == ""
+ || input_encoding_ == orig_->coding_scheme ())
{
Interval ydims;
/* TODO: should add nesting for Output_def here too. */
Font_metric *
-find_scaled_font (Output_def *mod,
- Font_metric *f, Real m, SCM input_enc_name)
+find_scaled_font (Output_def *mod, Font_metric *f, Real m,
+ SCM font_encoding, SCM input_encoding)
{
if (mod->parent_)
- return find_scaled_font (mod->parent_, f, m, input_enc_name);
+ return find_scaled_font (mod->parent_, f, m, font_encoding, input_encoding);
Real lookup_mag = m;
if (!dynamic_cast<Virtual_font_metric*> (f))
SCM *t = &lst;
for (SCM s = vf->get_font_list (); scm_is_pair (s); s = scm_cdr (s))
{
- Font_metric *scaled = find_scaled_font (mod,
- unsmob_metrics (scm_car (s)),
- m, input_enc_name);
+ Font_metric *scaled
+ = find_scaled_font (mod, unsmob_metrics (scm_car (s)), m,
+ font_encoding, input_encoding);
*t = scm_cons (scaled->self_scm (), SCM_EOL);
t = SCM_CDRLOC (*t);
}
val = vf->self_scm ();
}
else
- {
- val = Modified_font_metric::make_scaled_font_metric (input_enc_name,
- f, lookup_mag);
- }
+ val = Modified_font_metric::make_scaled_font_metric (f, lookup_mag,
+ font_encoding,
+ input_encoding);
sizes = scm_acons (scm_make_real (lookup_mag), val, sizes);
scm_gc_unprotect_object (val);
(raw (ly:gulp-file path))
(string (regexp-substitute/global #f "%[^\n]*" raw 'pre "" 'post))
(command (match:substring
- (string-match "/([^ \t\n\r]*)[ \t\n\r]+[[]" string) 1))
+ (string-match "/([^ \t\n\r]*)[ \t\n\r]*[[]" string) 1))
(encoding (match:substring (string-match "[[](.*)[]]" string) 1))
(ps-lst (string-tokenize encoding))
(lst (map (lambda (x) (string->symbol (substring x 1))) ps-lst))
(map (lambda (x)
(cons (car x)
(cons (cdr x) (delay (get-coding-from-file (cdr x))))))
-
'(
;; teTeX font (output) encodings
("TeX-typewriter-text" . "09fbbfac.enc") ;; cmtt10
;; LilyPond FETA music font
("fetaBraces" . "feta-braces-a.enc")
+ ("fetaDynamic" . "feta-din10.enc")
("fetaNumber" . "feta-nummer10.enc")
("fetaMusic" . "feta20.enc")
("parmesanMusic" . "parmesan20.enc"))
(define-public (decode-byte-string encoding-name str)
"Return vector of glyphname symbols that correspond to string,
assuming that STR is byte-coded using ENCODING-NAME."
-
- (let*
- ((coding-vector (get-coding-vector encoding-name))
- (len (string-length str))
- (output-vector (make-vector len '.notdef))
- )
+ (let* ((coding-vector (get-coding-vector encoding-name))
+ (len (string-length str))
+ (output-vector (make-vector len '.notdef)))
(do
((idx 0 (1+ idx)))
((>= idx len) output-vector)
(vector-set! output-vector idx
(vector-ref coding-vector
- (char->integer (string-ref str idx))))
- )))
+ (char->integer (string-ref str idx)))))))
. (10.0 . #(,(delay (ly:font-load "lmri7"))
,(delay (ly:font-load "lmri10"))
,(delay (ly:font-load "lmri12")))))
- (#(roman italic bold)
- . (10.0 . #(,(delay (ly:font-load "lmbxi8"))
- ,(delay (ly:font-load "lmbxi10"))
- ,(delay (ly:font-load "lmbi14")))))
- (#(roman caps medium)
+ (#(roman italic bold)
+ . (10.0 . #(,(delay (ly:font-load "lmbxi10")))))
+ (#(roman caps medium)
. (10.0 . #(,(delay (ly:font-load "lmcsc10")))))
(#(roman upright bold-narrow )
. (10.0 . #(,(delay (ly:font-load "lmb10")))))