From: Jan Nieuwenhuizen Date: Sun, 6 Mar 2005 18:27:55 +0000 (+0000) Subject: * stepmake/aclocal.m4 (STEPMAKE_KPATHSEA): Do not include X-Git-Tag: release/2.5.14~15 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=10fce7970987502ec8340819411897a829f6be23;p=lilypond.git * stepmake/aclocal.m4 (STEPMAKE_KPATHSEA): Do not include KPATHSEA_LIBS in LIBS. (STEPMAKE_DLOPEN): New function. * lily/font-config.cc (init_fontconfig): Use dir for directory, not path. * flower/file-path.cc (directories): Rename from paths, as this return an array of directories (a single path). --- diff --git a/ChangeLog b/ChangeLog index 08ae07518c..d3409d655a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2005-03-06 Jan Nieuwenhuizen + + Drop run-time dependency on teTeX. + + * lily/kpath.cc (initialize_kpathsea): dlopen libkpathsea. + + * stepmake/aclocal.m4 (STEPMAKE_KPATHSEA): Do not include + KPATHSEA_LIBS in LIBS. + (STEPMAKE_DLOPEN): New function. + + * lily/font-config.cc (init_fontconfig): Use dir for directory, + not path. + + * flower/file-path.cc (directories): Rename from paths, as this + return an array of directories (a single path). + 2005-03-06 Han-Wen Nienhuys * lily/GNUmakefile (MODULE_LIBS): link with kpath-guile diff --git a/config.make.in b/config.make.in index e8a36b5d5f..553f291aa9 100644 --- a/config.make.in +++ b/config.make.in @@ -7,6 +7,9 @@ MISSING_REQUIRED = @REQUIRED@ package-depth = @package_depth@ +#Alternative for dlopen +#KPATHSEA_LIBS = @KPATHSEA_LIBS@ + USER_CFLAGS = @CPPFLAGS@ @CFLAGS@ @GUILE_CFLAGS@ @PANGO_FT2_CFLAGS@ @FREETYPE2_CFLAGS@ USER_CXXFLAGS = @CPPFLAGS@ @CXXFLAGS@ @GUILE_CFLAGS@ @PANGO_FT2_CFLAGS@ @FREETYPE2_CFLAGS@ USER_LDFLAGS = @LDFLAGS@ @GUILE_LDFLAGS@ diff --git a/configure.in b/configure.in index f9ba2e2fab..9e207fed52 100644 --- a/configure.in +++ b/configure.in @@ -42,6 +42,7 @@ STEPMAKE_CXX(REQUIRED) STEPMAKE_GXX(REQUIRED, 3.0.5) STEPMAKE_CXXTEMPLATE STEPMAKE_LIB(REQUIRED) +STEPMAKE_DLOPEN # Do not use bison 1.50 and 1.75. # 1.29 is required fr %locations, but I'm not sure it's enough --ns STEPMAKE_BISON(REQUIRED, 1.29) diff --git a/flower/file-path.cc b/flower/file-path.cc index fa113fad71..88ccd59e17 100644 --- a/flower/file-path.cc +++ b/flower/file-path.cc @@ -28,7 +28,7 @@ #endif Array -File_path::paths () const +File_path::directories () const { return *this; } diff --git a/flower/include/file-path.hh b/flower/include/file-path.hh index 9f0ef04c3c..5f5549cb19 100644 --- a/flower/include/file-path.hh +++ b/flower/include/file-path.hh @@ -24,7 +24,7 @@ class File_path : private Array { public: - Array paths () const; + Array directories () const; String find (String name) const; String find (String name, char const *extensions[]); String to_string () const; diff --git a/lily/font-config.cc b/lily/font-config.cc index 4871c58303..ff2cb3f9ab 100644 --- a/lily/font-config.cc +++ b/lily/font-config.cc @@ -13,38 +13,36 @@ #include +#include "file-path.hh" #include "main.hh" #include "warn.hh" -#include "file-path.hh" void init_fontconfig () { - if (!FcInit()) - { - error ("FontConfig failed to initialize"); - } + if (!FcInit ()) + error (_ ("FontConfig failed to initialize")); FcConfig *fcc = FcConfigGetCurrent (); - Array dirs; dirs.push (prefix_directory + "/otf/"); dirs.push (prefix_directory + "/mf/out/"); dirs.push (prefix_directory + "/type1/"); dirs.push (prefix_directory + "/cff/"); - for (int i = 0; i < dirs.size(); i++) + for (int i = 0; i < dirs.size (); i++) { - String path = dirs[i]; - if (!FcConfigAppFontAddDir (fcc, (FcChar8*)path.to_str0 ())) - { - error (_f ("Failed to add lilypond directory %s", path.to_str0 ())); - } + String dir = dirs[i]; + if (!FcConfigAppFontAddDir (fcc, (FcChar8*)dir.to_str0 ())) + error (_f ("Failed to add lilypond directory %s", dir)); } } #else -void init_fontconfig() {} +void +init_fontconfig () +{ +} #endif diff --git a/lily/include/kpath-private.hh b/lily/include/kpath-private.hh index d8fa199e66..0814b5c6d6 100644 --- a/lily/include/kpath-private.hh +++ b/lily/include/kpath-private.hh @@ -10,6 +10,27 @@ #ifndef KPATH_PRIVATE_HH #define KPATH_PRIVATE_HH +#include "config.hh" + +#define popen KPATHSEA_HAS_POPEN_PROTOTYPE_PROBLEM +#define pclose KPATHSEA_HAS_PCLOSE_PROTOTYPE_PROBLEM +#define getopt KPATHSEA_HAS_GETOPT_PROTOTYPE_PROBLEM + +#if HAVE_KPATHSEA_KPATHSEA_H +extern "C" { + #include + #include + extern void *kpathsea_handle; + extern char *(*dl_kpse_find_file) (char const*, kpse_file_format_type, + boolean); + extern char const *(*dl_kpse_init_format) (kpse_file_format_type); + extern void (*dl_kpse_maketex_option) (char const*, boolean); + extern void (*dl_kpse_set_program_name) (char const*); + extern char *(*dl_kpse_var_expand) (char const*); + extern kpse_format_info_type (*dl_kpse_format_info)[kpse_last_format]; +} +#endif + kpse_file_format_type kpathsea_find_format (String name); #endif /* KPATH_PRIVATE_HH */ diff --git a/lily/main.cc b/lily/main.cc index 52e2c27710..291a9c8cc9 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -25,17 +25,16 @@ #include "all-font-metrics.hh" #include "file-name.hh" +#include "freetype.hh" #include "getopt-long.hh" #include "global-ctor.hh" -#include "kpath.hh" #include "lily-guile.hh" #include "lily-version.hh" -#include "version.hh" #include "misc.hh" #include "output-def.hh" -#include "warn.hh" -#include "freetype.hh" #include "string-convert.hh" +#include "version.hh" +#include "warn.hh" /* * Global options that can be overridden through command line. @@ -437,7 +436,7 @@ add_output_format (String format) static void parse_argv (int argc, char **argv) { - bool help_b = false; + bool show_help = false; option_parser = new Getopt_long (argc, argv, options_static); while (Long_option_init const *opt = (*option_parser) ()) { @@ -499,7 +498,7 @@ parse_argv (int argc, char **argv) init_name_global = option_parser->optional_argument_str0_; break; case 'h': - help_b = true; + show_help = true; break; case 'V': be_verbose_global = true; @@ -518,7 +517,7 @@ parse_argv (int argc, char **argv) } } - if (help_b) + if (show_help) { identify (stdout); usage (); diff --git a/lily/pango-font.cc b/lily/pango-font.cc index 5770a7e14f..88c719c7f3 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -19,7 +19,7 @@ #include "warn.hh" #if HAVE_PANGO_FT2 -#include "stencil.hh" +#include "stencil.hh" Pango_font::Pango_font (PangoFT2FontMap *fontmap, @@ -31,14 +31,14 @@ Pango_font::Pango_font (PangoFT2FontMap *fontmap, PangoDirection pango_dir = (dir == RIGHT) ? PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL; - context_ = - pango_ft2_get_context (PANGO_RESOLUTION, PANGO_RESOLUTION); + context_ + = pango_ft2_get_context (PANGO_RESOLUTION, PANGO_RESOLUTION); pango_description_ = pango_font_description_copy (description); - // context_ = pango_ft2_font_map_create_context (fontmap); + // context_ = pango_ft2_font_map_create_context (fontmap); attribute_list_= pango_attr_list_new(); - + /* urgh. I don't understand this. Why isn't this 1/(scale * resolution * output_scale) @@ -63,11 +63,11 @@ Pango_font::~Pango_font () } void -Pango_font::register_font_file (String filename, String ps_name) +Pango_font::register_font_file (String filename, String ps_name) { scm_hash_set_x (physical_font_tab_, - scm_makfrom0str (ps_name.to_str0()), - scm_makfrom0str (filename.to_str0())); + scm_makfrom0str (ps_name.to_str0 ()), + scm_makfrom0str (filename.to_str0 ())); } void @@ -78,7 +78,7 @@ Pango_font::derived_mark () const Stencil Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) const -{ +{ const int GLYPH_NAME_LEN = 256; char glyph_name[GLYPH_NAME_LEN]; PangoAnalysis *pa = &(item->analysis); @@ -90,17 +90,17 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con PangoRectangle logical_rect; PangoRectangle ink_rect; pango_glyph_string_extents (pgs, pa->font, &ink_rect, &logical_rect); - + PangoFcFont *fcfont = G_TYPE_CHECK_INSTANCE_CAST(pa->font, PANGO_TYPE_FC_FONT, PangoFcFont); - + FT_Face ftface = pango_fc_font_lock_face (fcfont); - Box b (Interval (PANGO_LBEARING(ink_rect), - PANGO_RBEARING(ink_rect)), - Interval (-PANGO_DESCENT(ink_rect), - PANGO_ASCENT(ink_rect))); - + Box b (Interval (PANGO_LBEARING (ink_rect), + PANGO_RBEARING (ink_rect)), + Interval (-PANGO_DESCENT (ink_rect), + PANGO_ASCENT (ink_rect))); + b.scale (scale_); SCM glyph_exprs = SCM_EOL; @@ -108,7 +108,7 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con for (int i = 0; i < pgs->num_glyphs; i++) { PangoGlyphInfo *pgi = pgs->glyphs + i; - + PangoGlyph pg = pgi->glyph; PangoGlyphGeometry ggeo = pgi->geometry; @@ -124,14 +124,14 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con PangoFontDescription *descr = pango_font_describe (pa->font); Real size = pango_font_description_get_size (descr) / (Real (PANGO_SCALE)); - + FcPattern *fcpat = fcfont->font_pattern; char *filename = 0; - FcPatternGetString(fcpat, FC_FILE, 0, (FcChar8 **) &filename); + FcPatternGetString (fcpat, FC_FILE, 0, (FcChar8 **) &filename); char const *ps_name_str0 = FT_Get_Postscript_Name (ftface); - + if (!ps_name_str0) - warning (_f ("No PS font name for font `%s'", filename)); + warning (_f ("No PS font name for font `%s'", filename)); String ps_name; if (!ps_name_str0 @@ -142,7 +142,7 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con /* UGH: kludge a PS name for OTF/CFF fonts. - + */ String name = filename; @@ -151,24 +151,24 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con name = name.left_string (idx); - int slash_idx = name.index_last ('/'); // UGh. What's happens on windows? + int slash_idx = name.index_last ('/'); // UGh. What's happens on windows? if (slash_idx >= 0) name = name.right_string (name.length() - slash_idx - 1); - String initial = name.cut_string (0,1); - initial.to_upper(); - name = name.nomid_string (0,1); - name.to_lower(); + String initial = name.cut_string (0, 1); + initial.to_upper (); + name = name.nomid_string (0, 1); + name.to_lower (); ps_name = initial + name; } else if (ps_name_str0) ps_name = ps_name_str0; - + if (ps_name.length ()) { ((Pango_font *) this)->register_font_file (filename, ps_name); pango_fc_font_unlock_face (fcfont); - + SCM expr = scm_list_4 (ly_symbol2scm ("glyph-string"), scm_makfrom0str (ps_name.to_str0 ()), scm_from_double (size), @@ -178,7 +178,7 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con } else { - warning (_ ("FreeType face has no PostScript font name.")); + warning (_ ("FreeType face has no PostScript font name.")); return Stencil(); } } @@ -196,7 +196,7 @@ Pango_font::text_stencil (String str) const str.to_str0 (), 0, str.length (), attribute_list_, NULL); - + GList *ptr = items; Stencil dest; Real x = 0.0; @@ -207,10 +207,10 @@ Pango_font::text_stencil (String str) const Stencil item_stencil = pango_item_string_stencil (item, str, x); x = item_stencil.extent (X_AXIS)[RIGHT]; - + dest.add_stencil (item_stencil); - - ptr = ptr->next; + + ptr = ptr->next; } /* @@ -235,12 +235,12 @@ Pango_font::text_stencil (String str) const b.unite (dest.extent_box ()); return Stencil (b, exp); } - + #if 0 // check extents. if (!dest.extent_box ()[X_AXIS].is_empty ()) { - Stencil frame = Lookup::frame (dest.extent_box(), 0.1, 0.1); + Stencil frame = Lookup::frame (dest.extent_box (), 0.1, 0.1); dest.add_stencil (frame); } #endif @@ -249,7 +249,7 @@ Pango_font::text_stencil (String str) const } -SCM +SCM Pango_font::font_file_name () const { return SCM_BOOL_F; @@ -261,10 +261,10 @@ Pango_font::font_file_name () const #if 0 -void test_pango() +void test_pango () { int dpi = 1200; - + char * font_family = "Emmentaler"; PangoContext * pango_context = pango_ft2_get_context (dpi, dpi); @@ -277,16 +277,16 @@ void test_pango() PangoAttrList *attr_list = pango_attr_list_new(); char *str = "sfz"; - GList * items = pango_itemize (pango_context, str, 0, strlen(str), - attr_list, NULL); - - - GList * ptr = items; + GList *items = pango_itemize (pango_context, str, 0, strlen (str), + attr_list, NULL); + + + GList *ptr = items; while (ptr) { PangoItem *item = (PangoItem*)ptr->data; printf( "off %d len %d num %d\n", item->offset, item->length, item->num_chars); - + PangoAnalysis paobj = item->analysis; PangoAnalysis * pa = &paobj; @@ -296,36 +296,36 @@ void test_pango() pango_font_description_to_string (descr), pango_font_description_to_filename (descr) ); - - printf ("type name %s\n", g_type_name (G_TYPE_FROM_INSTANCE(pa->font))); - PangoFcFont * fcfont = G_TYPE_CHECK_INSTANCE_CAST(pa->font, - PANGO_TYPE_FC_FONT, - PangoFcFont); + + printf ("type name %s\n", g_type_name (G_TYPE_FROM_INSTANCE (pa->font))); + PangoFcFont * fcfont = G_TYPE_CHECK_INSTANCE_CAST (pa->font, + PANGO_TYPE_FC_FONT, + PangoFcFont); FcPattern *fcpat = fcfont->font_pattern; FcPatternPrint (fcpat); char *retval ="bla"; - + FcPatternGetString(fcpat, FC_FILE, 0, (FcChar8 **) &retval); printf ("retval %s\n", retval); FT_Face ftface = pango_fc_font_lock_face (fcfont); printf ("shape %ux %s lang %ux font %ux languagae %ux\nft face %ux\n", pa->shape_engine, - G_OBJECT_TYPE_NAME(pa->shape_engine), + G_OBJECT_TYPE_NAME (pa->shape_engine), pa->lang_engine, pa->font, pa->language, ftface); - PangoGlyphString *pgs = pango_glyph_string_new(); - pango_shape (str, strlen(str), pa, pgs); + PangoGlyphString *pgs = pango_glyph_string_new (); + pango_shape (str, strlen (str), pa, pgs); int i; for (i = 0; i < pgs->num_glyphs; i++) { PangoGlyphInfo *pgi = pgs->glyphs + i; - + PangoGlyph pg = pgi->glyph; PangoGlyphGeometry ggeo = pgi->geometry; - + printf ("c %d w %d x %d y %d\n", pg, ggeo.width, ggeo.x_offset, ggeo.y_offset ); @@ -337,12 +337,11 @@ void test_pango() PangoRectangle r1; PangoRectangle r2; - + pango_glyph_string_extents (pgs, pa->font, &r1, &r2); - + ptr = ptr->next; printf ("\nnext item\n"); } - } #endif diff --git a/stepmake/aclocal.m4 b/stepmake/aclocal.m4 index 5e5fd6c2c1..2373646886 100644 --- a/stepmake/aclocal.m4 +++ b/stepmake/aclocal.m4 @@ -545,6 +545,11 @@ AC_DEFUN(STEPMAKE_GUILE_DEVEL, [ ]) +AC_DEFUN(STEPMAKE_DLOPEN, [ + AC_CHECK_LIB(dl, dlopen) + AC_CHECK_FUNCS(dlopen) +]) + AC_DEFUN(STEPMAKE_GXX, [ if test "$GXX" = "yes"; then STEPMAKE_CHECK_VERSION(CXX, $1, $2) @@ -769,6 +774,7 @@ AC_DEFUN(STEPMAKE_KPATHSEA, [ [ --with-kpathsea use kpathsea lib. Default: on], [kpathsea_b=$with_kpathsea]) + save_LIBS="$LIBS" if test "$kpathsea_b" != "no"; then AC_CHECK_HEADERS([kpathsea/kpathsea.h],,kpathsea_b=no) AC_CHECK_LIB(kpathsea, kpse_find_file) @@ -784,6 +790,8 @@ AC_DEFUN(STEPMAKE_KPATHSEA, [ STEPMAKE_ADD_ENTRY(REQUIRED, $warn) fi fi + KPATHSEA_LIBS="$LIBS" + LIBS="$save_LIBS" AC_MSG_CHECKING(whether to use kpathsea) if test "$kpathsea_b" != no; then AC_MSG_RESULT(yes) @@ -794,6 +802,7 @@ AC_DEFUN(STEPMAKE_KPATHSEA, [ fi AC_SUBST(KPATHSEA) + AC_SUBST(KPATHSEA_LIBS) AC_DEFINE_UNQUOTED(KPATHSEA, $KPATHSEA) ])