1/*
2 ****************************************************************************** *
3 *
4 *   Copyright (C) 1999-2003, International Business Machines
5 *   Corporation and others.  All Rights Reserved.
6 *
7 ****************************************************************************** *
8 *   file name:  cmaps.h
9 *
10 *   created on: ??/??/2001
11 *   created by: Eric R. Mader
12 */
13
14#ifndef __CMAPS_H
15#define __CMAPS_H
16
17#include "layout/LETypes.h"
18#include "sfnt.h"
19
20class CMAPMapper
21{
22public:
23    virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const = 0;
24
25    virtual ~CMAPMapper();
26
27    static CMAPMapper *createUnicodeMapper(const CMAPTable *cmap);
28
29protected:
30    CMAPMapper(const CMAPTable *cmap);
31
32    CMAPMapper() {};
33
34private:
35    const CMAPTable *fcmap;
36};
37
38class CMAPFormat4Mapper : public CMAPMapper
39{
40public:
41    CMAPFormat4Mapper(const CMAPTable *cmap, const CMAPFormat4Encoding *header);
42
43    virtual ~CMAPFormat4Mapper();
44
45    virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const;
46
47protected:
48    CMAPFormat4Mapper() {};
49
50private:
51    le_uint16        fEntrySelector;
52    le_uint16        fRangeShift;
53    const le_uint16 *fEndCodes;
54    const le_uint16 *fStartCodes;
55    const le_uint16 *fIdDelta;
56    const le_uint16 *fIdRangeOffset;
57};
58
59class CMAPGroupMapper : public CMAPMapper
60{
61public:
62    CMAPGroupMapper(const CMAPTable *cmap, const CMAPGroup *groups, le_uint32 nGroups);
63
64    virtual ~CMAPGroupMapper();
65
66    virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const;
67
68protected:
69    CMAPGroupMapper() {};
70
71private:
72    le_int32 fPower;
73    le_int32 fRangeOffset;
74    const CMAPGroup *fGroups;
75};
76
77inline CMAPMapper::CMAPMapper(const CMAPTable *cmap)
78    : fcmap(cmap)
79{
80    // nothing else to do
81}
82
83inline CMAPMapper::~CMAPMapper()
84{
85    LE_DELETE_ARRAY(fcmap);
86}
87
88#endif
89
90