fontaccel.c revision 23a0898a
123a0898aSmrg/* $Xorg: fontaccel.c,v 1.4 2001/02/09 02:04:04 xorgcvs Exp $ */ 223a0898aSmrg 323a0898aSmrg/* 423a0898aSmrg 523a0898aSmrgCopyright 1990, 1998 The Open Group 623a0898aSmrg 723a0898aSmrgPermission to use, copy, modify, distribute, and sell this software and its 823a0898aSmrgdocumentation for any purpose is hereby granted without fee, provided that 923a0898aSmrgthe above copyright notice appear in all copies and that both that 1023a0898aSmrgcopyright notice and this permission notice appear in supporting 1123a0898aSmrgdocumentation. 1223a0898aSmrg 1323a0898aSmrgThe above copyright notice and this permission notice shall be included 1423a0898aSmrgin all copies or substantial portions of the Software. 1523a0898aSmrg 1623a0898aSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 1723a0898aSmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 1823a0898aSmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 1923a0898aSmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 2023a0898aSmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 2123a0898aSmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 2223a0898aSmrgOTHER DEALINGS IN THE SOFTWARE. 2323a0898aSmrg 2423a0898aSmrgExcept as contained in this notice, the name of The Open Group shall 2523a0898aSmrgnot be used in advertising or otherwise to promote the sale, use or 2623a0898aSmrgother dealings in this Software without prior written authorization 2723a0898aSmrgfrom The Open Group. 2823a0898aSmrg 2923a0898aSmrg*/ 3023a0898aSmrg/* $XFree86: xc/lib/font/util/fontaccel.c,v 1.6 2001/01/17 19:43:33 dawes Exp $ */ 3123a0898aSmrg 3223a0898aSmrg/* 3323a0898aSmrg * Author: Keith Packard, MIT X Consortium 3423a0898aSmrg */ 3523a0898aSmrg 3623a0898aSmrg#ifdef HAVE_CONFIG_H 3723a0898aSmrg#include <config.h> 3823a0898aSmrg#endif 3923a0898aSmrg#include <X11/fonts/fontmisc.h> 4023a0898aSmrg#include <X11/fonts/fontstruct.h> 4123a0898aSmrg#include <X11/fonts/fontutil.h> 4223a0898aSmrg 4323a0898aSmrgvoid 4423a0898aSmrgFontComputeInfoAccelerators(FontInfoPtr pFontInfo) 4523a0898aSmrg{ 4623a0898aSmrg pFontInfo->noOverlap = FALSE; 4723a0898aSmrg if (pFontInfo->maxOverlap <= pFontInfo->minbounds.leftSideBearing) 4823a0898aSmrg pFontInfo->noOverlap = TRUE; 4923a0898aSmrg 5023a0898aSmrg if ((pFontInfo->minbounds.ascent == pFontInfo->maxbounds.ascent) && 5123a0898aSmrg (pFontInfo->minbounds.descent == pFontInfo->maxbounds.descent) && 5223a0898aSmrg (pFontInfo->minbounds.leftSideBearing == 5323a0898aSmrg pFontInfo->maxbounds.leftSideBearing) && 5423a0898aSmrg (pFontInfo->minbounds.rightSideBearing == 5523a0898aSmrg pFontInfo->maxbounds.rightSideBearing) && 5623a0898aSmrg (pFontInfo->minbounds.characterWidth == 5723a0898aSmrg pFontInfo->maxbounds.characterWidth) && 5823a0898aSmrg (pFontInfo->minbounds.attributes == pFontInfo->maxbounds.attributes)) { 5923a0898aSmrg pFontInfo->constantMetrics = TRUE; 6023a0898aSmrg if ((pFontInfo->maxbounds.leftSideBearing == 0) && 6123a0898aSmrg (pFontInfo->maxbounds.rightSideBearing == 6223a0898aSmrg pFontInfo->maxbounds.characterWidth) && 6323a0898aSmrg (pFontInfo->maxbounds.ascent == pFontInfo->fontAscent) && 6423a0898aSmrg (pFontInfo->maxbounds.descent == pFontInfo->fontDescent)) 6523a0898aSmrg pFontInfo->terminalFont = TRUE; 6623a0898aSmrg else 6723a0898aSmrg pFontInfo->terminalFont = FALSE; 6823a0898aSmrg } else { 6923a0898aSmrg pFontInfo->constantMetrics = FALSE; 7023a0898aSmrg pFontInfo->terminalFont = FALSE; 7123a0898aSmrg } 7223a0898aSmrg if (pFontInfo->minbounds.characterWidth == pFontInfo->maxbounds.characterWidth) 7323a0898aSmrg pFontInfo->constantWidth = TRUE; 7423a0898aSmrg else 7523a0898aSmrg pFontInfo->constantWidth = FALSE; 7623a0898aSmrg 7723a0898aSmrg if ((pFontInfo->minbounds.leftSideBearing >= 0) && 7823a0898aSmrg (pFontInfo->maxOverlap <= 0) && 7923a0898aSmrg (pFontInfo->minbounds.ascent >= -pFontInfo->fontDescent) && 8023a0898aSmrg (pFontInfo->maxbounds.ascent <= pFontInfo->fontAscent) && 8123a0898aSmrg (-pFontInfo->minbounds.descent <= pFontInfo->fontAscent) && 8223a0898aSmrg (pFontInfo->maxbounds.descent <= pFontInfo->fontDescent)) 8323a0898aSmrg pFontInfo->inkInside = TRUE; 8423a0898aSmrg else 8523a0898aSmrg pFontInfo->inkInside = FALSE; 8623a0898aSmrg} 8723a0898aSmrg 8823a0898aSmrgint 8923a0898aSmrgFontCouldBeTerminal(FontInfoPtr pFontInfo) 9023a0898aSmrg{ 9123a0898aSmrg if ((pFontInfo->minbounds.leftSideBearing >= 0) && 9223a0898aSmrg (pFontInfo->maxbounds.rightSideBearing <= pFontInfo->maxbounds.characterWidth) && 9323a0898aSmrg (pFontInfo->minbounds.characterWidth == pFontInfo->maxbounds.characterWidth) && 9423a0898aSmrg (pFontInfo->maxbounds.ascent <= pFontInfo->fontAscent) && 9523a0898aSmrg (pFontInfo->maxbounds.descent <= pFontInfo->fontDescent) && 9623a0898aSmrg (pFontInfo->maxbounds.leftSideBearing != 0 || 9723a0898aSmrg pFontInfo->minbounds.rightSideBearing != pFontInfo->minbounds.characterWidth || 9823a0898aSmrg pFontInfo->minbounds.ascent != pFontInfo->fontAscent || 9923a0898aSmrg pFontInfo->minbounds.descent != pFontInfo->fontDescent)) { 10023a0898aSmrg /* blow off font with nothing but a SPACE */ 10123a0898aSmrg if (pFontInfo->maxbounds.ascent == 0 && 10223a0898aSmrg pFontInfo->maxbounds.descent == 0) 10323a0898aSmrg return FALSE; 10423a0898aSmrg return TRUE; 10523a0898aSmrg } 10623a0898aSmrg return FALSE; 10723a0898aSmrg} 108