From: Han-Wen Nienhuys Date: Wed, 30 Nov 2005 13:36:21 +0000 (+0000) Subject: * lily/pango-font.cc: backport: pango-font.cc, completely. This X-Git-Tag: release/2.6.5~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0fd5aeb8220778d89c894caa0c21d7bb53cb9865;p=lilypond.git * lily/pango-font.cc: backport: pango-font.cc, completely. This turns on TTF kerning. * scm/output-ps.scm (glyph-string): backport: use width in glyph-string --- diff --git a/ChangeLog b/ChangeLog index 041f37241f..db5f0f67bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ +2005-11-30 Han-Wen Nienhuys + + * lily/pango-font.cc: backport: pango-font.cc, completely. This + turns on TTF kerning. + + * scm/output-ps.scm (glyph-string): backport: use width in glyph-string + 2005-11-29 Han-Wen Nienhuys + * GNUmakefile.in: backport of out-www excision. + * scripts/*.py: update bug reporting addresses. * lily/main.cc (LY_DEFINE): gmane address for reporting bugs. diff --git a/Documentation/index.html.in b/Documentation/index.html.in index 79da449068..fed0abf541 100644 --- a/Documentation/index.html.in +++ b/Documentation/index.html.in @@ -41,7 +41,7 @@ @@ -49,11 +49,11 @@ @@ -63,23 +63,23 @@   @@ -88,18 +88,18 @@  
  • - Program reference - (in one big page) + Program reference + (in one big page)
    (definitions for tweaking)
  • - Regression tests (in PDF) ~ 2.4Mb + Regression tests (in PDF) ~ 2.4Mb
    (for developers) -
  • Bibliography +
  • Bibliography
    (background information)
  • Thank yous diff --git a/GNUmakefile.in b/GNUmakefile.in index 23fccd5411..9a4ad906bf 100644 --- a/GNUmakefile.in +++ b/GNUmakefile.in @@ -41,9 +41,9 @@ doc: $(MAKE) -C Documentation install-WWW: - -$(INSTALL) -m 755 -d $(DESTDIR)$(webdir) - tar -C $(webdir)/ -xzf $(outdir)/web.tar.gz -# install-WWW does not recurse; fake it visiting Documentation/user manually + -$(INSTALL) -m 755 -d $(DESTDIR)$(webdir) + cp -a $(outdir)/web-root/ $(DESTDIR)$(webdir)/ + $(MAKE) -C Documentation/user local-install-WWW $(MAKE) -C Documentation/user install-info @@ -67,19 +67,31 @@ web-ext = html midi pdf png txt ly footify = $(PYTHON) $(step-bindir)/add-html-footer.py --name $(PACKAGE_NAME) --version $(TOPLEVEL_VERSION) footifymail = MAILADDRESS=bug-lilypond@gnu.org + local-WWW-post: # need UTF8 setting in case this is hosted on a website. - echo -e 'AddDefaultCharset utf-8\nAddCharset utf-8 .html\nAddCharset utf-8 .en\nAddCharset utf-8 .nl\nAddCharset utf-8 .txt\n' > $(builddir)/.htaccess - $(PYTHON) $(buildscript-dir)/mutopia-index.py -o $(builddir)/examples.html ./ - cd $(builddir) && $(FIND) . -name '*.html' -print | $(footifymail) xargs $(footify) - cd $(builddir) && find . -name \*.html~ -print | xargs rm -f + echo -e 'AddDefaultCharset utf-8\nAddCharset utf-8 .html\nAddCharset utf-8 .en\nAddCharset utf-8 .nl\nAddCharset utf-8 .txt\n' > $(outdir)/.htaccess + $(PYTHON) $(buildscript-dir)/mutopia-index.py -o $(outdir)/examples.html ./ + echo '' > $(outdir)/index.html + echo 'Redirecting to the documentation index...' >> $(outdir)/index.html + + $(FIND) $(builddir) -name '*.html' -print | $(footifymail) xargs $(footify) + $(FIND) $(builddir) -name \*.html~ -print | xargs rm -f cd $(builddir) && find Documentation input \ $(web-ext:%=-path '*/out-www/*.%' -or) -type l \ > $(outdir)/weblist - echo '' > $(builddir)/index.html - echo 'Redirecting to the documentation index...' >> $(builddir)/index.html - cd $(builddir) && ls *.html >> $(outdir)/weblist - cat $(outdir)/weblist | (cd $(builddir); GZIP=-9v tar -czf $(outdir)/web.tar.gz -T -) + ls $(outdir)/*.html >> $(outdir)/weblist + +## rewrite paths so we lose out-www + rm -rf $(outdir)/web-root/ + mkdir $(outdir)/web-root/ + cat $(outdir)/weblist | (cd $(builddir); tar -cf- -T- ) | \ + tar -C $(outdir)/web-root/ -xf - + cd $(outdir)/web-root/ && \ + for a in `find -name out-www`; do \ + mv $$a/* $$a/.. ; \ + rmdir $$a ; \ + done share-prefix = $(builddir)/share tree-prefix = $(builddir)/share/lilypond/$(TOPLEVEL_VERSION) diff --git a/buildscripts/mutopia-index.py b/buildscripts/mutopia-index.py index 76ad6e1c5b..8b02ea4ba2 100644 --- a/buildscripts/mutopia-index.py +++ b/buildscripts/mutopia-index.py @@ -18,6 +18,7 @@ def find (pat, dir): return lst +junk_prefix = 'out-www/' headertext= r""" @@ -26,16 +27,12 @@ headertext= r"""

    You're looking at a page with some LilyPond samples. These files are also included in the distribution. The output is completely -generated from the .ly source file, without any further touch -up. +generated from the source file, without any further touch up.

    The pictures are 90 dpi anti-aliased snapshots of the printed output. -If you want a better impression of the appearance, do print out one of -the PDF or PostScript files; they use scalable fonts, and should look -good at any resolution. - +For a good impression of the quality print out the PDF file. """ headertext_nopics= r""" @@ -136,7 +133,7 @@ hr { border:0; height:1; color: #000000; background-color: #000000; }\n def list_item (file_name, desc, type, lst = list): if os.path.isfile (file_name): lst.write ('

  • %s' - % (file_name, desc)) + % (re.sub (junk_prefix, '', file_name), desc)) # FIXME: include warning if it uses \include # files. diff --git a/lily/all-font-metrics.cc b/lily/all-font-metrics.cc index 1273a3ae59..cbb646a305 100644 --- a/lily/all-font-metrics.cc +++ b/lily/all-font-metrics.cc @@ -78,7 +78,6 @@ All_font_metrics::find_pango_font (PangoFontDescription *description, progress_indication ("[" + String (pango_fn)); Pango_font *pf = new Pango_font (pango_ft2_fontmap_, - RIGHT, description, output_scale); val = pf->self_scm (); diff --git a/lily/include/pango-font.hh b/lily/include/pango-font.hh index b8119b746a..3874b29b6c 100644 --- a/lily/include/pango-font.hh +++ b/lily/include/pango-font.hh @@ -25,12 +25,12 @@ class Pango_font : public Font_metric PangoFontDescription *pango_description_; PangoAttrList *attribute_list_; Real scale_; + Real output_scale_; SCM physical_font_tab_; public: SCM physical_font_tab () const; Pango_font (PangoFT2FontMap *, - Direction leftright, PangoFontDescription *, Real); ~Pango_font (); @@ -38,7 +38,7 @@ public: SCM font_file_name () const; void register_font_file (String, String); Stencil text_stencil (String) const; - Stencil pango_item_string_stencil (PangoItem *, String, Real) const; + Stencil pango_item_string_stencil (const PangoItem *, String) const; virtual void derived_mark () const; }; diff --git a/lily/pango-font.cc b/lily/pango-font.cc index c021807467..5f4950ae93 100644 --- a/lily/pango-font.cc +++ b/lily/pango-font.cc @@ -22,15 +22,12 @@ #include "stencil.hh" Pango_font::Pango_font (PangoFT2FontMap *fontmap, - Direction dir, PangoFontDescription *description, Real output_scale) { (void) fontmap; physical_font_tab_ = scm_c_make_hash_table (11); - PangoDirection pango_dir = (dir == RIGHT) - ? PANGO_DIRECTION_LTR - : PANGO_DIRECTION_RTL; + PangoDirection pango_dir = PANGO_DIRECTION_LTR; context_ = pango_ft2_get_context (PANGO_RESOLUTION, PANGO_RESOLUTION); // context_ = pango_ft2_font_map_create_context (fontmap); @@ -44,6 +41,7 @@ Pango_font::Pango_font (PangoFT2FontMap *fontmap, --hwn */ + output_scale_ = output_scale; scale_ = INCH_TO_BP / (Real (PANGO_SCALE) * Real (PANGO_RESOLUTION) * output_scale); /* @@ -76,15 +74,15 @@ Pango_font::derived_mark () const } Stencil -Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) const +Pango_font::pango_item_string_stencil (PangoItem const *item, String str) const { const int GLYPH_NAME_LEN = 256; char glyph_name[GLYPH_NAME_LEN]; - PangoAnalysis *pa = &(item->analysis); + PangoAnalysis const *pa = &(item->analysis); PangoGlyphString *pgs = pango_glyph_string_new (); pango_shape (str.to_str0 () + item->offset, - item->length, pa, pgs); + item->length, (PangoAnalysis*) pa, pgs); PangoRectangle logical_rect; PangoRectangle ink_rect; @@ -101,7 +99,7 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con PANGO_ASCENT (ink_rect))); b.scale (scale_); - + SCM glyph_exprs = SCM_EOL; SCM *tail = &glyph_exprs; @@ -115,24 +113,24 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con FT_Get_Glyph_Name (ftface, pg, glyph_name, GLYPH_NAME_LEN); - - SCM char_id; + SCM char_id; if (glyph_name[0] == '\0') { /* CID entry - */ + */ cid_keyed = true; char_id = scm_from_int (pg); } else char_id = scm_makfrom0str (glyph_name); - *tail = scm_cons (scm_list_3 (scm_from_double (ggeo.x_offset * scale_ - + dx), + + *tail = scm_cons (scm_list_4 (scm_from_double (ggeo.width * scale_), + scm_from_double (ggeo.x_offset * scale_), scm_from_double (ggeo.y_offset * scale_), + char_id), SCM_EOL); - dx = 0.0; tail = SCM_CDRLOC (*tail); } @@ -141,14 +139,16 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con / (Real (PANGO_SCALE)); FcPattern *fcpat = fcfont->font_pattern; - char *file_name = 0; - FcPatternGetString (fcpat, FC_FILE, 0, (FcChar8 **) & file_name); -#ifdef __MINGW32__ - /* Normalize file name. */ - // FIXME: memleak(s?), drop the #ifdef? - file_name = File_name (file_name).to_string ().get_copy_str0 (); -#endif + char *file_name_as_ptr = 0; + FcPatternGetString (fcpat, FC_FILE, 0, (FcChar8 **) & file_name_as_ptr); + String file_name; + if (file_name_as_ptr) + { + /* Normalize file name. */ + file_name = File_name (file_name_as_ptr).to_string (); + } + char const *ps_name_str0 = FT_Get_Postscript_Name (ftface); if (!ps_name_str0) @@ -156,15 +156,15 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con String ps_name; if (!ps_name_str0 - && file_name - && (String (file_name).index (".otf") >= 0 - || String (file_name).index (".cff") >= 0)) + && file_name != "" + && (file_name.index (".otf") >= 0 + || file_name.index (".cff") >= 0)) { /* UGH: kludge a PS name for OTF/CFF fonts. */ String name = file_name; - int idx = max (String (file_name).index (".otf"), - String (file_name).index (".cff")); + int idx = max (file_name.index (".otf"), + file_name.index (".cff")); name = name.left_string (idx); @@ -185,7 +185,7 @@ Pango_font::pango_item_string_stencil (PangoItem *item, String str, Real dx) con { ((Pango_font *) this)->register_font_file (file_name, ps_name); pango_fc_font_unlock_face (fcfont); - + SCM expr = scm_list_5 (ly_symbol2scm ("glyph-string"), scm_makfrom0str (ps_name.to_str0 ()), scm_from_double (size), @@ -208,25 +208,52 @@ Pango_font::physical_font_tab () const Stencil Pango_font::text_stencil (String str) const { - GList *items = pango_itemize (context_, - str.to_str0 (), - 0, str.length (), attribute_list_, - NULL); + GList *items + = pango_itemize (context_, + str.to_str0 (), + 0, str.length (), attribute_list_, + NULL); - GList *ptr = items; Stencil dest; - Real x = 0.0; - while (ptr) + + Real last_x = 0.0; + + Direction text_dir = RIGHT; + for (GList *p = items; p; p = p->next) + { + PangoItem *item = (PangoItem *) p->data; + if (item->analysis.level == PANGO_DIRECTION_RTL) + text_dir = LEFT; + } + + for (GList *ptr = items; ptr; ptr = ptr->next) { PangoItem *item = (PangoItem *) ptr->data; - Stencil item_stencil = pango_item_string_stencil (item, str, x); + Stencil item_stencil = pango_item_string_stencil (item, str); - x = item_stencil.extent (X_AXIS)[RIGHT]; + if (text_dir == RIGHT) + { + item_stencil.translate_axis (last_x, X_AXIS); + last_x = item_stencil.extent (X_AXIS)[RIGHT]; + } + else if (text_dir == LEFT) + { + dest.translate_axis (item_stencil.extent (X_AXIS)[RIGHT], X_AXIS); + } +#if 0 /* Check extents. */ + if (!item_stencil.extent_box ()[X_AXIS].is_empty ()) + { + Stencil frame = Lookup::frame (item_stencil.extent_box (), 0.1, 0.1); + Box empty; + empty.set_empty (); + Stencil dimless_frame (empty, frame.expr ()); + dest.add_stencil (frame); + } +#endif + dest.add_stencil (item_stencil); - - ptr = ptr->next; } /* @@ -241,7 +268,7 @@ Pango_font::text_stencil (String str) const */ char *descr_string = pango_font_description_to_string (pango_description_); SCM exp - = scm_list_3 (ly_symbol2scm ("utf8-string"), + = scm_list_3 (ly_symbol2scm ("utf-8-string"), scm_makfrom0str (descr_string), scm_makfrom0str (str.to_str0 ())); @@ -252,17 +279,6 @@ Pango_font::text_stencil (String str) const 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); - Box empty; - empty.set_empty (); - Stencil dimless_frame (empty, frame.expr ()); - dest.add_stencil (frame); - } -#endif return dest; } diff --git a/make/lilypond.fedora.spec.in b/make/lilypond.fedora.spec.in index 3091df8f60..6d86228f1c 100644 --- a/make/lilypond.fedora.spec.in +++ b/make/lilypond.fedora.spec.in @@ -182,8 +182,7 @@ scrollkeeper-update %{_datadir}/lilypond/@TOPLEVEL_VERSION@/ %{_datadir}/locale/*/LC_MESSAGES/lilypond.mo - -# %{_libdir}/lilypond/ +%{_libdir}/lilypond/ %files documentation diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 8ad92dc74c..954c03aa98 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -147,49 +147,28 @@ (define (glyph-string postscript-font-name size cid? - x-y-named-glyphs) - - (define (encoding-vector-hack glyphs) - - ;; GS fucks up with glyphs that are not in the - ;; encoding vector. - (define (inner j glyphs) - (if (or (null? glyphs) (> j 256)) - '() - (cons (format "dup ~a /~a put\n" - j (car glyphs)) - (inner (1+ j) (cdr glyphs))))) - - (format "256 array 0 1 255 { 1 index exch /.notdef put} for\n ~a -/EncHack reencode-font /EncHack findfont" - (apply string-append (inner 32 glyphs)))) - ;; END HACK. - - (format #f "gsave 1 output-scale div 1 output-scale div scale - /~a ~a ~a scalefont setfont\n~a grestore" + w-x-y-named-glyphs) + + (format #f "gsave + /~a ~a ~a output-scale div scalefont setfont\n~a grestore" postscript-font-name (if cid? " /CIDFont findresource " " findfont") - size (apply string-append (map (lambda (item) (let* - ((x (car item)) - (y (cadr item)) - (g (caddr item)) + ((w (car item)) + (x (cadr item)) + (y (caddr item)) + (g (cadddr item)) (prefix (if (string? g) "/" ""))) - (if (and (= 0.0 x) - (= 0.0 y)) - (format #f " ~a~a glyphshow\n" prefix g) - (format #f " ~a ~a rmoveto ~a~a glyphshow\n" - x y - prefix - g)))) - x-y-named-glyphs)))) + (format #f " gsave ~a~a glyphshow grestore ~a ~a rmoveto \n" prefix g (+ w x) y) + )) + w-x-y-named-glyphs)))) (define (grob-cause offset grob) (let* ((cause (ly:grob-property grob 'cause))