1/* 2 3Copyright 1990, 1998 The Open Group 4 5Permission to use, copy, modify, distribute, and sell this software and its 6documentation for any purpose is hereby granted without fee, provided that 7the above copyright notice appear in all copies and that both that 8copyright notice and this permission notice appear in supporting 9documentation. 10 11The above copyright notice and this permission notice shall be included 12in all copies or substantial portions of the Software. 13 14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 18OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20OTHER DEALINGS IN THE SOFTWARE. 21 22Except as contained in this notice, the name of The Open Group shall 23not be used in advertising or otherwise to promote the sale, use or 24other dealings in this Software without prior written authorization 25from The Open Group. 26 27*/ 28 29/* 30 * Author: Keith Packard, MIT X Consortium 31 */ 32 33#ifdef HAVE_CONFIG_H 34#include <config.h> 35#endif 36#include <X11/fonts/fontmisc.h> 37#include <X11/fonts/fontstruct.h> 38#include <X11/fonts/fontutil.h> 39 40void 41FontComputeInfoAccelerators(FontInfoPtr pFontInfo) 42{ 43 pFontInfo->noOverlap = FALSE; 44 if (pFontInfo->maxOverlap <= pFontInfo->minbounds.leftSideBearing) 45 pFontInfo->noOverlap = TRUE; 46 47 if ((pFontInfo->minbounds.ascent == pFontInfo->maxbounds.ascent) && 48 (pFontInfo->minbounds.descent == pFontInfo->maxbounds.descent) && 49 (pFontInfo->minbounds.leftSideBearing == 50 pFontInfo->maxbounds.leftSideBearing) && 51 (pFontInfo->minbounds.rightSideBearing == 52 pFontInfo->maxbounds.rightSideBearing) && 53 (pFontInfo->minbounds.characterWidth == 54 pFontInfo->maxbounds.characterWidth) && 55 (pFontInfo->minbounds.attributes == pFontInfo->maxbounds.attributes)) { 56 pFontInfo->constantMetrics = TRUE; 57 if ((pFontInfo->maxbounds.leftSideBearing == 0) && 58 (pFontInfo->maxbounds.rightSideBearing == 59 pFontInfo->maxbounds.characterWidth) && 60 (pFontInfo->maxbounds.ascent == pFontInfo->fontAscent) && 61 (pFontInfo->maxbounds.descent == pFontInfo->fontDescent)) 62 pFontInfo->terminalFont = TRUE; 63 else 64 pFontInfo->terminalFont = FALSE; 65 } else { 66 pFontInfo->constantMetrics = FALSE; 67 pFontInfo->terminalFont = FALSE; 68 } 69 if (pFontInfo->minbounds.characterWidth == pFontInfo->maxbounds.characterWidth) 70 pFontInfo->constantWidth = TRUE; 71 else 72 pFontInfo->constantWidth = FALSE; 73 74 if ((pFontInfo->minbounds.leftSideBearing >= 0) && 75 (pFontInfo->maxOverlap <= 0) && 76 (pFontInfo->minbounds.ascent >= -pFontInfo->fontDescent) && 77 (pFontInfo->maxbounds.ascent <= pFontInfo->fontAscent) && 78 (-pFontInfo->minbounds.descent <= pFontInfo->fontAscent) && 79 (pFontInfo->maxbounds.descent <= pFontInfo->fontDescent)) 80 pFontInfo->inkInside = TRUE; 81 else 82 pFontInfo->inkInside = FALSE; 83} 84 85int 86FontCouldBeTerminal(FontInfoPtr pFontInfo) 87{ 88 if ((pFontInfo->minbounds.leftSideBearing >= 0) && 89 (pFontInfo->maxbounds.rightSideBearing <= pFontInfo->maxbounds.characterWidth) && 90 (pFontInfo->minbounds.characterWidth == pFontInfo->maxbounds.characterWidth) && 91 (pFontInfo->maxbounds.ascent <= pFontInfo->fontAscent) && 92 (pFontInfo->maxbounds.descent <= pFontInfo->fontDescent) && 93 (pFontInfo->maxbounds.leftSideBearing != 0 || 94 pFontInfo->minbounds.rightSideBearing != pFontInfo->minbounds.characterWidth || 95 pFontInfo->minbounds.ascent != pFontInfo->fontAscent || 96 pFontInfo->minbounds.descent != pFontInfo->fontDescent)) { 97 /* blow off font with nothing but a SPACE */ 98 if (pFontInfo->maxbounds.ascent == 0 && 99 pFontInfo->maxbounds.descent == 0) 100 return FALSE; 101 return TRUE; 102 } 103 return FALSE; 104} 105