From: Han-Wen Nienhuys Date: Thu, 15 Jul 2004 23:19:22 +0000 (+0000) Subject: * input/regression/font-postscript.ly: new file. X-Git-Tag: release/2.3.7~42 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d7495f035d2eef8b1a1f719dc3c6aa32098135f7;p=lilypond.git * input/regression/font-postscript.ly: new file. * scm/framework-ps.scm (load-fonts): load pfb files too. * lily/pfb.cc (pfb2pfa): new file. --- diff --git a/ChangeLog b/ChangeLog index 154e346970..14df3554fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2004-07-16 Han-Wen Nienhuys + + * input/regression/font-postscript.ly: new file. + + * scm/framework-ps.scm (load-fonts): load pfb files too. + + * lily/pfb.cc (pfb2pfa): new file. + 2004-07-15 Han-Wen Nienhuys * scripts/lilypond-book.py (PREAMBLE_LY): set diff --git a/input/regression/font-postscript.ly b/input/regression/font-postscript.ly new file mode 100644 index 0000000000..795d360660 --- /dev/null +++ b/input/regression/font-postscript.ly @@ -0,0 +1,32 @@ +\header { + + texidoc = "This file demonstrates how to load different + (postscript) fonts. The file @file{font.scm} shows how to define + the scheme-function called." + +} + +\bookpaper +{ + + #(define text-font-defaults + '((font-encoding . latin1) + (baseline-skip . 2) + (word-space . 0.6))) + + #(set! fonts (make-century-schoolbook-tree 1.0)) +} + +\paper { + linewidth = 160 \mm - 2.0 * 9.0 \mm + + + indent = 0.0\mm + raggedright = ##t +} + + { + \key a \major +\time 6/8 +cis''8. d''16 cis''8 e''4 e''8 + } diff --git a/lily/pfb.cc b/lily/pfb.cc new file mode 100644 index 0000000000..60dde35569 --- /dev/null +++ b/lily/pfb.cc @@ -0,0 +1,90 @@ +/* + pfb.cc -- implement pfb conversion. + + source file of the GNU LilyPond music typesetter + + (c) 2004 Han-Wen Nienhuys + +*/ +#include +#include +#include + +#include "string.hh" +#include "lily-guile.hh" +#include "source-file.hh" + +char * +pfb2pfa (Byte const * pfb, int length) +{ + char * out = new char[1]; + int olen = 0; + + Byte const * p = pfb; + while (p < pfb + length) + { + if (*p++ != 128) + break; + + Byte type = *p++; + if (type == 3) + break ; + + unsigned seglen = + p[0] | (p[1] << 8) + | (p[2] << 16) | (p[3] << 24); + + p += 4; + if (type == 1) + { + out = (char*)realloc (out, olen + seglen + 1); + char* outp = out + olen ; + memcpy (outp, p, seglen); + olen += seglen; + p += seglen; + } + else if (type == 2) + { + unsigned outlength = (seglen * 2) + (seglen / 32) + 2; + + out = (char*)realloc (out, olen + outlength + 1); + + char * outp = out + olen; + for (int i = seglen; i--;) + { + sprintf (outp, "%02x", *p++); + outp += 2; + if (!(i % 32)) + { + *outp ++ = '\n'; + } + } + + olen = outp - out; + } + + } + out[olen] = 0; + + return out; +} + +LY_DEFINE(ly_pfb_to_pfa, "ly:pfb->pfa", + 1,0,0, (SCM pfb_path), + "Convert the contents of a PFB file to PFA." + ) +{ + SCM_ASSERT_TYPE(ly_c_string_p (pfb_path), pfb_path, + SCM_ARG1, __FUNCTION__, "string"); + + String path = ly_scm2string (pfb_path); + int len ; + char *str = gulp_file (path, &len); + char *pfa = pfb2pfa ((Byte*)str, len); + + SCM pfa_scm = scm_makfrom0str(pfa); + free (pfa); + delete str; + return pfa_scm; +} + diff --git a/lily/text-item.cc b/lily/text-item.cc index b03027b965..d472c17980 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -44,6 +44,7 @@ Text_item::interpret_string (SCM paper, SCM props, SCM encoding, SCM markup) { /* ARGH. */ programming_error ("Must have Modified_font_metric for text."); + scm_display (fm->description_, scm_current_error_port ()); } return Stencil (b, lst).smobbed_copy (); diff --git a/scm/font.scm b/scm/font.scm index 6af657f205..a17dc3be69 100644 --- a/scm/font.scm +++ b/scm/font.scm @@ -369,33 +369,32 @@ (font-shape . upright) (font-series . medium) (font-encoding . latin1)) - `(10.0 . #(,(delay (ly:font-load "c059013l"))))) + `(10.0 . #(,(delay (ly:font-load "uncr8a"))))) (add-font node '((font-family . roman) (font-shape . italic) (font-series . medium) (font-encoding . latin1)) - `(10.0 . #(,(delay (ly:font-load "c059033l"))))) + `(10.0 . #(,(delay (ly:font-load "uncri8a"))))) (add-font node '((font-family . roman) (font-shape . upright) (font-series . bold) (font-encoding . latin1)) - `(10.0 . #(,(delay (ly:font-load "c059016l"))))) + `(10.0 . #(,(delay (ly:font-load "uncb8a"))))) (add-font node '((font-family . roman) (font-shape . italic) (font-series . bold) (font-encoding . latin1)) - `(10.0 . #(,(delay (ly:font-load "c059036l"))))) + `(10.0 . #(,(delay (ly:font-load "uncbi8a"))))) ) (define-public (make-cmr-tree factor) - (let ((n (make-font-tree-node 'font-encoding 'fetaMusic))) @@ -416,6 +415,5 @@ )) - (define-public (magstep x) (exp (* (/ x 6) (log 2)))) diff --git a/scm/framework-ps.scm b/scm/framework-ps.scm index 3f72f59049..50070674f6 100644 --- a/scm/framework-ps.scm +++ b/scm/framework-ps.scm @@ -56,17 +56,14 @@ ((aname (string-append x ".pfa")) (apath (ly:kpathsea-expand-path aname)) -; (bpath (if (not apath) -; (ly:kpathsea-expand-path (string-append x ".pfb")) -; #f))) - - ) + (bpath (if (not apath) + (ly:kpathsea-expand-path (string-append x ".pfb")) + #f))) + (cond (apath (ly:gulp-file apath)) - - ; oops , can't plonk PFB in, must convert to ASCII. - ;(bpath (ly:gulp-file bpath)) + (bpath (ly:pfb->pfa bpath)) (else (ly:warn "Can't find PFA font ~S" x) ""))))