CVSROOT: /cvsroot/lilypond Module name: lilypond Branch: Changes by: Han-Wen Nienhuys <[EMAIL PROTECTED]> 05/08/26 08:38:38
Modified files: . : ChangeLog THANKS lily : all-font-metrics.cc pango-font.cc lily/include : pango-font.hh scripts : lilypond-book.py Added files: input/regression: markup-bidi-pango.ly Log message: * input/regression/markup-bidi-pango.ly: new file. * lily/pango-font.cc (pango_item_string_stencil): make Mingw code standard. Remove #ifdef. Remove memleak. (text_stencil): use text_dir to decide how to composite items. (text_stencil): determine uniform text direction for the entire string. * scripts/lilypond-book.py (output_name): remove latex_filter_cmd. Non-portable to non-Unix systems. (get_latex_textwidth): use File.write and os.unlink() instead. * THANKS: add Vicente & Trevor. CVSWeb URLs: http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/ChangeLog.diff?tr1=1.4089&tr2=1.4090&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/THANKS.diff?tr1=1.147&tr2=1.148&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/input/regression/markup-bidi-pango.ly?rev=1.1 http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/all-font-metrics.cc.diff?tr1=1.92&tr2=1.93&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/pango-font.cc.diff?tr1=1.42&tr2=1.43&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/lily/include/pango-font.hh.diff?tr1=1.16&tr2=1.17&r1=text&r2=text http://savannah.gnu.org/cgi-bin/viewcvs/lilypond/lilypond/scripts/lilypond-book.py.diff?tr1=1.271&tr2=1.272&r1=text&r2=text Patches: Index: lilypond/ChangeLog diff -u lilypond/ChangeLog:1.4089 lilypond/ChangeLog:1.4090 --- lilypond/ChangeLog:1.4089 Fri Aug 26 00:42:38 2005 +++ lilypond/ChangeLog Fri Aug 26 08:38:37 2005 @@ -1,5 +1,17 @@ 2005-08-26 Han-Wen Nienhuys <[EMAIL PROTECTED]> + * input/regression/markup-bidi-pango.ly: new file. + + * lily/pango-font.cc (pango_item_string_stencil): make Mingw code + standard. Remove #ifdef. Remove memleak. + (text_stencil): use text_dir to decide how to composite items. + (text_stencil): determine uniform text direction for the entire + string. + + * scripts/lilypond-book.py (output_name): remove + latex_filter_cmd. Non-portable to non-Unix systems. + (get_latex_textwidth): use File.write and os.unlink() instead. + * THANKS: add Vicente & Trevor. * lily/grob.cc (discretionary_processing): look up origin for Index: lilypond/THANKS diff -u lilypond/THANKS:1.147 lilypond/THANKS:1.148 --- lilypond/THANKS:1.147 Fri Aug 26 00:42:38 2005 +++ lilypond/THANKS Fri Aug 26 08:38:37 2005 @@ -38,6 +38,7 @@ BUG HUNTERS/SUGGESTIONS Bob Broadus +Darius Blasband Donald Axel Erlend Aasland Trevor BaÄa Index: lilypond/lily/all-font-metrics.cc diff -u lilypond/lily/all-font-metrics.cc:1.92 lilypond/lily/all-font-metrics.cc:1.93 --- lilypond/lily/all-font-metrics.cc:1.92 Fri Aug 12 00:04:47 2005 +++ lilypond/lily/all-font-metrics.cc Fri Aug 26 08:38:37 2005 @@ -62,7 +62,8 @@ Pango_font * All_font_metrics::find_pango_font (PangoFontDescription *description, Real magnification, - Real output_scale) + Real output_scale + ) { pango_font_description_set_size (description, gint (magnification * @@ -78,9 +79,10 @@ progress_indication ("[" + String (pango_fn)); Pango_font *pf = new Pango_font (pango_ft2_fontmap_, - RIGHT, description, - output_scale); + output_scale + ); + val = pf->self_scm (); pango_dict_->set (key, val); pf->unprotect (); Index: lilypond/lily/include/pango-font.hh diff -u lilypond/lily/include/pango-font.hh:1.16 lilypond/lily/include/pango-font.hh:1.17 --- lilypond/lily/include/pango-font.hh:1.16 Thu Aug 25 16:46:02 2005 +++ lilypond/lily/include/pango-font.hh Fri Aug 26 08:38:38 2005 @@ -27,11 +27,10 @@ Real scale_; Real output_scale_; SCM physical_font_tab_; - + Direction text_direction_; public: SCM physical_font_tab () const; Pango_font (PangoFT2FontMap *, - Direction leftright, PangoFontDescription *, Real); ~Pango_font (); @@ -39,7 +38,7 @@ SCM font_file_name () const; void register_font_file (String, String); Stencil text_stencil (String) const; - Stencil pango_item_string_stencil (PangoItem *, String) const; + Stencil pango_item_string_stencil (PangoItem const *, String) const; virtual void derived_mark () const; }; Index: lilypond/lily/pango-font.cc diff -u lilypond/lily/pango-font.cc:1.42 lilypond/lily/pango-font.cc:1.43 --- lilypond/lily/pango-font.cc:1.42 Thu Aug 25 16:46:02 2005 +++ lilypond/lily/pango-font.cc Fri Aug 26 08:38:38 2005 @@ -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); @@ -77,15 +74,15 @@ } Stencil -Pango_font::pango_item_string_stencil (PangoItem *item, String str) 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; @@ -140,14 +137,16 @@ / (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) @@ -155,15 +154,15 @@ 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); @@ -207,23 +206,41 @@ 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 last_x = 0.0; - while (ptr) + + 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); - item_stencil.translate_axis (last_x, X_AXIS); - last_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 ()) { @@ -236,8 +253,6 @@ #endif dest.add_stencil (item_stencil); - - ptr = ptr->next; } /* Index: lilypond/scripts/lilypond-book.py diff -u lilypond/scripts/lilypond-book.py:1.271 lilypond/scripts/lilypond-book.py:1.272 --- lilypond/scripts/lilypond-book.py:1.271 Mon Aug 22 15:50:37 2005 +++ lilypond/scripts/lilypond-book.py Fri Aug 26 08:38:38 2005 @@ -117,7 +117,6 @@ use_hash_p = 1 format = 0 output_name = '' -latex_filter_cmd = 'cat > %(tmpfile)s && latex "\\nonstopmode \input %(tmpfile)s" && rm %(tmpfile)s' filter_cmd = 0 process_cmd = '' default_ly_options = { 'alt': "[image of music]" } @@ -1276,7 +1275,8 @@ if ly_names: my_system (string.join ([cmd, 'snippet-map.ly'] + ly_names)) -LATEX_DOCUMENT = r''' +LATEX_INSPECTION_DOCUMENT = r''' +\nonstopmode %(preamble)s \begin{document} \typeout{textwidth=\the\textwidth} @@ -1289,12 +1289,16 @@ def get_latex_textwidth (source): m = re.search (r'''(?P<preamble>\\begin\s*{document})''', source) preamble = source[:m.start (0)] - latex_document = LATEX_DOCUMENT % vars () + latex_document = LATEX_INSPECTION_DOCUMENT % vars () # Workaround problems with unusable $TMP on Cygwin: tempfile.tempdir = '' tmpfile = tempfile.mktemp('.tex') - cmd = latex_filter_cmd % vars () - parameter_string = filter_pipe (latex_document, cmd) + logfile = os.path.splitext (tmpfile) + '.log' + open (tmpfile,'w').write (latex_document) + ly.system ('latex %s' % tmpfile) + parameter_string = open (logfile).read() + os.unlink (tmpfile) + os.unlink (logfile) columns = 0 m = re.search ('columns=([0-9.]*)', parameter_string) _______________________________________________ Lilypond-cvs mailing list Lilypond-cvs@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-cvs