From df2bf3ee4c32d569f346d84fb5b42cab676a74d1 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 8 May 2005 13:17:15 +0000 Subject: [PATCH] * scm/framework-ps.scm (write-preamble): embed CFFs if file name matches .otf * lily/pfb.cc (Module): new function ly:otf->cff * lily/open-type-font.cc (get_otf_table): use ::get_otf_table (get_otf_table): new function. --- ChangeLog | 15 +++++++++++++++ lexer-gcc-3.1.sh | 14 +++++++------- lily/include/open-type-font.hh | 9 +++------ lily/open-type-font.cc | 29 +++++++++++++++++++++++------ lily/pfb.cc | 22 ++++++++++++++++++++++ scm/framework-ps.scm | 6 +++++- 6 files changed, 75 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9514332092..299db84850 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2005-05-08 Han-Wen Nienhuys + + * scm/framework-ps.scm (write-preamble): embed CFFs if file name + matches .otf + + * lily/pfb.cc (Module): new function ly:otf->cff + + * lily/open-type-font.cc (get_otf_table): use ::get_otf_table + (get_otf_table): new function. + +2005-05-07 Han-Wen Nienhuys + + * scm/backend-library.scm (postscript->png): call lilypond-ps2png + iso. ps2png. + 2005-05-06 Heikki Junes * po/fi.po: apply second round of update. diff --git a/lexer-gcc-3.1.sh b/lexer-gcc-3.1.sh index c9b8a389d6..1898f27eb8 100755 --- a/lexer-gcc-3.1.sh +++ b/lexer-gcc-3.1.sh @@ -8,7 +8,7 @@ FLEXLEXER=OK if [ -z "$FLEXLEXER" ]; then -includes="$HOME/usr/include /usr/local/include /usr/include" +includes="$HOME/usr/include $PREFIX/include /usr/local/include /usr/include" for i in $includes; do file=$i/FlexLexer.h @@ -43,9 +43,9 @@ if [ -z "$FLEXLEXER" ]; then echo -n "Copying and fixing $file... " mkdir -p lily/$outdir rm -f lily/$outdir/FlexLexer.h -sed -e 's/iostream.h/iostream/' \ - -e 's/\/std::istream/' \ - -e 's/\/std::ostream/' \ +perl -p -e 's/iostream.h/iostream/g;' \ + -e 's/\bistream\b/std::istream/g;' \ + -e 's/\bostream\b/std::ostream/' \ $file > lily/$outdir/FlexLexer.h echo "done" @@ -58,9 +58,9 @@ if [ -f GNUmakefile ]; then make conf=$CONF -C lily $outdir/lexer.cc > /dev/null 2>&1 || true mv $file $file.orig - sed -e 's/\/std::cin/g' \ - -e 's/\/std::cout/g' \ - -e 's/\/std::cerr/g' \ + perl -p -e 's/\bcin\b/std::cin/g;' \ + -e 's/\bcout\b/std::cout/g;' \ + -e 's/\bcerr\b/std::cerr/g' \ $file.orig > $file echo "done" fi diff --git a/lily/include/open-type-font.hh b/lily/include/open-type-font.hh index 918a2cc5cb..02278dbf23 100644 --- a/lily/include/open-type-font.hh +++ b/lily/include/open-type-font.hh @@ -44,13 +44,10 @@ public: virtual unsigned index_to_charcode (int) const; virtual void derived_mark () const; virtual SCM sub_fonts () 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; -#endif virtual Real design_size () const; }; +String get_otf_table (FT_Face face, String tag); +FT_Face open_ft_face (String str); + #endif /* OPEN_TYPE_FONT_HH */ diff --git a/lily/open-type-font.cc b/lily/open-type-font.cc index 6c82e91f21..ddd6b7c80e 100644 --- a/lily/open-type-font.cc +++ b/lily/open-type-font.cc @@ -42,13 +42,11 @@ load_table (char const *tag_str, FT_Face face, FT_ULong *length) return 0; } + String Open_type_font::get_otf_table (String tag) const { - FT_ULong len; - FT_Byte *tab = load_table (tag.to_str0 (), face_, &len); - - return String (tab, len); + return ::get_otf_table (face_, tag); } SCM @@ -87,8 +85,21 @@ Open_type_font::~Open_type_font () FT_Done_Face (face_); } -SCM -Open_type_font::make_otf (String str) + +/* + UGH fix naming +*/ +String +get_otf_table (FT_Face face, String tag) +{ + FT_ULong len; + FT_Byte *tab = load_table (tag.to_str0 (), face, &len); + + return String (tab, len); +} + +FT_Face +open_ft_face (String str) { FT_Face face; int error_code = FT_New_Face (freetype2_library, str.to_str0 (), 0, &face); @@ -98,7 +109,13 @@ Open_type_font::make_otf (String str) else if (error_code) error (_f ("unknown error: %d reading font file: %s", error_code, str.to_str0 ())); + return face; +} +SCM +Open_type_font::make_otf (String str) +{ + FT_Face face = open_ft_face (str); Open_type_font *otf = new Open_type_font (face); return otf->self_scm (); diff --git a/lily/pfb.cc b/lily/pfb.cc index 0967358f1f..bbb546405d 100644 --- a/lily/pfb.cc +++ b/lily/pfb.cc @@ -13,6 +13,7 @@ #include "source-file.hh" #include "memory-stream.hh" #include "ttftool.h" +#include "open-type-font.hh" char * pfb2pfa (Byte const *pfb, int length) @@ -104,3 +105,24 @@ LY_DEFINE (ly_ttf_to_pfa, "ly:ttf->pfa", return asscm; } + + + +LY_DEFINE (ly_otf_to_pfa, "ly:otf->cff", + 1, 0, 0, (SCM otf_file_name), + "Convert the contents of a OTF file to CFF file, returning it as " + " a string.") +{ + SCM_ASSERT_TYPE (scm_is_string (otf_file_name), otf_file_name, + SCM_ARG1, __FUNCTION__, "string"); + + String file_name = ly_scm2string (otf_file_name); + + FT_Face face = open_ft_face (file_name); + String table = get_otf_table (face, "CFF "); + + SCM asscm = scm_from_locale_stringn (table.get_bytes (), + table.length ()); + + return asscm; +} diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm index 2418b1c854..9eeb6588a2 100644 --- a/scm/framework-ps.scm +++ b/scm/framework-ps.scm @@ -231,7 +231,7 @@ (define (write-preamble paper load-fonts? port) - + (define (load-font font-name-filename) (let* ((font (car font-name-filename)) (name (cadr font-name-filename)) @@ -246,9 +246,13 @@ ((and bare-file-name (string-match "\\.pfb" bare-file-name)) (ly:pfb->pfa bare-file-name)) + ((string-match "([eE]mmentaler|[Aa]ybabtu)" file-name) (cached-file-contents (format "~a.pfa" (munge-lily-font-name file-name)))) + + ((and bare-file-name (string-match "\\.otf" bare-file-name)) + (ps-embed-cff (ly:otf->cff bare-file-name) name 0)) ((and bare-file-name (string-match "\\.ttf" bare-file-name)) (ly:ttf->pfa bare-file-name)) -- 2.39.5