w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

gr_features.cpp
Go to the documentation of this file.
1 /* GRAPHITE2 LICENSING
2 
3  Copyright 2010, SIL International
4  All rights reserved.
5 
6  This library is free software; you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation; either version 2.1 of License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should also have received a copy of the GNU Lesser General Public
17  License along with this library in the file named "LICENSE".
18  If not, write to the Free Software Foundation, 51 Franklin Street,
19  Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
20  internet at http://www.fsf.org/licenses/lgpl.html.
21 
22 Alternatively, the contents of this file may be used under the terms of the
23 Mozilla Public License (http://mozilla.org/MPL) or the GNU General Public
24 License, as published by the Free Software Foundation, either version 2
25 of the License or (at your option) any later version.
26 */
27 #include "graphite2/Font.h"
28 #include "inc/Face.h"
29 #include "inc/FeatureMap.h"
30 #include "inc/FeatureVal.h"
31 #include "inc/NameTable.h"
32 
33 using namespace graphite2;
34 
35 extern "C" {
36 
37 
38 gr_uint16 gr_fref_feature_value(const gr_feature_ref* pfeatureref, const gr_feature_val* feats) //returns 0 if either pointer is NULL
39 {
40  if (!pfeatureref || !feats) return 0;
41 
42  return pfeatureref->getFeatureVal(*feats);
43 }
44 
45 
47 {
48  if (!pfeatureref || !pDest) return 0;
49 
50  return pfeatureref->applyValToFeature(val, *pDest);
51 }
52 
53 
54 gr_uint32 gr_fref_id(const gr_feature_ref* pfeatureref) //returns 0 if pointer is NULL
55 {
56  if (!pfeatureref)
57  return 0;
58 
59  return pfeatureref->getId();
60 }
61 
62 
64 {
65  if(!pfeatureref)
66  return 0;
67  return pfeatureref->getNumSettings();
68 }
69 
70 
71 gr_int16 gr_fref_value(const gr_feature_ref* pfeatureref, gr_uint16 settingno)
72 {
73  if(!pfeatureref || (settingno >= pfeatureref->getNumSettings()))
74  {
75  return 0;
76  }
77  return pfeatureref->getSettingValue(settingno);
78 }
79 
80 
81 void* gr_fref_label(const gr_feature_ref* pfeatureref, gr_uint16 *langId, gr_encform utf, gr_uint32 *length)
82 {
83  if(!pfeatureref)
84  {
85  langId = 0;
86  length = 0;
87  return NULL;
88  }
89  uint16 label = pfeatureref->getNameId();
90  NameTable * names = pfeatureref->getFace().nameTable();
91  if (!names)
92  {
93  langId = 0;
94  length = 0;
95  return NULL;
96  }
97  return names->getName(*langId, label, utf, *length);
98 }
99 
100 
101 void* gr_fref_value_label(const gr_feature_ref*pfeatureref, gr_uint16 setting,
103 {
104  if(!pfeatureref || (setting >= pfeatureref->getNumSettings()))
105  {
106  langId = 0;
107  length = 0;
108  return NULL;
109  }
110  uint16 label = pfeatureref->getSettingName(setting);
111  NameTable * names = pfeatureref->getFace().nameTable();
112  if (!names)
113  {
114  langId = 0;
115  length = 0;
116  return NULL;
117  }
118  return names->getName(*langId, label, utf, *length);
119 }
120 
121 
123 {
124  free(label);
125 }
126 
127 gr_feature_val* gr_featureval_clone(const gr_feature_val* pfeatures/*may be NULL*/)
128 { //When finished with the Features, call features_destroy
129  return static_cast<gr_feature_val*>(pfeatures ? new Features(*pfeatures) : new Features);
130 }
131 
133 {
134  delete static_cast<Features*>(p);
135 }
136 
137 
138 } // extern "C"
NameTable * nameTable() const
Definition: Face.cpp:258
uint16 getNumSettings() const
Definition: FeatureMap.h:78
uint32 getId() const
Definition: FeatureMap.h:76
const Face & getFace() const
Definition: FeatureMap.h:83
int16 getSettingValue(uint16 index) const
Definition: FeatureMap.h:80
uint16 getNameId() const
Definition: FeatureMap.h:77
uint16 getSettingName(uint16 index) const
Definition: FeatureMap.h:79
bool applyValToFeature(uint32 val, Features &pDest) const
Definition: FeatureMap.cpp:270
uint32 getFeatureVal(const Features &feats) const
Definition: FeatureMap.cpp:286
#define free(a)
Definition: decNumber.cpp:310
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p
Definition: afcover.h:72
#define length(c)
Definition: ctangleboot.c:65
unsigned short uint16
Definition: tiff.h:62
list names
Definition: fc-lang.py:151
Definition: bits.h:30
FeatureVal Features
Definition: FeatureVal.h:63
short gr_int16
Definition: Types.h:35
unsigned short gr_uint16
Definition: Types.h:34
gr_encform
Definition: Types.h:39
unsigned int gr_uint32
Definition: Types.h:36
gr_uint16 gr_fref_n_values(const gr_feature_ref *pfeatureref)
Definition: gr_features.cpp:63
int gr_fref_set_feature_value(const gr_feature_ref *pfeatureref, gr_uint16 val, gr_feature_val *pDest)
Definition: gr_features.cpp:46
void * gr_fref_value_label(const gr_feature_ref *pfeatureref, gr_uint16 setting, gr_uint16 *langId, gr_encform utf, gr_uint32 *length)
void gr_featureval_destroy(gr_feature_val *p)
void * gr_fref_label(const gr_feature_ref *pfeatureref, gr_uint16 *langId, gr_encform utf, gr_uint32 *length)
Definition: gr_features.cpp:81
gr_uint16 gr_fref_feature_value(const gr_feature_ref *pfeatureref, const gr_feature_val *feats)
Definition: gr_features.cpp:38
void gr_label_destroy(void *label)
gr_feature_val * gr_featureval_clone(const gr_feature_val *pfeatures)
gr_int16 gr_fref_value(const gr_feature_ref *pfeatureref, gr_uint16 settingno)
Definition: gr_features.cpp:71
gr_uint32 gr_fref_id(const gr_feature_ref *pfeatureref)
Definition: gr_features.cpp:54
Definition: strexpr.c:21
struct def_label label[1024]
Definition: t1part.c:286