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