1 /*--------------------------------------------------------------------*//*:Ignore this sentence.
2 Copyright (C) 2005 SIL International. All rights reserved.
3 
4 Distributable under the terms of either the Common Public License or the
5 GNU Lesser General Public License, as specified in the LICENSING.txt file.
6 
7 File: PangoTextSrc.h
8 Responsibility: Daniel Glassey
9 Last reviewed: Not yet.
10 
11 Description:
12 	A simple text source that shows how to use this interface within Graphite.
13 -------------------------------------------------------------------------------*//*:End Ignore*/
14 #ifndef PANGOTXTSRC_INCLUDED
15 #define PANGOTXTSRC_INCLUDED
16 
17 #include <graphite/ITextSource.h>
18 typedef char   gchar;
19 using gr::GrResult;
20 
21 /*----------------------------------------------------------------------------------------------
22 	Class: PangoTextSrc
23 	This class provides a simple implementation for a text source for the Graphite engine.
24 	There are no paragraph properties of interest and one set of character properties that
25 	apply to the entire string.
26 ----------------------------------------------------------------------------------------------*/
27 
28 namespace gr
29 {
30 
31 class PangoTextSrc : public gr::ITextSource
32 {
33 public:
34 	// Constructor:
35 	PangoTextSrc(const char * pszText, int bytelength, int rtl, const char *language=0);
36 	PangoTextSrc(PangoTextSrc & textsrc);
37 	~PangoTextSrc();
38 
39 
40 	// -------------------------------------------------------------------------------
41 	// New interface:
utfEncodingForm()42 	virtual gr::UtfType utfEncodingForm()
43 	{
44 		return gr::kutf8;
45 	}
getLength()46 	virtual size_t getLength()
47 	{
48 		return m_cchLength;
49 	}
getText()50 	virtual const char * getText()
51 	{
52 		return m_prgchText;
53 	}
fetch(toffset ichMin,size_t cch,gr::utf32 * prgchBuffer)54 	virtual size_t fetch(toffset ichMin, size_t cch, gr::utf32 * prgchBuffer)
55 	{
56 		assert(false);
57 		return 0;
58 	}
fetch(toffset ichMin,size_t cch,gr::utf16 * prgchwBuffer)59 	virtual size_t fetch(toffset ichMin, size_t cch, gr::utf16 * prgchwBuffer)
60 	{
61 		assert(false);
62 		return 0;
63 	};
64 	virtual size_t fetch(toffset ichMin, size_t cch, gr::utf8  * prgchsBuffer);
65 	virtual GrResult getFaceName(int ich, unsigned int cchMax,
66 		gr::utf16 * prgchFaceName, unsigned int * pcchLen);
67 	virtual bool getRightToLeft(toffset ich);
68 	virtual unsigned int getDirectionDepth(toffset ich);
69 	virtual float getVerticalOffset(toffset ich);
70   virtual isocode getLanguage(toffset ich);
71 
propertyRange(toffset ich)72 	virtual std::pair<toffset, toffset> propertyRange(toffset ich)
73 	{
74 		std::pair<toffset, toffset> pairRet;
75 		pairRet.first = 0;
76 		pairRet.second = m_cchLength;
77 		return pairRet;
78 	}
79 
getFontFeatures(toffset ich,gr::FeatureSetting * prgfset)80 	virtual size_t getFontFeatures(toffset ich, gr::FeatureSetting * prgfset)
81 	{
82 		return 0; // no features in this simple implementation
83 	}
sameSegment(toffset ich1,toffset ich2)84 	virtual bool sameSegment(toffset ich1, toffset ich2)
85 	{
86 		return true;
87 	}
88 
89 	// Temporary--eventually these properties will be of interest only to SegmentPainter.
getColors(toffset ich,int * pclrFore,int * pclrBack)90 	virtual void getColors(toffset ich, int * pclrFore, int * pclrBack)
91 	{
92 		*pclrFore = gr::kclrBlack;
93 		*pclrBack = gr::kclrTransparent;
94 	}
95 
96 
97 protected:
98 	gchar * m_prgchText;
99 	int m_cchLength;
100   isocode m_langid;
101     bool m_fRtl;
102 };
103 
104 }; //namespace gr
105 
106 #endif // !GRTXTSRC_INCLUDED
107