Mako 8.2.0 API
MakoCore SDK API Documentation
Loading...
Searching...
No Matches
iglyphsclusters.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009-2023 Global Graphics Software Ltd. All rights reserved.
3 */
4
10
11
12#ifndef GLYPHSCLUSTERS_H
13#define GLYPHSCLUSTERS_H
14
15#include <edl/edlnamespaces.h>
16#include <edl/edltypes.h>
17#include <edl/ircobject.h>
18#include <edl/edlstring.h>
19#include <edl/edlvector.h>
20#include <edl/edlmath.h>
21
23
32{
33 public:
35 {
36 hasGlyphId = false;
37 hasAdvance = false;
38 hasUOffset = false;
39 hasVOffset = false;
40 advance = 0.0;
41 glyphId = 0;
42 uOffset = 0.0;
43 vOffset = 0.0;
44 }
48 float advance;
50 float uOffset;
52 float vOffset;
53
54 bool operator== (const CIndicesGlyph &other) const
55 {
56 bool bEq = (other.hasGlyphId == hasGlyphId)
57 && (other.hasAdvance == hasAdvance)
58 && (other.hasUOffset == hasUOffset)
59 && (other.hasVOffset == hasVOffset);
60
61 if (bEq && hasGlyphId)
62 bEq = (other.glyphId == glyphId);
63
64 if (bEq && hasAdvance)
65 bEq = (other.advance == advance);
66
67 if (bEq && hasUOffset)
68 bEq = (other.uOffset == uOffset);
69
70 if (bEq && hasVOffset)
71 bEq = (other.vOffset == vOffset);
72
73 return bEq;
74 }
75
84 bool similar(const CIndicesGlyph &other, float eps) const
85 {
86 bool bSimilar = (other.hasGlyphId == hasGlyphId)
87 && (other.hasAdvance == hasAdvance)
88 && (other.hasUOffset == hasUOffset)
89 && (other.hasVOffset == hasVOffset);
90
91 if (bSimilar && hasGlyphId)
92 {
93 bSimilar = (other.glyphId == glyphId);
94 }
95
96 if (bSimilar && hasAdvance)
97 {
98 bSimilar = fabs(other.advance - advance) <= eps;
99 }
100
101 if (bSimilar && hasUOffset)
102 {
103 bSimilar = fabs(other.uOffset - uOffset) <= eps;
104 }
105
106 if (bSimilar && hasVOffset)
107 {
108 bSimilar = fabs(other.vOffset - vOffset) <= eps;
109 }
110
111 return bSimilar;
112 }
113
114 bool operator!= (const CIndicesGlyph &other) const
115 {
116 return ! (*this == other);
117 }
118};
119
120// A vector of CIndicesGlyph
122
141{
142 public:
145 {
146 unicode.resize(1);
147 unicode[0] = codePoint;
148 }
151
160 bool similar(const CGlyphsCluster &other, float eps) const
161 {
162 bool bSimilar = (other.unicode == unicode) &&
163 (other.glyphs.size() == glyphs.size());
164
165 for (uint32 i = 0; bSimilar && i < glyphs.size(); i++)
166 {
167 bSimilar = glyphs[i].similar(other.glyphs[i], eps);
168 }
169
170 return bSimilar;
171 }
172
173};
174
175class IGlyphsClusters;
177
196{
197 public:
198 virtual ~IGlyphsClusters() {}
199
204 static EDL_API IGlyphsClustersPtr create();
205
209 static EDL_API IGlyphsClustersPtr create(const EDLString &unicodeString, const EDLSysString &indices);
210
215 virtual IGlyphsClustersPtr clone() const = 0;
216
220 virtual void populateUnicodeAndIndices(EDLString &unicodeString, EDLSysString &indices) = 0;
221
225 virtual void clear() = 0;
226
231 virtual uint32 getNumClusters() const = 0;
232
238 virtual CGlyphsCluster &getCluster(uint32 index) = 0;
239
244 virtual void deleteCluster(uint32 index) = 0;
245
251 virtual void insertCluster(uint32 index, const CGlyphsCluster &cluster) = 0;
252
257 virtual void appendCluster(const CGlyphsCluster &cluster) = 0;
258
264
273 virtual bool similar(const IGlyphsClustersPtr &other, float eps) const = 0;
274
275};
276
278
279#endif
280
Definition edlvector.h:30
uint32_t size() const
Definition edlvector.h:106
A single cluster generated from the parallel Indices and Unicode strings present in an IDOMGlyphs nod...
Definition iglyphsclusters.h:141
CGlyphsCluster()
Definition iglyphsclusters.h:143
CIndicesGlyphList glyphs
The glyph information, if present.
Definition iglyphsclusters.h:150
CGlyphsCluster(uint32 codePoint)
Definition iglyphsclusters.h:144
bool similar(const CGlyphsCluster &other, float eps) const
Check to see if this cluster is similar to another with regard to metrics. Non-metrics information (s...
Definition iglyphsclusters.h:160
CEDLVector< uint32, 5 > unicode
The unicode information for the cluster as UTF-32, if present.
Definition iglyphsclusters.h:149
bool hasGlyphId
True if the glyphId entry is valid.
Definition iglyphsclusters.h:45
float advance
The advance, in hundredths of an em, if hasAdvance is true.
Definition iglyphsclusters.h:48
bool hasUOffset
True if the uOffset entry is valid.
Definition iglyphsclusters.h:49
bool hasAdvance
True if the advance entry is valid.
Definition iglyphsclusters.h:47
uint16 glyphId
The glyph ID of the glyph, if hasGlyphId is true.
Definition iglyphsclusters.h:46
bool operator==(const CIndicesGlyph &other) const
Definition iglyphsclusters.h:54
bool operator!=(const CIndicesGlyph &other) const
Definition iglyphsclusters.h:114
bool hasVOffset
True if the vOffset entry is valid.
Definition iglyphsclusters.h:51
bool similar(const CIndicesGlyph &other, float eps) const
Check to see if this indices glyph entry is similar to another with regard to metrics....
Definition iglyphsclusters.h:84
float uOffset
The u offset of the glyph, in hundredths of an em, if hasUOffset is true.
Definition iglyphsclusters.h:50
CIndicesGlyph()
Definition iglyphsclusters.h:34
float vOffset
The v offset of the glyph, in hundredths of an em, if hasVOffset is true.
Definition iglyphsclusters.h:52
Definition iglyphsclusters.h:196
virtual IGlyphsClustersPtr clone() const =0
Clone this clusters object.
static EDL_API IGlyphsClustersPtr create(const EDLString &unicodeString, const EDLSysString &indices)
Create a set of glyphs clusters based on the given unicode and indices strings.
virtual uint32 getNumClusters() const =0
Clear the number of clusters.
virtual ~IGlyphsClusters()
Definition iglyphsclusters.h:198
virtual void appendCluster(const CGlyphsCluster &cluster)=0
Append a cluster to the set.
static EDL_API IGlyphsClustersPtr create()
Create a new set of glyphs clusters.
virtual CGlyphsCluster & getCluster(uint32 index)=0
Obtain a reference to the cluster at the given index.
virtual void deleteCluster(uint32 index)=0
Remove a cluster at the given index.
virtual void clear()=0
Clear the clusters.
virtual bool similar(const IGlyphsClustersPtr &other, float eps) const =0
Check to see if these clusters are similar to another with regard to metrics. Non-metrics information...
virtual void insertCluster(uint32 index, const CGlyphsCluster &cluster)=0
Insert a cluster before the item at the given index.
virtual void populateUnicodeAndIndices(EDLString &unicodeString, EDLSysString &indices)=0
Populate a unicode string and indices from this set of clusters.
virtual CGlyphsCluster & newCluster()=0
Allocate a new cluster at the end of the set and return a reference to it.
Base class Interface for all Reference Counted objects.
Definition ircobject.h:35
(very thin) portability layer around operating system provided math functionality but also includes a...
EDL C++ namespace(s)
#define _END_EDL_DOM_NAMESPACE
Definition edlnamespaces.h:110
#define _BEGIN_EDL_DOM_NAMESPACE
Definition edlnamespaces.h:109
EDLString and EDLSysString classes and associated EDL string manipulation functions.
std::string EDLSysString
Definition edlstring.h:158
std::wstring EDLString
Definition edlstring.h:165
EDL "standard" types including known bit-length signed and unsigned integer type[def]s and definition...
unsigned short uint16
Definition edltypes.h:33
unsigned int uint32
Definition edltypes.h:34
#define EDL_API
Definition edltypes.h:86
Simple template vector class for general use.
CEDLVector< CIndicesGlyph, 2 > CIndicesGlyphList
Definition iglyphsclusters.h:121
Interface for Reference Counted Object.
#define DECL_SMART_PTR(cls)
Definition smartptr.h:211