Home | History | Annotate | Download | only in layout
      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 
     20 #ifndef __CMAPS_H
     21 #define __CMAPS_H
     22 
     23 #include "layout/LETypes.h"
     24 #include "sfnt.h"
     25 
     26 class CMAPMapper
     27 {
     28 public:
     29     virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const = 0;
     30 
     31     virtual ~CMAPMapper();
     32 
     33     static CMAPMapper *createUnicodeMapper(const CMAPTable *cmap);
     34 
     35 protected:
     36     CMAPMapper(const CMAPTable *cmap);
     37 
     38     CMAPMapper() {};
     39 
     40 private:
     41     const CMAPTable *fcmap;
     42 };
     43 
     44 class CMAPFormat4Mapper : public CMAPMapper
     45 {
     46 public:
     47     CMAPFormat4Mapper(const CMAPTable *cmap, const CMAPFormat4Encoding *header);
     48 
     49     virtual ~CMAPFormat4Mapper();
     50 
     51     virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const;
     52 
     53 protected:
     54     CMAPFormat4Mapper() {};
     55 
     56 private:
     57     le_uint16        fEntrySelector;
     58     le_uint16        fRangeShift;
     59     const le_uint16 *fEndCodes;
     60     const le_uint16 *fStartCodes;
     61     const le_uint16 *fIdDelta;
     62     const le_uint16 *fIdRangeOffset;
     63 };
     64 
     65 class CMAPGroupMapper : public CMAPMapper
     66 {
     67 public:
     68     CMAPGroupMapper(const CMAPTable *cmap, const CMAPGroup *groups, le_uint32 nGroups);
     69 
     70     virtual ~CMAPGroupMapper();
     71 
     72     virtual LEGlyphID unicodeToGlyph(LEUnicode32 unicode32) const;
     73 
     74 protected:
     75     CMAPGroupMapper() {};
     76 
     77 private:
     78     le_int32 fPower;
     79     le_int32 fRangeOffset;
     80     const CMAPGroup *fGroups;
     81 };
     82 
     83 inline CMAPMapper::CMAPMapper(const CMAPTable *cmap)
     84     : fcmap(cmap)
     85 {
     86     // nothing else to do
     87 }
     88 
     89 inline CMAPMapper::~CMAPMapper()
     90 {
     91     LE_DELETE_ARRAY(fcmap);
     92 }
     93 
     94 #endif
     95 
     96