find absolute path files.
* lily/pango-select.cc: new file.
* scm/framework-ps.scm: remove all encoding code.
load pfb/pfa for PangoFont too.
* lily/lily-guile.cc (ly_chain_assoc_get): new function.
+2004-12-25 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * scm/framework-ps.scm: remove all encoding code.
+ load pfb/pfa for PangoFont too.
+
+ * lily/lily-guile.cc (ly_chain_assoc_get): new function.
+
2004-12-22 Werner Lemberg <wl@gnu.org>
Prepare glyph shapes for mf2pt1 conversion.
@item -f,--format=@var{format}
-A comma separated list of back-end output formats to use. Choices are
+the output format to use for the back-end. Choices are
@table @code
@item tex
for @TeX{} output, to be processed with La@TeX{}
for PostScript
@cindex PostScript output
@item svg
- for SVG (Scalable Vector Graphics.)
+ for SVG (Scalable Vector Graphics)
@cindex SVG (Scalable Vector Graphics)
@item scm
for a dump of the raw, internal Scheme-based drawing commands.
PACKAGE_NAME=LilyPond
MAJOR_VERSION=2
MINOR_VERSION=5
-PATCH_LEVEL=4
+PATCH_LEVEL=5
MY_PATCH_LEVEL=
/* define if you have pango 1.6 */
#define HAVE_PANGO16 0
+/* define if you have pango FT2 binding */
+#define HAVE_PANGO_FT2 0
+
/* define if you have pango_fc_font_map_add_decoder_find_func */
#define HAVE_PANGO_FC_FONT_MAP_ADD_DECODER_FIND_FUNC 0
{
if (!name.length () || (name == "-") )
return name;
- int n = size ();
- for (int i = 0; i < n; i++)
+
+ /*
+ TODO: should check for absolute path
+ */
+ if (FILE *f =fopen (name.to_str0 (), "r"))
+ {
+ fclose (f);
+ return name;
+ }
+
+ for (int i = 0; i < size (); i++)
{
String file_name = elem (i);
String sep = ::to_string (DIRSEP);
tfm_dict_ = new Scheme_hash_table;
otf_dict_ = new Scheme_hash_table;
-#ifdef HAVE_PANGO16
+#if HAVE_PANGO_FT2
PangoFontMap*pfm = pango_ft2_font_map_new ();
pango_ft2_fontmap_ =
{
}
-#ifdef HAVE_PANGO16
+#if HAVE_PANGO_FT2
Pango_font *
All_font_metrics::find_pango_font (PangoFontDescription*description)
{
{
Font_metric *fm = unsmob_metrics (font);
SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
- return scm_car (fm->description_);
+ return fm->font_file_name();
+}
+
+SCM
+Font_metric::font_file_name () const
+{
+ return scm_car (description_);
}
String
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_chain_assoc (ly_symbol2scm ("font-name"), chain);
if (!scm_is_pair (name) || !scm_is_string (scm_cdr (name)))
{
if (scm_is_string (name))
{
- SCM mag = ly_assoc_chain (ly_symbol2scm ("font-magnification"), chain);
+ SCM mag = ly_chain_assoc (ly_symbol2scm ("font-magnification"), chain);
Real rmag = (scm_is_pair (mag)
? robust_scm2double (scm_cdr (mag), 1.0)
: 1);
Font_metric *fm = all_fonts_global->find_font (ly_scm2string (name));
SCM font_encoding
- = scm_cdr (ly_assoc_chain (ly_symbol2scm ("font-encoding"), chain));
+ = scm_cdr (ly_chain_assoc (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);
+ SCM font_size = ly_chain_assoc (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));
+ = scm_cdr (ly_chain_assoc (ly_symbol2scm ("font-encoding"), chain));
return get_font_by_mag_step (layout, req, vec, scm_to_double (base_size),
font_encoding, input_encoding);
virtual Stencil get_ascii_char_stencil (int k) const;
virtual String coding_scheme () const;
virtual SCM sub_fonts () const;
-
+ virtual SCM font_file_name () const;
DECLARE_SMOBS (Font_metric,);
private:
String ly_symbol2string (SCM);
SCM ly_offset2scm (Offset);
Offset ly_scm2offset (SCM);
-SCM ly_assoc_chain (SCM key, SCM achain);
+SCM ly_chain_assoc (SCM key, SCM achain);
+SCM ly_chain_assoc_get (SCM key, SCM achain, SCM dfault);
SCM ly_assoc_cdr (SCM key, SCM alist);
SCM ly_assoc_get (SCM key, SCM alist, SCM def);
Interval ly_scm2interval (SCM);
void set_variable (SCM sym, SCM val);
Real get_dimension (SCM symbol) const;
};
-
+SCM get_font_table (Output_def *def);
void assign_context_def (Output_def *m, SCM transdef);
SCM find_context_def (Output_def const *m, SCM name);
PangoContext *context_;
PangoAttrList *attribute_list_;
Real scale_;
+ SCM subfonts_;
public:
+ virtual SCM sub_fonts () const;
+ SCM font_file_name () const;
+ virtual void derived_mark () const;
+ void register_font_file (String, String);
Stencil text_stencil (String) const;
Pango_font (PangoFT2FontMap *,
int dpi,
SCM variant,
SCM weight,
SCM stretch,
- SCM size);
+ Real size);
+
+Font_metric *
+select_pango_font (Output_def *layout, SCM chain);
#endif
#endif /* PANGO_FONT_HH */
return src;
}
-
-
+SCM
+ly_chain_assoc_get (SCM key, SCM achain, SCM dfault)
+{
+ if (scm_is_pair (achain))
+ {
+ SCM handle = scm_assoc (key, scm_car (achain));
+ if (scm_is_pair (handle))
+ return scm_cdr (handle);
+ else
+ return ly_chain_assoc (key, scm_cdr (achain));
+ }
+ else
+ return dfault;
+}
SCM
-ly_assoc_chain (SCM key, SCM achain)
+ly_chain_assoc (SCM key, SCM achain)
{
if (scm_is_pair (achain))
{
if (scm_is_pair (handle))
return handle;
else
- return ly_assoc_chain (key, scm_cdr (achain));
+ return ly_chain_assoc (key, scm_cdr (achain));
}
else
return SCM_BOOL_F;
*/
-#include <pango/pangoft2.h>
-
-#include "pango-font.hh"
-#include "stencil.hh"
-
-PangoStyle
-symbol_to_pango_style (SCM style)
-{
- PangoStyle pstyle = PANGO_STYLE_NORMAL;
- if (style == ly_symbol2scm ("italic"))
- {
- pstyle = PANGO_STYLE_NORMAL;
- }
- else if (style == ly_symbol2scm ("oblique")
- || style == ly_symbol2scm ("slanted")
- )
- {
- pstyle = PANGO_STYLE_OBLIQUE;
- }
-
- return pstyle;
-}
-PangoVariant
-symbol_to_pango_variant (SCM variant)
-{
- PangoVariant pvariant;
- if (variant == ly_symbol2scm ("caps"))
- {
- pvariant = PANGO_VARIANT_SMALL_CAPS;
- }
- return pvariant;
-}
-
-
-PangoWeight
-symbol_to_pango_weight (SCM weight)
-{
- PangoWeight pw = PANGO_WEIGHT_NORMAL;
- if (weight == ly_symbol2scm ("bold"))
- {
- pw = PANGO_WEIGHT_BOLD;
- }
- if (weight == ly_symbol2scm ("heavy"))
- {
- pw = PANGO_WEIGHT_HEAVY;
- }
- if (weight == ly_symbol2scm ("ultrabold"))
- {
- pw = PANGO_WEIGHT_ULTRABOLD;
- }
- if (weight == ly_symbol2scm ("light"))
- {
- pw = PANGO_WEIGHT_LIGHT;
- }
- if (weight == ly_symbol2scm ("ultralight"))
- {
- pw = PANGO_WEIGHT_ULTRALIGHT;
- }
-
- return pw;
-}
+#define PANGO_ENABLE_BACKEND // ugh, why necessary?
-PangoStretch
-symbol_to_pango_stretch (SCM stretch)
-{
- PangoStretch ps = PANGO_STRETCH_NORMAL;
-
- /*
- // TODO
-
- PANGO_STRETCH_ULTRA_CONDENSED,
- PANGO_STRETCH_EXTRA_CONDENSED,
- PANGO_STRETCH_CONDENSED,
- PANGO_STRETCH_SEMI_CONDENSED,
-
- PANGO_STRETCH_SEMI_EXPANDED,
- PANGO_STRETCH_EXPANDED,
- PANGO_STRETCH_EXTRA_EXPANDED,
- PANGO_STRETCH_ULTRA_EXPANDED
- */
- return ps;
-}
+#include <pango/pangoft2.h>
+#include "pango-font.hh"
+#if HAVE_PANGO_FT2
+#include "stencil.hh"
-PangoFontDescription*
-symbols_to_pango_font_description(SCM family,
- SCM style,
- SCM variant,
- SCM weight,
- SCM stretch,
- SCM size)
-{
- PangoFontDescription * description = pango_font_description_new ();
-
- pango_font_description_set_family (description,
- ly_symbol2string (family).to_str0 ());
- pango_font_description_set_style (description,
- symbol_to_pango_style (style));
- pango_font_description_set_variant (description,
- symbol_to_pango_variant (variant));
- pango_font_description_set_weight (description,
- symbol_to_pango_weight (weight));
- pango_font_description_set_stretch (description,
- symbol_to_pango_stretch (stretch));
- pango_font_description_set_size (description,
- gint (scm_to_double (size) * PANGO_SCALE));
-
- return description;
-}
Pango_font::Pango_font (PangoFT2FontMap *fontmap,
int resolution,
Direction dir,
PangoFontDescription * description)
{
+ subfonts_ = SCM_EOL;
PangoDirection pango_dir = (dir==RIGHT)
? PANGO_DIRECTION_LTR
: PANGO_DIRECTION_RTL;
context_ = pango_ft2_font_map_create_context (fontmap);
attribute_list_= pango_attr_list_new();
- scale_ = PANGO_SCALE * resolution * 72.27;
+ scale_ = 1.0 / (PANGO_SCALE * resolution * 72.27);
pango_context_set_language (context_, pango_language_from_string ("en_US"));
pango_context_set_base_dir (context_, pango_dir);
pango_context_set_font_description (context_, description);
}
+
Pango_font::~Pango_font ()
{
g_object_unref (context_);
pango_attr_list_unref (attribute_list_);
}
+void
+Pango_font::register_font_file (String filename, String ps_name)
+{
+ subfonts_ = scm_cons (//scm_cons (scm_makfrom0str (ps_name.to_str0 ()),
+ scm_makfrom0str (filename.to_str0 ()),
+ subfonts_);
+}
+void
+Pango_font::derived_mark () const
+{
+ scm_gc_mark (subfonts_);
+}
Stencil
Pango_font::text_stencil (String str) const
{
const int GLYPH_NAME_LEN = 256;
char glyph_name[GLYPH_NAME_LEN];
- Box dest_extent;
- dest_extent.set_empty ();
GList * ptr = items;
- SCM glyph_exprs = SCM_EOL;
+ Stencil dest;
while (ptr)
{
PangoItem *item = (PangoItem*) ptr->data;
PangoAnalysis *pa = &(item->analysis);
PangoGlyphString *pgs = pango_glyph_string_new();
+
pango_shape (str.to_str0 (), str.length (), pa, pgs);
PangoRectangle logical_rect;
b.translate (Offset (- logical_rect.x, -logical_rect.y));
b.scale (scale_);
- dest_extent.unite (b);
-
+
+ SCM glyph_exprs = SCM_EOL;
+ SCM *tail = &glyph_exprs;
for (int i = 0; i < pgs->num_glyphs; i++)
{
PangoGlyphInfo *pgi = pgs->glyphs + i;
PangoGlyphGeometry ggeo = pgi->geometry;
FT_Get_Glyph_Name (ftface, pg, glyph_name, GLYPH_NAME_LEN);
- glyph_exprs = scm_cons (scm_list_5 (ly_symbol2scm ("named-ps-glyph"),
- scm_from_int (ggeo.x_offset),
- scm_from_int (ggeo.y_offset),
- scm_makfrom0str (glyph_name),
- scm_makfrom0str (FT_Get_Postscript_Name (ftface))),
- glyph_exprs);
+ *tail = scm_cons (scm_list_3 (scm_from_double (ggeo.x_offset * scale_),
+ scm_from_double (ggeo.y_offset * scale_),
+ scm_makfrom0str (glyph_name)),
+ SCM_EOL);
+ tail = SCM_CDRLOC(*tail);
}
+ FcPattern *fcpat = fcfont->font_pattern;
+ char *filename = 0;
+ FcPatternGetString(fcpat, FC_FILE, 0, (FcChar8 **) &filename);
+ char const *ps_name = FT_Get_Postscript_Name (ftface);
+ ((Pango_font *) this)->register_font_file (filename, ps_name);
+
+ SCM expr = scm_list_3 (ly_symbol2scm ("glyph-string"),
+ scm_makfrom0str (ps_name),
+ ly_quote_scm (glyph_exprs));
+
+ Stencil item_stencil (b, expr);
+
+ dest.add_stencil (item_stencil);
+
+ pango_fc_font_unlock_face (fcfont);
ptr = ptr->next;
}
- Stencil dest (dest_extent,
- scm_cons (ly_symbol2scm ("combine-stencil"),
- glyph_exprs));
return dest;
}
+
+SCM
+Pango_font::sub_fonts () const
+{
+ return subfonts_;
+}
+
+SCM
+Pango_font::font_file_name () const
+{
+ return SCM_BOOL_F;
+}
+
+LY_DEFINE(ly_pango_font_p, "ly:pango-font?",
+ 1,0,0,
+ (SCM f),
+ "Is @var{f} a pango font?")
+
+{
+ return scm_from_bool (dynamic_cast<Pango_font*> (unsmob_metrics (f)));
+}
+
+#endif
--- /dev/null
+/*
+ pango-select.cc -- implement lily font selection for Pango_fonts.
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+#include <math.h>
+
+#include "all-font-metrics.hh"
+#include "output-def.hh"
+#include "pango-font.hh"
+
+Font_metric *
+select_pango_font (Output_def *layout, SCM chain)
+{
+ SCM name = ly_chain_assoc (ly_symbol2scm ("font-name"), chain);
+
+ PangoFontDescription *description = 0;
+ if (scm_is_pair (name) && scm_is_string (scm_cdr (name)))
+ {
+ String name_str = ly_scm2string (scm_cdr (name));
+ description = pango_font_description_from_string (name_str.to_str0 ());
+ }
+ else
+ {
+ SCM family = ly_chain_assoc_get (ly_symbol2scm ("font-family"), chain,
+ SCM_BOOL_F);
+ SCM variant = ly_chain_assoc_get (ly_symbol2scm ("font-shape"), chain,
+ SCM_BOOL_F);
+
+ SCM style = ly_chain_assoc_get (ly_symbol2scm ("font-shape"), chain,
+ SCM_BOOL_F);
+ SCM weight = ly_chain_assoc_get (ly_symbol2scm ("font-series"), chain,
+ SCM_BOOL_F);
+
+ Real step = robust_scm2double (ly_symbol2scm ("font-size"), 0.0);
+ Real size = layout->get_dimension (ly_symbol2scm ("text-font-size"))
+ * pow (2.0, step / 6.0);
+
+ description
+ = symbols_to_pango_font_description (family, style, variant, weight,
+ SCM_BOOL_F,
+ size);
+ }
+
+ Font_metric * fm = all_fonts_global->find_pango_font (description);
+
+ /*
+ Klutz the pango font into font table, otherwise it doesn't show up
+ in the output.
+ */
+ SCM font_table = get_font_table (layout);
+ SCM sizes = scm_hashq_ref (font_table, fm->self_scm (), SCM_BOOL_F);
+ if (sizes != SCM_BOOL_F)
+ {
+ SCM met = scm_assoc (scm_make_real (1.0), sizes);
+ if (scm_is_pair (met))
+ return unsmob_metrics (scm_cdr (met));
+ }
+ else
+ sizes = SCM_EOL;
+
+ sizes = scm_acons (scm_make_real (1.0), fm->self_scm(), sizes);
+ scm_hashq_set_x (font_table, fm->self_scm (), sizes);
+
+ return fm;
+}
+
+
+PangoStyle
+symbol_to_pango_style (SCM style)
+{
+ PangoStyle pstyle = PANGO_STYLE_NORMAL;
+ if (style == ly_symbol2scm ("italic"))
+ {
+ pstyle = PANGO_STYLE_NORMAL;
+ }
+ else if (style == ly_symbol2scm ("oblique")
+ || style == ly_symbol2scm ("slanted")
+ )
+ {
+ pstyle = PANGO_STYLE_OBLIQUE;
+ }
+
+ return pstyle;
+}
+
+PangoVariant
+symbol_to_pango_variant (SCM variant)
+{
+ PangoVariant pvariant;
+ if (variant == ly_symbol2scm ("caps"))
+ {
+ pvariant = PANGO_VARIANT_SMALL_CAPS;
+ }
+ return pvariant;
+}
+
+
+PangoWeight
+symbol_to_pango_weight (SCM weight)
+{
+ PangoWeight pw = PANGO_WEIGHT_NORMAL;
+ if (weight == ly_symbol2scm ("bold"))
+ {
+ pw = PANGO_WEIGHT_BOLD;
+ }
+ if (weight == ly_symbol2scm ("heavy"))
+ {
+ pw = PANGO_WEIGHT_HEAVY;
+ }
+ if (weight == ly_symbol2scm ("ultrabold"))
+ {
+ pw = PANGO_WEIGHT_ULTRABOLD;
+ }
+ if (weight == ly_symbol2scm ("light"))
+ {
+ pw = PANGO_WEIGHT_LIGHT;
+ }
+ if (weight == ly_symbol2scm ("ultralight"))
+ {
+ pw = PANGO_WEIGHT_ULTRALIGHT;
+ }
+
+ return pw;
+}
+
+PangoStretch
+symbol_to_pango_stretch (SCM) // stretch)
+{
+ PangoStretch ps = PANGO_STRETCH_NORMAL;
+
+ /*
+ // TODO
+
+ PANGO_STRETCH_ULTRA_CONDENSED,
+ PANGO_STRETCH_EXTRA_CONDENSED,
+ PANGO_STRETCH_CONDENSED,
+ PANGO_STRETCH_SEMI_CONDENSED,
+
+ PANGO_STRETCH_SEMI_EXPANDED,
+ PANGO_STRETCH_EXPANDED,
+ PANGO_STRETCH_EXTRA_EXPANDED,
+ PANGO_STRETCH_ULTRA_EXPANDED
+ */
+ return ps;
+}
+
+
+
+PangoFontDescription*
+symbols_to_pango_font_description(SCM family,
+ SCM style,
+ SCM variant,
+ SCM weight,
+ SCM stretch,
+ Real size)
+{
+ PangoFontDescription * description = pango_font_description_new ();
+
+ String family_str = scm_is_symbol (family)
+ ? ly_symbol2string (family)
+ : String("roman");
+ pango_font_description_set_family (description,
+ family_str.to_str0 ());
+ pango_font_description_set_style (description,
+ symbol_to_pango_style (style));
+ pango_font_description_set_variant (description,
+ symbol_to_pango_variant (variant));
+ pango_font_description_set_weight (description,
+ symbol_to_pango_weight (weight));
+ pango_font_description_set_stretch (description,
+ symbol_to_pango_stretch (stretch));
+ pango_font_description_set_size (description,
+ gint (size * PANGO_SCALE));
+
+ return description;
+}
#include "ly-module.hh"
#include "output-def.hh"
#include "modified-font-metric.hh"
+#include "pango-font.hh"
Real
output_scale (Output_def *od)
return scm_to_double (od->lookup_variable (ly_symbol2scm ("outputscale")));
}
+
+SCM
+get_font_table (Output_def *def)
+{
+ SCM font_table = def->lookup_variable (ly_symbol2scm ("scaled-fonts"));
+ if (scm_hash_table_p (font_table) != SCM_BOOL_T)
+ {
+ font_table = scm_c_make_hash_table (11);
+ def->set_variable (ly_symbol2scm ("scaled-fonts"), font_table);
+ }
+ return font_table;
+}
+
+
+
/* TODO: should add nesting for Output_def here too. */
Font_metric *
find_scaled_font (Output_def *mod, Font_metric *f, Real m,
Real lookup_mag = m / output_scale (mod);
-
- SCM font_table = mod->lookup_variable (ly_symbol2scm ("scaled-fonts"));
- if (scm_hash_table_p (font_table) != SCM_BOOL_T)
- {
- font_table = scm_c_make_hash_table (11);
- mod->set_variable (ly_symbol2scm ("scaled-fonts"), font_table);
- }
+
+ SCM font_table = get_font_table (mod);
SCM sizes = scm_hashq_ref (font_table, f->self_scm (), SCM_BOOL_F);
if (sizes != SCM_BOOL_F)
{
{
Font_metric *fm = unsmob_metrics (scm_cdar (t));
- if (dynamic_cast<Modified_font_metric*> (fm))
+ if (dynamic_cast<Modified_font_metric*> (fm)
+ || dynamic_cast<Pango_font*> (fm))
ell = scm_cons (fm->self_scm (), ell);
}
}
#include <math.h>
+#include "main.hh"
+#include "config.hh"
+#include "pango-font.hh"
#include "warn.hh"
#include "grob.hh"
#include "font-interface.hh"
#include "modified-font-metric.hh"
#include "ly-module.hh"
+
MAKE_SCHEME_CALLBACK (Text_interface, interpret_string, 4)
SCM
Text_interface::interpret_string (SCM layout_smob,
String str = ly_scm2string (markup);
-#if 0
+#if HAVE_PANGO_FT2
+ if (output_format_global != "tex")
+ {
+ Font_metric *fm = select_pango_font (layout, props);
+ return fm->text_stencil (str).smobbed_copy ();
+ }
+#endif
+
SCM_ASSERT_TYPE (input_encoding == SCM_EOL || scm_is_symbol (input_encoding),
input_encoding, SCM_ARG2, __FUNCTION__, "symbol");
-
- String str = ly_scm2string (markup);
if (!scm_is_symbol (input_encoding))
{
SCM enc = layout->lookup_variable (ly_symbol2scm ("inputencoding"));
Font_metric *fm = select_encoded_font (layout, props, input_encoding);
- SCM lst = SCM_EOL;
- Box b;
- if (Modified_font_metric* mf = dynamic_cast<Modified_font_metric*> (fm))
- {
- lst = scm_list_3 (ly_symbol2scm ("text"),
- mf->self_scm (),
- markup);
-
- b = mf->text_dimension (str);
- }
- else
- {
- /* ARGH. */
- programming_error ("Must have Modified_font_metric for text.");
- scm_display (fm->description_, scm_current_error_port ());
- }
-
- return Stencil (b, lst).smobbed_copy ();
-#else
-
-
- Font_metric *fm = select_encoded_font (layout, props, input_encoding);
- return fm->text_stencil (str).smobbed_copy ();
-#endif
+ return fm->text_stencil (str).smobbed_copy();
}
-
MAKE_SCHEME_CALLBACK (Text_interface, interpret_markup, 3)
SCM
Text_interface::interpret_markup (SCM layout_smob, SCM props, SCM markup)
staff-height init-paper
-
+pstack
% end lilyponddefs.ps
(define-public (ps-font-command font . override-coding)
(let* ((name (ly:font-file-name font))
- (magnify (ly:font-magnification font))
- (coding-alist (ly:font-encoding-alist font))
- (input-encoding (assoc-get 'input-name coding-alist))
- (font-encoding (assoc-get 'output-name coding-alist))
- (coding-command (if (null? override-coding)
- (if (equal? input-encoding font-encoding)
- #f font-encoding)
- (car override-coding))))
+ (magnify (ly:font-magnification font)))
(string-append
"magfont" (string-encode-integer (hashq name 1000000))
"m" (string-encode-integer (inexact->exact (round (* 1000 magnify))))
- (if (not coding-command) "" (string-append "e" coding-command)))))
+ )))
(define (tex-font? fontname)
(or
font-set-name font-set-name version (string-length binary-data)
)
binary-data
- "%%EndData
+ "\n%%EndData
%%EndResource
%%EOF
"
(define (load-fonts paper)
(let* ((fonts (ly:paper-fonts paper))
- (font-names (uniq-list (sort (map ly:font-file-name fonts) string<?)))
+ (all-font-names
+ (map
+ (lambda (font)
+ (if (string? (ly:font-file-name font))
+ (list (ly:font-file-name font))
+ (ly:font-sub-fonts font)))
+
+ fonts))
+ (font-names
+ (uniq-list
+ (sort (apply append all-font-names) string<?)))
(pfas (map
(lambda (x)
- (let* ((cffname (string-append x ".cff"))
+ (let* ((bare-file-name (ly:find-file x))
+ (cffname (string-append x ".cff"))
(aname (string-append x ".pfa"))
(bname (string-append x ".pfb"))
(cff-file-name (ly:find-file cffname))
(a-file-name (ly:kpathsea-find-file aname))
(b-file-name (ly:kpathsea-find-file bname)))
(cond
+ (bare-file-name (if (string-match "\\.pfb" bare-file-name)
+ (ly:pfb->pfa bare-file-name)
+ (ly:gulp-file bare-file-name)))
(cff-file-name (ps-embed-cff (ly:gulp-file cff-file-name) x 0))
(a-file-name (ly:gulp-file a-file-name))
(b-file-name (ly:pfb->pfa b-file-name))
(string-join pfas "\n")))
(define (define-fonts paper)
-
+
(define font-list (ly:paper-fonts paper))
(define (define-font command fontname scaling)
(string-append
"/" command " { /" fontname " findfont "
(ly:number->string scaling) " output-scale div scalefont } bind def\n"))
- (define (reencode-font fontname encoding scaling command)
- (let ((coding-vector (get-coding-command encoding)))
- (string-append
- "/" fontname " findfont " coding-vector " /" command " reencode-font\n"
- "/" command "{ /" command " findfont " (ly:number->string scaling) " output-scale div scalefont } bind def\n")))
-
(define (standard-tex-font? x)
(or (equal? (substring x 0 2) "ms")
(equal? (substring x 0 2) "cm")))
(fontname (if specced-font-name
specced-font-name
(ly:font-file-name font)))
-
- (coding-alist (ly:font-encoding-alist font))
- (input-encoding (assoc-get 'input-name coding-alist))
- (font-encoding (assoc-get 'output-name coding-alist))
(command (ps-font-command font))
+
;; FIXME -- see (ps-font-command )
(plain (ps-font-command font #f))
(designsize (ly:font-design-size font))
(ops (ly:output-def-lookup paper 'outputscale))
(scaling (* ops magnification designsize)))
+
;; Bluesky pfbs have UPCASE names (sigh.)
;;
(if (standard-tex-font? fontname)
(set! fontname (string-upcase fontname)))
- ;; debugging: [output]encoding is broken
- ;; found so far: coding-alist is empty!
- (pdebug "font: ~S\n" font)
- (pdebug "fontname: ~S\n" fontname)
- (pdebug "input-encoding:~S\n" input-encoding)
- (pdebug "font-encoding:~S\n" font-encoding)
-
- (pdebug "coding-alist:~S\n" coding-alist)
- (string-append
- (define-font plain fontname scaling)
- (if (equal? input-encoding font-encoding)
- ""
- (reencode-font fontname input-encoding scaling command)))))
-
- (define (font-load-encoding encoding)
- (let ((file-name (get-coding-file-name encoding)))
- (ly:gulp-file (ly:kpathsea-find-file file-name))))
-
- (let* ((encoding-list (map (lambda (x)
- (assoc-get 'input-name
- (ly:font-encoding-alist x)))
- font-list))
- (encodings (uniq-list (sort-list (filter string? encoding-list)
- string<?))))
-
- (pdebug "encodings:~S\n" encodings)
- (string-append
- (apply string-append (map font-load-encoding encodings))
- (apply string-append
- (map (lambda (x) (font-load-command x)) font-list)))))
+ (define-font plain fontname scaling)))
+
+ (apply string-append
+ (map (lambda (x) (font-load-command x))
+ (filter (lambda (x) (not (ly:pango-font? x)))
+ font-list))))
;; FIXME: duplicated in other output backends
;; FIXME: silly interface name
(define (no-origin)
"")
+
+(define-public (glyph-string psname items)
+ (apply
+ string-append
+ (cons
+ (format " /~a findfont setfont " psname)
+ (map (lambda (item)
+ (format " ~a ~a rmoveto /~a glyphshow "
+ (car item)
+ (cadr item)
+ (caddr item)))
+ items))))
(mm (eval 'mm m)))
+ (module-define! m 'text-font-size (* 12 (/ sz 20)))
(module-define! m 'outputscale ss)
(module-define! m 'fonts (make-cmr-tree (/ sz (* 20 pt))))
(module-define! m 'staffheight sz)