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