diff options
author | Han-Wen Nienhuys <hanwen@xs4all.nl> | 2005-05-08 13:17:15 +0000 |
---|---|---|
committer | Han-Wen Nienhuys <hanwen@xs4all.nl> | 2005-05-08 13:17:15 +0000 |
commit | df2bf3ee4c32d569f346d84fb5b42cab676a74d1 (patch) | |
tree | 8130136c07a6eff0dade6306621a6ca2ce4ba0d2 /lily | |
parent | e43ea6a8e015ce281d0213490ba8ef52319e9ed5 (diff) |
* scm/framework-ps.scm (write-preamble): embed CFFs if file name
matches .otf
* lily/pfb.cc (Module): new function ly:otf->cff
* lily/open-type-font.cc (get_otf_table): use ::get_otf_table
(get_otf_table): new function.
Diffstat (limited to 'lily')
-rw-r--r-- | lily/include/open-type-font.hh | 9 | ||||
-rw-r--r-- | lily/open-type-font.cc | 29 | ||||
-rw-r--r-- | lily/pfb.cc | 22 |
3 files changed, 48 insertions, 12 deletions
diff --git a/lily/include/open-type-font.hh b/lily/include/open-type-font.hh index 918a2cc5cb..02278dbf23 100644 --- a/lily/include/open-type-font.hh +++ b/lily/include/open-type-font.hh @@ -44,13 +44,10 @@ public: virtual unsigned index_to_charcode (int) const; virtual void derived_mark () const; virtual SCM sub_fonts () const; -#if 0 - virtual int count () const; - virtual int index_to_ascii (int) const; - virtual Box get_ascii_char (int) const; - virtual Offset get_indexed_wxwy (int) const; -#endif virtual Real design_size () const; }; +String get_otf_table (FT_Face face, String tag); +FT_Face open_ft_face (String str); + #endif /* OPEN_TYPE_FONT_HH */ diff --git a/lily/open-type-font.cc b/lily/open-type-font.cc index 6c82e91f21..ddd6b7c80e 100644 --- a/lily/open-type-font.cc +++ b/lily/open-type-font.cc @@ -42,13 +42,11 @@ load_table (char const *tag_str, FT_Face face, FT_ULong *length) return 0; } + String Open_type_font::get_otf_table (String tag) const { - FT_ULong len; - FT_Byte *tab = load_table (tag.to_str0 (), face_, &len); - - return String (tab, len); + return ::get_otf_table (face_, tag); } SCM @@ -87,8 +85,21 @@ Open_type_font::~Open_type_font () FT_Done_Face (face_); } -SCM -Open_type_font::make_otf (String str) + +/* + UGH fix naming +*/ +String +get_otf_table (FT_Face face, String tag) +{ + FT_ULong len; + FT_Byte *tab = load_table (tag.to_str0 (), face, &len); + + return String (tab, len); +} + +FT_Face +open_ft_face (String str) { FT_Face face; int error_code = FT_New_Face (freetype2_library, str.to_str0 (), 0, &face); @@ -98,7 +109,13 @@ Open_type_font::make_otf (String str) else if (error_code) error (_f ("unknown error: %d reading font file: %s", error_code, str.to_str0 ())); + return face; +} +SCM +Open_type_font::make_otf (String str) +{ + FT_Face face = open_ft_face (str); Open_type_font *otf = new Open_type_font (face); return otf->self_scm (); diff --git a/lily/pfb.cc b/lily/pfb.cc index 0967358f1f..bbb546405d 100644 --- a/lily/pfb.cc +++ b/lily/pfb.cc @@ -13,6 +13,7 @@ #include "source-file.hh" #include "memory-stream.hh" #include "ttftool.h" +#include "open-type-font.hh" char * pfb2pfa (Byte const *pfb, int length) @@ -104,3 +105,24 @@ LY_DEFINE (ly_ttf_to_pfa, "ly:ttf->pfa", return asscm; } + + + +LY_DEFINE (ly_otf_to_pfa, "ly:otf->cff", + 1, 0, 0, (SCM otf_file_name), + "Convert the contents of a OTF file to CFF file, returning it as " + " a string.") +{ + SCM_ASSERT_TYPE (scm_is_string (otf_file_name), otf_file_name, + SCM_ARG1, __FUNCTION__, "string"); + + String file_name = ly_scm2string (otf_file_name); + + FT_Face face = open_ft_face (file_name); + String table = get_otf_table (face, "CFF "); + + SCM asscm = scm_from_locale_stringn (table.get_bytes (), + table.length ()); + + return asscm; +} |