1 /***************************************************************************
2  *   Copyright (C) 2007 by Pierre Marchand   *
3  *   pierre@oep-h.com   *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20 
21 
22 #ifndef WRAPLIBOTF
23 #define WRAPLIBOTF
24 
25 #include <ft2build.h>
26 #include FT_FREETYPE_H
27 #include FT_TRUETYPE_TABLES_H
28 
29 
30 #include <QString>
31 #include <QStringList>
32 #include <QMap>
33 #include <QList>
34 
35 #include "fmshaper_own.h"
36 #include "fmsharestruct.h"
37 // added to pacify gcc44 PL
38 #include <stdint.h>
39 #include <ctype.h>
40 
41 
42 #include <harfbuzz.h>
43 
44 
45 // using namespace std;
46 
47 class FMOtf
48 {
49 	public:
50 		FMOtf ( FT_Face, double scale = 0.0 );
51 		~FMOtf ();
52 
53 		QString curString;
54 
55 	private:
56 		FT_Face _face;
57 //   ScShaper * shaper;
58 		bool useShaper;
59 		HB_FontRec hbFont;
60 		QByteArray _memgdef,_memgsub,_memgpos;
61 		HB_StreamRec* gdefstream;
62 		HB_StreamRec* gsubstream;
63 		HB_StreamRec* gposstream;
64 		HB_GDEF _gdef;
65 		HB_GSUB _gsub;
66 		HB_GPOS _gpos;
67 
68 		//OTF_GlyphString mys;
69 		HB_Buffer _buffer;
70 
71 		bool glyphAlloc;
72 
73 		int GDEF, GSUB, GPOS;
74 
75 
76 
77 
78 	public:
79 
80 // 	OTF_GlyphString * FMOtfString() {return &mys;}
81 // 	int unicode(int gid){ return OTF_get_unicode(my, gid);}
82 		int get_glyph ( int index );//{return _buffer->out_string[index].gindex;}
83 		QString curTable;
84 		HB_UShort curScript, curLang, curLangReq;
85 		QString curScriptName, curLangName;
86 		QStringList curFeatures;
87 
88 		static HB_UShort manageAlternates ( HB_UInt    pos,HB_UShort   glyphID,HB_UShort   num_alternates,HB_UShort*  alternates, void*       data );
89 		static QList<int> altGlyphs;
90 		/*
91 		 * These members functions apply features currently set
92 		 */
93 	public:
94 		// Yes there are a lot, doubtless too much.
95 		int procstring ( QString s, QString script, QString lang, QStringList gsub, QStringList gpos );
96 		QList<RenderedGlyph> procstring ( QString s, OTFSet set );
97 		QList<RenderedGlyph> procstring ( QList<Character> shaped , QString script );
98 		QList<RenderedGlyph> procstring ( QList<unsigned int> glyList , QString script, QString lang, QStringList gsub, QStringList gpos );
99 
100 		/*
101 		  * These functions give access to informations contained in the fontfile
102 		 */
103 		QStringList   get_tables ();
104 		QStringList   get_scripts ();
105 		QStringList   get_langs ();
106 		QStringList   get_features ( bool required=false );
107 		/*
108 		 * These allow to set up the features ( Tab -> Scr -> Lan -> Fea )
109 		 */
110 		void set_table ( QString );
111 		void set_script ( QString );
112 		void set_lang ( QString );
113 		void set_features ( QStringList );
114 
115 
116 //   uint get_position(int,GlyphLayout *);
117 //   uint presentAlternates(HB_UInt, HB_UShort, QList<HB_UShort>);
118 		GlyphList get_position ( HB_Buffer abuffer = 0 );
119 
face()120 	FT_Face face() const
121 	{
122 		return _face;
123 	}
124 
125 
126 		friend class FontItem;
127 		friend class FMShaper;
128 
129 
130 
131 };
132 
133 #endif
134