#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);
}
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;
/ (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)
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);
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 ())
{
#endif
dest.add_stencil (item_stencil);
-
- ptr = ptr->next;
}
/*
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]" }
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}
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)