fontenc.h revision 3da084b3
13da084b3Smrg/* 23da084b3SmrgCopyright (c) 1998-2001 by Juliusz Chroboczek 33da084b3Smrg 43da084b3SmrgPermission is hereby granted, free of charge, to any person obtaining a copy 53da084b3Smrgof this software and associated documentation files (the "Software"), to deal 63da084b3Smrgin the Software without restriction, including without limitation the rights 73da084b3Smrgto use, copy, modify, merge, publish, distribute, sublicense, and/or sell 83da084b3Smrgcopies of the Software, and to permit persons to whom the Software is 93da084b3Smrgfurnished to do so, subject to the following conditions: 103da084b3Smrg 113da084b3SmrgThe above copyright notice and this permission notice shall be included in 123da084b3Smrgall copies or substantial portions of the Software. 133da084b3Smrg 143da084b3SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 153da084b3SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 163da084b3SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 173da084b3SmrgAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 183da084b3SmrgLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 193da084b3SmrgOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 203da084b3SmrgTHE SOFTWARE. 213da084b3Smrg*/ 223da084b3Smrg 233da084b3Smrg/* $XFree86: xc/lib/font/include/fontenc.h,v 1.7 2000/11/14 16:54:45 dawes Exp $ */ 243da084b3Smrg 253da084b3Smrg/* Header for backend-independent encoding code */ 263da084b3Smrg 273da084b3Smrg/* An encoding is identified with a name. An encoding contains some 283da084b3Smrg global encoding data, such as its size, and a set of mappings. 293da084b3Smrg Mappings are identified by their type and two integers, known as 303da084b3Smrg pid and eid, the interpretation of which is type dependent. */ 313da084b3Smrg 323da084b3Smrg#ifndef _FONTENC_H 333da084b3Smrg#define _FONTENC_H 343da084b3Smrg 353da084b3Smrg/* Encoding types. For future extensions, clients should be prepared 363da084b3Smrg to ignore unknown encoding types. */ 373da084b3Smrg 383da084b3Smrg/* 0 is treated specially. */ 393da084b3Smrg 403da084b3Smrg#define FONT_ENCODING_UNICODE 1 413da084b3Smrg#define FONT_ENCODING_TRUETYPE 2 423da084b3Smrg#define FONT_ENCODING_POSTSCRIPT 3 433da084b3Smrg 443da084b3Smrg/* This structure represents a mapping, either from numeric codes from 453da084b3Smrg numeric codes, or from numeric codes to strings. */ 463da084b3Smrg 473da084b3Smrg/* It is expected that only one of `recode' and `name' will actually 483da084b3Smrg be present. However, having both fields simplifies the interface 493da084b3Smrg somewhat. */ 503da084b3Smrg 513da084b3Smrgtypedef struct _FontMap { 523da084b3Smrg int type; /* the type of the mapping */ 533da084b3Smrg int pid, eid; /* the identification of the mapping */ 543da084b3Smrg unsigned (*recode)(unsigned, void*); /* mapping function */ 553da084b3Smrg char *(*name)(unsigned, void*); /* function returning glyph names */ 563da084b3Smrg void *client_data; /* second parameter of the two above */ 573da084b3Smrg struct _FontMap *next; /* link to next element in list */ 583da084b3Smrg /* The following was added for version 0.3 of the font interface. */ 593da084b3Smrg /* It should be kept at the end to preserve binary compatibility. */ 603da084b3Smrg struct _FontEnc *encoding; 613da084b3Smrg} FontMapRec, *FontMapPtr; 623da084b3Smrg 633da084b3Smrg/* This is the structure that holds all the info for one encoding. It 643da084b3Smrg consists of a charset name, its size, and a linked list of mappings 653da084b3Smrg like above. */ 663da084b3Smrg 673da084b3Smrgtypedef struct _FontEnc { 683da084b3Smrg char *name; /* the name of the encoding */ 693da084b3Smrg char **aliases; /* its aliases, null terminated */ 703da084b3Smrg int size; /* its size, either in bytes or rows */ 713da084b3Smrg int row_size; /* the size of a row, or 0 if bytes */ 723da084b3Smrg FontMapPtr mappings; /* linked list of mappings */ 733da084b3Smrg struct _FontEnc *next; /* link to next element */ 743da084b3Smrg /* the following two were added in version 0.2 of the font interface */ 753da084b3Smrg /* they should be kept at the end to preserve binary compatibility */ 763da084b3Smrg int first; /* first byte or row */ 773da084b3Smrg int first_col; /* first column in each row */ 783da084b3Smrg} FontEncRec, *FontEncPtr; 793da084b3Smrg 803da084b3Smrgtypedef struct _FontMapReverse { 813da084b3Smrg unsigned int (*reverse)(unsigned, void*); 823da084b3Smrg void *data; 833da084b3Smrg} FontMapReverseRec, *FontMapReversePtr; 843da084b3Smrg 853da084b3Smrg 863da084b3Smrg/* Function prototypes */ 873da084b3Smrg 883da084b3Smrg/* extract an encoding name from an XLFD name. Returns a pointer to a 893da084b3Smrg *static* buffer, or NULL */ 903da084b3Smrgchar *FontEncFromXLFD(const char*, int); 913da084b3Smrg 923da084b3Smrg/* find the encoding data for a given encoding name; second parameter 933da084b3Smrg is the filename of the font for which the encoding is needed. 943da084b3Smrg Returns NULL on failure. */ 953da084b3SmrgFontEncPtr FontEncFind(const char*, const char*); 963da084b3Smrg 973da084b3Smrg/* Find a given mapping for an encoding. This is only a convenience 983da084b3Smrg function, as clients are allowed to scavenge the data structures 993da084b3Smrg themselves (as the TrueType backend does). */ 1003da084b3Smrg 1013da084b3SmrgFontMapPtr FontMapFind(FontEncPtr, int, int, int); 1023da084b3Smrg 1033da084b3Smrg/* Do both in a single step */ 1043da084b3SmrgFontMapPtr FontEncMapFind(const char *, int, int, int, const char *); 1053da084b3Smrg 1063da084b3Smrg/* Recode a code. Always succeeds. */ 1073da084b3Smrgunsigned FontEncRecode(unsigned, FontMapPtr); 1083da084b3Smrg 1093da084b3Smrg/* Return a name for a code. Returns a string or NULL. */ 1103da084b3Smrgchar *FontEncName(unsigned, FontMapPtr); 1113da084b3Smrg 1123da084b3Smrg/* Return a pointer to the name of the system encodings directory. */ 1133da084b3Smrg/* This string is static and should not be modified. */ 1143da084b3Smrgchar* FontEncDirectory(void); 1153da084b3Smrg 1163da084b3Smrg/* Identify an encoding file. If fileName doesn't exist, or is not an 1173da084b3Smrg encoding file, return NULL, otherwise returns a NULL-terminated 1183da084b3Smrg array of strings. */ 1193da084b3Smrgchar **FontEncIdentify(const char *fileName); 1203da084b3Smrg 1213da084b3SmrgFontMapReversePtr FontMapReverse(FontMapPtr); 1223da084b3Smrg 1233da084b3Smrgvoid FontMapReverseFree(FontMapReversePtr); 1243da084b3Smrg#endif 125