cmaps.h 2.1 KB

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