new function.
(ly:font-glyph-to-index): Remove.
* lily/font-metric.cc ("ly:font-glyph-name-to-charcode"): Bugfix:
use original font.
* lily/font-metric.cc (ly:font-glyph-name-to-charcode): Use it in
new function.
- (ly:font-glyp-to-index): Remove.
+ (ly:font-glyph-to-index): Remove.
- * scm/lily-library.scm (char->unicode-index): Remove.
+ * lily/font-metric.cc ("ly:font-glyph-name-to-charcode"): Bugfix:
+ use original font.
2004-12-12 Han-Wen Nienhuys <hanwen@xs4all.nl>
#include <cctype>
#include "modified-font-metric.hh"
+#include "open-type-font.hh"
+#include "stencil.hh"
#include "virtual-methods.hh"
#include "warn.hh"
-#include "stencil.hh"
#include "ly-smobs.icc"
SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
SCM_ASSERT_TYPE (scm_is_integer (index), index, SCM_ARG2, __FUNCTION__, "index");
- return scm_from_unsigned_integer (fm->index_to_charcode (ly_scm2int (index)));
+ unsigned charcode;
+ if (Modified_font_metric* mfm = dynamic_cast<Modified_font_metric*> (fm))
+ charcode = mfm->original_font ()->index_to_charcode (ly_scm2int (index));
+ else
+ charcode = fm->index_to_charcode (ly_scm2int (index));
+
+ return scm_from_unsigned_integer (charcode);
}
LY_DEFINE (ly_font_glyph_name_to_charcode, "ly:font-glyph-name-to-charcode",
Font_metric *fm = unsmob_metrics (font);
SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "font-metric");
SCM_ASSERT_TYPE (scm_is_string (name), name, SCM_ARG2, __FUNCTION__, "string");
+#if 1
+ unsigned charcode;
+ if (Modified_font_metric* mfm = dynamic_cast<Modified_font_metric*> (fm))
+ charcode = mfm->original_font ()->index_to_charcode (mfm->original_font ()->name_to_index (ly_scm2string (name)));
+ else
+ charcode = fm->index_to_charcode (fm->name_to_index (ly_scm2string (name)));
+#else
+ unsigned charcode;
+ if (Modified_font_metric* mfm = dynamic_cast<Modified_font_metric*> (fm))
+ charcode = mfm->original_font ()->glyph_name_to_charcode (ly_scm2string (name));
+ else
+ charcode = fm->glyph_name_to_charcode (ly_scm2string (name));
+#endif
- return scm_from_unsigned_integer (fm->index_to_charcode (fm->name_to_index (ly_scm2string (name))));
+ return scm_from_unsigned_integer (charcode);
}
LY_DEFINE (ly_text_dimension,"ly:text-dimension",
if (Modified_font_metric* mfm = dynamic_cast<Modified_font_metric*> (fm))
return ly_font_name (mfm->original_font ()->self_scm ());
else if (Adobe_font_metric* afm = dynamic_cast<Adobe_font_metric*> (fm))
- {
- return scm_makfrom0str (afm->font_info_->gfi->fontName);
- }
- else
- return SCM_BOOL_F;
+ return scm_makfrom0str (afm->font_info_->gfi->fontName);
+ return SCM_BOOL_F;
}
return (unsigned) index_to_ascii (i);
}
+#if 0
+unsigned
+Font_metric::glyph_name_to_charcode (String glyph_name) const
+{
+ return (unsigned) index_to_ascii (name_to_index (glyph_name));
+}
+#endif
+
Stencil
Font_metric::get_ascii_char_stencil (int code) const
{
#include "font-metric.hh"
typedef std::map<FT_UInt, FT_ULong> Index_to_charcode_map;
+//typedef std::map<String, FT_ULong> Glyph_name_to_charcode_map;
class Open_type_font : public Font_metric
{
SCM lily_character_table_;
SCM lily_global_table_;
Index_to_charcode_map index_to_charcode_map_;
+ //Glyph_name_to_charcode_map glyph_name_to_charcode_map_;
Open_type_font (FT_Face);
+
public:
static SCM make_otf (String);
virtual ~Open_type_font();
virtual Offset attachment_point (String) const;
virtual Box get_indexed_char (int) const;
virtual int name_to_index (String) const;
+ //virtual unsigned glyph_name_to_charcode (String) const;
virtual unsigned index_to_charcode (int) const;
virtual void derived_mark () const;
#if 0
virtual Real design_size () const;
};
-
#endif /* OPEN_TYPE_FONT_HH */
-
}
return tab;
}
-
+
Index_to_charcode_map
make_index_to_charcode_map (FT_Face face)
{
FT_ULong charcode;
FT_UInt gindex;
- charcode = FT_Get_First_Char (face, &gindex);
- while (gindex != 0)
+ for (charcode = FT_Get_First_Char (face, &gindex); gindex != 0;
+ charcode = FT_Get_Next_Char (face, charcode, &gindex))
+ m[gindex] = charcode;
+ return m;
+}
+
+#if 0
+Glyph_name_to_charcode_map
+make_glyph_name_to_charcode_map (FT_Face face)
+{
+ Glyph_name_to_charcode_map m;
+ FT_ULong charcode;
+ FT_UInt gindex;
+ char buffer[1024];
+
+ for (charcode = FT_Get_First_Char (face, &gindex); gindex != 0;
+ charcode = FT_Get_Next_Char (face, charcode, &gindex))
{
- printf ("index -> code: %d %d \n", gindex, charcode);
- m[gindex] = charcode;
- charcode = FT_Get_Next_Char (face, charcode, &gindex);
+ if (FT_Get_Glyph_Name (face, gindex, buffer, sizeof (buffer) - 1))
+ {
+ programming_error ("no glyph name");
+ continue;
+ }
+ m[String (buffer)] = charcode;
}
return m;
}
+#endif
Open_type_font::Open_type_font (FT_Face face)
{
lily_character_table_ = load_scheme_table ("LILC", face_);
lily_global_table_ = load_scheme_table ("LILY", face_);
index_to_charcode_map_ = make_index_to_charcode_map (face_);
+ //glyph_name_to_charcode_map_ = make_glyph_name_to_charcode_map (face_);
}
Open_type_font::~Open_type_font()
unsigned
Open_type_font::index_to_charcode (int i) const
{
- return ((Open_type_font*) this)->index_to_charcode_map_[index_to_ascii (i)];
+ return ((Open_type_font*) this)->index_to_charcode_map_[i];
+}
+
+#if 0
+unsigned
+Open_type_font::glyph_name_to_charcode (String glyph_name) const
+{
+ return ((Open_type_font*) this)->glyph_name_to_charcode_map_[glyph_name];
}
+#endif
Real
Open_type_font::design_size () const
(ly:font-file-name font)))))
(define-public (char->unicode-index font char)
- ;;(ly:font-index-to-charcode (char->integer char))
- (char->integer char))
+ (ly:font-index-to-charcode font (char->integer char)))
(+ #x80 (modulo y #x40))))))
(else FIXME)))
+(define (integer->utf8-string font integer)
+ (list->string (utf8 integer)))
+
(define (char->utf8-string font char)
(list->string (utf8 (char->unicode-index font char))))
(debugf "glyph:~S\n" name)
(debugf "index:~S\n" (ly:font-glyph-name-to-charcode font name))
(debugf "font:~S\n" (font-family font))
- (text font (integer->char (ly:font-glyph-name-to-charcode font name))))
+ (text font (ly:font-glyph-name-to-charcode font name)))
(define (polygon coords blotdiameter)
(let*
(define (text font s)
(define (pango-font-name font)
- (stderr "FONT-NAME:~S\n" (ly:font-name font))
+ (stderr "FONT-NAME:~S:~S\n" (ly:font-name font) (ly:font-design-size font))
(let ((family (font-family font)))
;; Hmm, family is bigcheese20?
- (if (string=? family "bigcheese20")
- (format #f "~S, ~S" (ly:font-name font) (ly:font-design-size font))
+ (if (string=? (substring family 0 (min (string-length family) 9))
+ "bigcheese")
+ (begin
+ ;; FIXME: FONT-NAME:#f:8.85678704856787
+ ;;(format #f "~S, ~S" (ly:font-name font) (ly:font-design-size font))
+ (stderr "BIGCHEESE\n")
+ "LilyPond 20"
+ )
family)))
(define (pango-font-size font)
#:size-set #t
#:text (if (char? s)
(char->utf8-string font s)
- (string->utf8-string font s)))))
+ (if (integer? s)
+ (integer->utf8-string font s)
+ (string->utf8-string font s))))))