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    "fontmisc.h"
37#include    <X11/fonts/fontstruct.h>
38#include    "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    }
66    else {
67        pFontInfo->constantMetrics = FALSE;
68        pFontInfo->terminalFont = FALSE;
69    }
70    if (pFontInfo->minbounds.characterWidth ==
71        pFontInfo->maxbounds.characterWidth)
72        pFontInfo->constantWidth = TRUE;
73    else
74        pFontInfo->constantWidth = FALSE;
75
76    if ((pFontInfo->minbounds.leftSideBearing >= 0) &&
77        (pFontInfo->maxOverlap <= 0) &&
78        (pFontInfo->minbounds.ascent >= -pFontInfo->fontDescent) &&
79        (pFontInfo->maxbounds.ascent <= pFontInfo->fontAscent) &&
80        (-pFontInfo->minbounds.descent <= pFontInfo->fontAscent) &&
81        (pFontInfo->maxbounds.descent <= pFontInfo->fontDescent))
82        pFontInfo->inkInside = TRUE;
83    else
84        pFontInfo->inkInside = FALSE;
85}
86
87int
88FontCouldBeTerminal(FontInfoPtr pFontInfo)
89{
90    if ((pFontInfo->minbounds.leftSideBearing >= 0) &&
91        (pFontInfo->maxbounds.rightSideBearing <=
92         pFontInfo->maxbounds.characterWidth) &&
93        (pFontInfo->minbounds.characterWidth ==
94         pFontInfo->maxbounds.characterWidth) &&
95        (pFontInfo->maxbounds.ascent <= pFontInfo->fontAscent) &&
96        (pFontInfo->maxbounds.descent <= pFontInfo->fontDescent) &&
97        (pFontInfo->maxbounds.leftSideBearing != 0 ||
98         pFontInfo->minbounds.rightSideBearing !=
99         pFontInfo->minbounds.characterWidth ||
100         pFontInfo->minbounds.ascent != pFontInfo->fontAscent ||
101         pFontInfo->minbounds.descent != pFontInfo->fontDescent)) {
102        /* blow off font with nothing but a SPACE */
103        if (pFontInfo->maxbounds.ascent == 0 &&
104            pFontInfo->maxbounds.descent == 0)
105            return FALSE;
106        return TRUE;
107    }
108    return FALSE;
109}
110