1 /* 2 * Copyright (C) 1995, 1996 Karl-Johan Johnsson. 3 * 4 * Modified from <X11/Xlibint.h>. 5 */ 6 7 /* 8 9 Copyright (c) 1984, 1985, 1987, 1989 X Consortium 10 11 Permission is hereby granted, free of charge, to any person obtaining 12 a copy of this software and associated documentation files (the 13 "Software"), to deal in the Software without restriction, including 14 without limitation the rights to use, copy, modify, merge, publish, 15 distribute, sublicense, and/or sell copies of the Software, and to 16 permit persons to whom the Software is furnished to do so, subject to 17 the following conditions: 18 19 The above copyright notice and this permission notice shall be included 20 in all copies or substantial portions of the Software. 21 22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 23 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 25 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR 26 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 27 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 OTHER DEALINGS IN THE SOFTWARE. 29 30 Except as contained in this notice, the name of the X Consortium shall 31 not be used in advertising or otherwise to promote the sale, use or 32 other dealings in this Software without prior written authorization 33 from the X Consortium. 34 35 */ 36 37 #define CI_NONEXISTCHAR(cs) ((cs)->width == 0 && \ 38 ((cs)->rbearing | (cs)->lbearing | \ 39 (cs)->ascent | (cs)->descent ) == 0) 40 41 /* 42 * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit 43 * character. If the character is in the column and exists, then return the 44 * appropriate metrics (note that fonts with common per-character metrics will 45 * return min_bounds). If none of these hold true, try again with the default 46 * char. 47 */ 48 #define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \ 49 do { \ 50 unsigned int tmp = col - fs->min_char_or_byte2; \ 51 cs = def; \ 52 if (tmp <= fs->max_char_or_byte2 - fs->min_char_or_byte2) \ 53 if (fs->per_char == NULL) \ 54 cs = &fs->min_bounds; \ 55 else { \ 56 cs = fs->per_char + tmp; \ 57 if (CI_NONEXISTCHAR(cs)) \ 58 cs = def; \ 59 } \ 60 } while (0) 61 62 #define CI_GET_DEFAULT_INFO_1D(fs,cs) \ 63 CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs) 64 65 66 67 /* 68 * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and 69 * column. This is used for fonts that have more than row zero. 70 */ 71 #define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \ 72 do { \ 73 unsigned int tmp1 = row - fs->min_byte1; \ 74 unsigned int tmp2 = col - fs->min_char_or_byte2; \ 75 cs = def; \ 76 if (tmp1 <= fs->max_byte1 - fs->min_byte1 && \ 77 tmp2 <= fs->max_char_or_byte2 - fs->min_char_or_byte2) \ 78 if (fs->per_char == NULL) \ 79 cs = &fs->min_bounds; \ 80 else { \ 81 cs = fs->per_char + tmp2 + tmp1 * \ 82 (fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1); \ 83 if (CI_NONEXISTCHAR(cs)) \ 84 cs = def; \ 85 } \ 86 } while (0) 87 88 #define CI_GET_DEFAULT_INFO_2D(fs,cs) \ 89 { \ 90 unsigned int r = (fs->default_char >> 8); \ 91 unsigned int c = (fs->default_char & 0xff); \ 92 CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \ 93 } 94