#include "all-font-metrics.hh"
-//#include "open-type-font.hh"
+#include "open-type-font.hh"
#include "config.hh"
#include "main.hh"
#include "warn.hh"
return dynamic_cast<Adobe_font_metric*> (unsmob_metrics (val));
}
-#if 0
-
Open_type_font*
All_font_metrics::find_otf (String name)
{
return dynamic_cast<Open_type_font*> (unsmob_metrics (val));
}
-#endif
Tex_font_metric*
All_font_metrics::find_tfm (String name)
Font_metric*
All_font_metrics::find_font (String name)
{
- //Font_metric *f = find_otf (name);
- Font_metric *f = 0;
-
+ Font_metric *f = find_otf (name);
+
if (!f &&
(name.left_string (4) == "feta"
|| name.left_string (8) == "parmesan"
SCM expr = SCM_EOL;
if (idx >= 0)
{
- expr = scm_list_3 (ly_symbol2scm ("char"),
+ expr = scm_list_3 (ly_symbol2scm ("named-glyph"),
self_scm (),
- scm_int2num (index_to_ascii (idx)));
+ scm_makfrom0str (s.to_str0 ())
+ );
b = get_indexed_char (idx);
}
virtual ~Open_type_font();
virtual Box get_indexed_char (int) const;
virtual int name_to_index (String) const;
+
#if 0
virtual int count () const;
virtual int index_to_ascii (int) const;
virtual Box get_ascii_char (int) const;
virtual Offset get_indexed_wxwy (int) const;
- virtual Real design_size () const;
#endif
+ virtual Real design_size () const;
};
return string;
}
+
+LY_DEFINE (ly_find_file, "ly:find-file",
+ 1, 0, 0, (SCM name),
+ "Return the absolute file name of @var{name},"
+ "or @code{#f} if not found.")
+{
+ SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG1, __FUNCTION__, "string");
+
+ String nm = ly_scm2string (name);
+ String file_name = global_path.find (nm);
+ if (file_name.is_empty ())
+ return SCM_BOOL_F;
+
+ return scm_makfrom0str (file_name.to_str0 ());
+}
+
LY_DEFINE (ly_kpathsea_find_file, "ly:kpathsea-find-file",
1, 0, 0, (SCM name),
"Return the absolute file name of @var{name},"
#include "misc.hh"
#include "output-def.hh"
#include "warn.hh"
+#include "freetype.hh"
/*
* Global options that can be overridden through command line.
ly_c_init_guile ();
call_constructors ();
init_global_tweak_registry ();
-
+ init_freetype ();
determine_output_options ();
all_fonts_global = new All_font_metrics (global_path.to_string ());
#include <stdio.h>
-#if 0
-
-void
-enumerate_glyphs (FT_Face face)
-{
- FT_UInt glyph_index;
- FT_ULong char_code = FT_Get_First_Char (face, &glyph_index);
- while (gindex != 0)
- {
- // ... do something with (charcode,gindex) pair ...
- FT_Get
- charcode = FT_Get_Next_Char( face, charcode, &gindex );
- }
-}
-
-#endif
-
SCM
Open_type_font::make_otf (String str)
{
Open_type_font * otf = new Open_type_font;
int error_code = FT_New_Face(freetype2_library, str.to_str0(),
0, &(otf->face_));
-
- // int code = FT_Set_Charmap (otf->face_, );
-
if (error_code == FT_Err_Unknown_File_Format)
{
Box
-Open_type_font::get_indexed_char (int signed_idx)
+Open_type_font::get_indexed_char (int signed_idx) const
{
FT_UInt idx = signed_idx;
- int code =
- FT_Load_Glyph (face_,
+ FT_Load_Glyph (face_,
idx,
FT_LOAD_NO_SCALE);
- FT_Glyph_Metrics m = face->glyph->metrics;
- Box b (Interval (0, m->width) - m->horiBearingX,
- Interval (0, m->height) - m->horiBearingY);
+ FT_Glyph_Metrics m = face_->glyph->metrics;
+ int hb = m.horiBearingX;
+ int vb = m.horiBearingY;
+ Box b (Interval (-hb, m.width - hb),
+ Interval (-vb, m.height - vb));
return b;
}
int
-Open_type_font::name_to_index (String nm)
+Open_type_font::name_to_index (String nm) const
{
- FT_String * nm_str = nm.to_str0 ();
+ char * nm_str = (char * )nm.to_str0 ();
int idx = FT_Get_Name_Index (face_, nm_str);
if (idx == 0)
Real
-Open_type_font::get_design_size () const
+Open_type_font::design_size () const
{
return 20.0;
}
// TODO: set version
// TODO: GPL?
-SetFontNames("Feta", "LilyPond", "", "", "This font is in the public domain.", "");
+SetFontNames("bigcheese20", "", "", "", "This font is in the public domain.", "");
MergeFonts("feta20.pfa");
MergeFonts("parmesan20.pfa");
MergeFonts("feta-din14.pfa");
MergeKern("feta-din14.tfm");
LoadTableFromFile("LILC", "feta20.otf-table")
-Generate("feta20.otf");
-Generate("feta20.t42");
+Generate("bigcheese20.otf");
+Generate("bigcheese20.t42");
,(delay (ly:make-virtual-font
(ly:font-load "feta20")
(ly:font-load "parmesan20")))
+; ,(delay (ly:make-virtual-font (ly:font-load "bigcheese20")))
,(delay (ly:make-virtual-font
(ly:font-load "feta23")
(ly:font-load "parmesan23")))
(font-names (uniq-list (sort (map ly:font-file-name fonts) string<?)))
(pfas (map
(lambda (x)
-
- (let* ((aname (string-append x ".pfa"))
+
+ (let* ((t42name (string-append x ".t42"))
+ (aname (string-append x ".pfa"))
+ (bname (string-append x ".pfb"))
+ (t42path (ly:find-file t42name))
(apath (ly:kpathsea-find-file aname))
-
- (bpath (if (not apath)
- (ly:kpathsea-find-file
- (string-append x ".pfb"))
- #f)))
+ (bpath (ly:kpathsea-find-file bname)))
(cond
+ (t42path (ly:gulp-file t42path))
(apath (ly:gulp-file apath))
(bpath (ly:pfb->pfa bpath))
(else
- (ly:warn "cannot find PFA font ~S" x)
+ (ly:warn "cannot find T42/PFA/PFB font ~S" x)
""))))
(filter string? font-names))))
bracket
dashed-slur
char
+ named-glyph
dashed-line
zigzag-line
ez-ball
(ps-font-command font) " setfont "
"(\\" (ly:inexact->string i 8) ") show" ))
+(define (named-glyph font glyph)
+ (string-append
+ (ps-font-command font) " setfont "
+ "/" glyph " glyphshow "))
+
(define (dashed-line thick on off dx dy)
(string-append
(ly:number->string dx) " "