summaryrefslogtreecommitdiff
path: root/Build/source/libs/graphite/test/RegressionTest/RtTextSrc.h
blob: cdbd51e90df3972b78c7f111a484cd090870e493 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*--------------------------------------------------------------------*//*:Ignore this sentence.
Copyright (C) 1999, 2001 SIL International. All rights reserved.

Distributable under the terms of either the Common Public License or the
GNU Lesser General Public License, as specified in the LICENSING.txt file.

File: RtTextSrc.h
Responsibility: Sharon Correll
Last reviewed: Not yet.

Description:

-------------------------------------------------------------------------------*//*:End Ignore*/
#pragma once
#ifndef RTTXTSRC_INCLUDED
#define RTTXTSRC_INCLUDED

#include <cstring>

/*----------------------------------------------------------------------------------------------
	Class: RtTextSrc
	This class extends the SimpleTextSource to allow setting of features.
----------------------------------------------------------------------------------------------*/
class RtTextSrc : public SimpleTextSrc
{
public:
	RtTextSrc(gr::utf16 * pszText) : SimpleTextSrc(pszText)
	{
		m_fRtl = false;
		memset(m_fset, 0, MAXFEAT * sizeof(FeatureSetting));
	}

	void setFeatures(FeatureSetting * fset)
	{
		m_cFeats = 0;
		for (int i = 0; i < MAXFEAT; i++)
		{
			if (fset[i].id > 0)
			{
				m_fset[i].id = fset[i].id;
				m_fset[i].value = fset[i].value;
				m_cFeats++;
			}
		}
	}

	virtual size_t getFontFeatures(toffset ich, FeatureSetting * prgfset)
	{
		// Note: size of prgfset buffer = gr::kMaxFeatures = 64
		std::copy(m_fset, m_fset + MAXFEAT, prgfset);
		return m_cFeats;
	}

	virtual bool getRightToLeft(toffset ich)
	{
		return m_fRtl;
	}
	virtual unsigned int getDirectionDepth(toffset ich)
	{
		return ((m_fRtl == 1) ? 1 : 0);
	}
	void setRightToLeft(bool f)
	{
		m_fRtl = f;
	}

protected:
	bool m_fRtl;
	int m_cFeats;
	FeatureSetting m_fset[MAXFEAT];
};


#endif // !RTTXTSRC_INCLUDED