1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
/* $XTermId: luitconv.h,v 1.37 2021/02/18 19:23:20 tom Exp $ */
/*
Copyright 2010-2019,2021 by Thomas E. Dickey
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef LUITCONV_H
#define LUITCONV_H
#ifdef USE_ICONV
#include <other.h>
#include <iconv.h>
typedef enum {
umNONE = 0
,umPOSIX = 1
,umBUILTIN = 2
,umFONTENC = 4
,umICONV = 8
,umANY = (umPOSIX | umBUILTIN | umFONTENC | umICONV)
} UM_MODE;
typedef enum {
usANY = 1
,us8BIT = 2
,us16BIT = 4
} US_SIZE;
#define FONT_ENCODING_UNICODE 1
typedef struct _FontMap {
int type;
unsigned (*recode) (unsigned, void *); /* mapping function */
void *client_data; /* second parameter of the two above */
struct _FontMap *next; /* link to next element in list */
} FontMapRec, *FontMapPtr;
typedef struct _FontMapReverse {
unsigned int (*reverse) (unsigned, void *);
void *data;
} FontMapReverseRec, *FontMapReversePtr;
typedef struct _FontEnc {
char *name; /* the name of the encoding */
char **aliases; /* its aliases, null terminated */
int size; /* its size, either in bytes or rows */
int row_size; /* the size of a row, or 0 if bytes */
FontMapPtr mappings; /* linked list of mappings */
struct _FontEnc *next; /* link to next element */
/* the following two were added in version 0.2 of the font interface */
/* they should be kept at the end to preserve binary compatibility */
int first; /* first byte or row */
int first_col; /* first column in each row */
} FontEncRec, *FontEncPtr;
typedef struct {
size_t size; /* length of text[] */
char *text; /* value, in UTF-8 */
unsigned ucs; /* corresponding Unicode value */
} MappingData;
typedef struct {
unsigned ucs;
unsigned ch;
} ReverseData;
typedef struct _LuitConv {
struct _LuitConv *next;
char *encoding_name;
iconv_t iconv_desc;
/* internal tables for input/output */
MappingData *table_utf8; /* UTF-8 equivalents of 8-bit codes */
ReverseData *rev_index; /* reverse-index */
size_t len_index; /* index length */
size_t table_size; /* length of table_utf8[] and rev_index[] */
/* data expected by caller */
FontMapRec mapping;
FontMapReverseRec reverse;
} LuitConv;
typedef struct {
unsigned source;
unsigned target;
} BuiltInMapping;
typedef struct _BuiltInCharset {
const char *name; /* table name, for lookups */
const BuiltInMapping *table;
size_t length; /* length of table[] */
} BuiltInCharsetRec;
extern UM_MODE lookup_order[];
extern FontEncPtr luitGetFontEnc(const char *, UM_MODE);
extern FontMapPtr luitLookupMapping(const char *, UM_MODE, US_SIZE);
extern FontMapReversePtr luitLookupReverse(FontMapPtr);
extern LuitConv *luitLookupEncoding(FontMapPtr);
extern const BuiltInCharsetRec builtin_encodings[];
extern unsigned luitMapCodeValue(unsigned, FontMapPtr);
extern void luitFreeFontEnc(FontEncPtr);
#ifdef NO_LEAKS
extern void luitDestroyReverse(FontMapReversePtr);
#endif
#define LookupMapping(encoding_name,usize) \
luitLookupMapping(encoding_name, umANY, usize)
#define LookupReverse(fontmap_ptr) \
luitLookupReverse(fontmap_ptr)
#define MapCodeValue(code, fontmap_ptr) \
luitMapCodeValue(code, fontmap_ptr)
#else /* !USE_ICONV */
#include <X11/fonts/fontenc.h>
#define LookupMapping(encoding_name,usize) \
FontEncMapFind(encoding_name, FONT_ENCODING_UNICODE, -1, -1, NULL)
#define LookupReverse(fontmap_ptr) \
FontMapReverse(fontmap_ptr)
#define MapCodeValue(code, fontmap_ptr) \
FontEncRecode(code, fontmap_ptr)
#endif /* USE_ICONV */
typedef unsigned short UCode;
typedef struct _FontEncSimpleMap {
unsigned len; /* might be 0x10000 */
UCode row_size;
UCode first;
UCode *map; /* fontenc makes this const */
} FontEncSimpleMapRec, *FontEncSimpleMapPtr;
#ifdef FONT_ENCODING_POSTSCRIPT
typedef struct _FontEncSimpleName {
unsigned len;
UCode first;
char **map;
} FontEncSimpleNameRec, *FontEncSimpleNamePtr;
#endif /* FONT_ENCODING_POSTSCRIPT */
#define MIN_UCODE 0x0000
#define MAX_UCODE 0xffff
#define rowOf(code) ((code) / 0x100)
#define colOf(code) ((code) & 0xff)
extern FontEncPtr lookupOneFontenc(const char *);
extern int reportBuiltinCharsets(void);
extern int reportFontencCharsets(void);
extern int reportIconvCharsets(void);
extern int showBuiltinCharset(const char *);
extern int showFontencCharset(const char *);
extern int showIconvCharset(const char *);
extern int typeOfFontenc(FontEncPtr);
extern unsigned luitRecode(unsigned, void *);
extern unsigned shiftOfFontenc(FontEncPtr);
#endif /* LUITCONV_H */
|