1 //========================================================================
5 // Copyright 2001-2003 Glyph & Cog, LLC
7 //========================================================================
9 //========================================================================
11 // Modified under the Poppler project - http://poppler.freedesktop.org
13 // All changes made under the Poppler project to this file are licensed
14 // under GPL version 2 or later
16 // Copyright (C) 2008 Koji Otani <sho@bbr.jp>
17 // Copyright (C) 2009 Albert Astals Cid <aacid@kde.org>
18 // Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
20 // To see a description of the changes please see the Changelog file that
21 // came with your tarball or type make ChangeLog if you are building from git
23 //========================================================================
28 #ifdef USE_GCC_PRAGMAS
32 #include "poppler-config.h"
33 #include "goo/gtypes.h"
34 #include "CharTypes.h"
37 #include "goo/GooMutex.h"
42 struct CMapVectorEntry
;
46 //------------------------------------------------------------------------
51 // Parse a CMap from <obj>, which can be a name or a stream. Sets
52 // the initial reference count to 1. Returns NULL on failure.
53 static CMap
*parse(CMapCache
*cache
, GooString
*collectionA
, Object
*obj
);
55 // Create the CMap specified by <collection> and <cMapName>. Sets
56 // the initial reference count to 1. Returns NULL on failure.
57 static CMap
*parse(CMapCache
*cache
, GooString
*collectionA
,
58 GooString
*cMapNameA
);
60 // Parse a CMap from <str>. Sets the initial reference count to 1.
61 // Returns NULL on failure.
62 static CMap
*parse(CMapCache
*cache
, GooString
*collectionA
, Stream
*str
);
64 // Create the CMap specified by <collection> and <cMapName>. Sets
65 // the initial reference count to 1.
66 // Stream is a stream containing the CMap, can be NULL and
67 // this means the CMap will be searched in the CMap files
68 // Returns NULL on failure.
69 static CMap
*parse(CMapCache
*cache
, GooString
*collectionA
,
70 GooString
*cMapNameA
, Stream
*stream
);
77 // Return collection name (<registry>-<ordering>).
78 GooString
*getCollection() { return collection
; }
80 GooString
*getCMapName() { return cMapName
; }
82 // Return true if this CMap matches the specified <collectionA>, and
84 GBool
match(GooString
*collectionA
, GooString
*cMapNameA
);
86 // Return the CID corresponding to the character code starting at
87 // <s>, which contains <len> bytes. Sets *<c> to the char code, and
88 // *<nUsed> to the number of bytes used by the char code.
89 CID
getCID(char *s
, int len
, CharCode
*c
, int *nUsed
);
91 // Return the writing mode (0=horizontal, 1=vertical).
92 int getWMode() { return wMode
; }
94 void setReverseMap(Guint
*rmap
, Guint rmapSize
, Guint ncand
);
98 void parse2(CMapCache
*cache
, int (*getCharFunc
)(void *), void *data
);
99 CMap(GooString
*collectionA
, GooString
*cMapNameA
);
100 CMap(GooString
*collectionA
, GooString
*cMapNameA
, int wModeA
);
101 void useCMap(CMapCache
*cache
, char *useName
);
102 void useCMap(CMapCache
*cache
, Object
*obj
);
103 void copyVector(CMapVectorEntry
*dest
, CMapVectorEntry
*src
);
104 void addCIDs(Guint start
, Guint end
, Guint nBytes
, CID firstCID
);
105 void freeCMapVector(CMapVectorEntry
*vec
);
106 void setReverseMapVector(Guint startCode
, CMapVectorEntry
*vec
,
107 Guint
*rmap
, Guint rmapSize
, Guint ncand
);
109 GooString
*collection
;
111 GBool isIdent
; // true if this CMap is an identity mapping,
112 // or is based on one (via usecmap)
113 int wMode
; // writing mode (0=horizontal, 1=vertical)
114 CMapVectorEntry
*vector
; // vector for first byte (NULL for
122 //------------------------------------------------------------------------
124 #define cMapCacheSize 4
132 // Get the <cMapName> CMap for the specified character collection.
133 // Increments its reference count; there will be one reference for
134 // the cache plus one for the caller of this function.
135 // Stream is a stream containing the CMap, can be NULL and
136 // this means the CMap will be searched in the CMap files
137 // Returns NULL on failure.
138 CMap
*getCMap(GooString
*collection
, GooString
*cMapName
, Stream
*stream
);
142 CMap
*cache
[cMapCacheSize
];