summaryrefslogtreecommitdiff
path: root/Build/source/libs/graphite/include/graphite/GrFeature.h
blob: 4cc396a11d94e59ca8dcb316f252288b0a430e4a (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*--------------------------------------------------------------------*//*: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: GrFeature.h
Responsibility: Sharon Correll
Last reviewed: Not yet.

Description:

Note:
	The body of methods not complete contained in this file are located in GrEngine.cpp.
----------------------------------------------------------------------------------------------*/
#ifdef _MSC_VER
#pragma once
#endif
#ifndef GR_FEATURE_INCLUDED
#define GR_FEATURE_INCLUDED

//:End Ignore

#include "GrAppData.h"

namespace gr
{


/*----------------------------------------------------------------------------------------------
	A valid setting and its UI labels in potentially various languages.

	Hungarian: fset
----------------------------------------------------------------------------------------------*/
/****
class GrFeatureSetting
{
	friend class GrFeature;
public:
	GrFeatureSetting()
	{
		m_hmnstuLabels.Clear();
	}
	GrFeatureSetting(GrFeatureSetting & fset)
	{
		m_hmnstuLabels.Clear();
	}
protected:
	int m_nVal;
	HashMap<int, std::wstring> m_hmnstuLabels;
};
****/

class GrEngine;

/*----------------------------------------------------------------------------------------------
	Each Graphite feature defines a way to customize or parameterize the rendering processs.

	Hungarian: feat
----------------------------------------------------------------------------------------------*/
class GrFeature
{
	//friend class GrFeatureSetting;
public:
	enum {
		knLangFeatV2 = 1
	};

	GrFeature()
	{
		m_vnVal.clear();
		m_vnNameId.clear();
	}

	void Initialize(featid nID, int nNameId, int cfset, int nDefault = 0);

	featid ID()
	{
		return m_nID;
	}

	int DefaultValue()
	{
		return m_nDefault;
	}

	void SetDefault(int nDefault)
	{
		m_nDefault = nDefault;
	}

	int NameId()
	{
		return m_nNameId;
	}

	void SetNameId(int n)
	{
		m_nNameId = n;
	}

	int NumberOfSettings()
	{
		return (int)m_vnVal.size();
	}

	int Settings(int cMax, int * prgnVal);
	void AddSetting(int nVal, int nNameId);
	bool IsValidSetting(int nVal);
	std::wstring Label(GrEngine * pgreng, int nLang);
	std::wstring SettingLabel(GrEngine * pgreng, int nVal, int nLang);
	int NthSetting(int ifset);
	std::wstring NthSettingLabel(GrEngine * pgreng, int ifset, int nLang);
//	void SetSettingLabel(int nVal, std::wstring stuLabel, int nLang);

protected:
	featid m_nID;
	int m_nDefault;
	int m_nNameId;
//	HashMap<int, std::wstrng> m_hmnstuLabels;

	// These are parallel arrays. The first gives the setting value for a given feature,
	// the second gives the index into the name table that is used to read UI strings.
	std::vector<int> m_vnVal;
	std::vector<int> m_vnNameId;
};


/*----------------------------------------------------------------------------------------------
	GrLangTable handles looking up language information.
	GrEngine has one instance of this class.
	Hungarian: langtbl
----------------------------------------------------------------------------------------------*/
class GrIStream;

class GrLangTable
{
	friend class FontMemoryUsage;

public:
	GrLangTable()
	{
		m_prglang = NULL;
		m_clang = 0;
		m_prgfset = NULL;
	}
	~GrLangTable()
	{
		delete[] m_prglang;
		delete[] m_prgfset;
	}

	bool ReadFromFont(GrIStream * pgrstrm, int fxdVersion);
	void CreateEmpty();

	size_t NumberOfLanguages()
	{
		return m_clang;
	}
	void LanguageFeatureSettings(isocode lgcode,
		std::vector<featid> & vnFeatId, std::vector<int> & vnValues);
	isocode LanguageCode(size_t ilang);

protected:
	size_t m_clang;
	//	constants for fast binary search of language list
	data16	m_dilangInit;	// (max power of 2 <= m_clang);
							//		size of initial range to consider
	data16	m_cLoop;		// log2(max power of 2 <= m_clang);
							//		indicates how many iterations are necessary
	data16	m_ilangStart;	// m_clang - m_dilangInit;
							//		where to start search

	struct LangEntry
	{
		char rgchCode[4];
		data16 cFeaturesBIG;	// big endian
		data16 cbOffsetBIG;		// big endian
	};
	LangEntry * m_prglang;
	int m_cbOffset0; // offset of first entry

	struct FeatSet
	{
		featid featidBIG;	// big endian
		data16 valueBIG;	// big endian
		data16 padBIG;
	};
	FeatSet * m_prgfset;
	int m_cfset;	// needed for memory instrumentation only

	int FindIndex(isocode lgcode);
};

} // namespace gr


#if defined(GR_NO_NAMESPACE)
using namespace gr;
#endif


#endif // !GR_FEATURE_INCLUDED