Coverage Report

Created: 2025-06-10 06:58

/src/ghostpdl/base/gxchrout.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2001-2023 Artifex Software, Inc.
2
   All Rights Reserved.
3
4
   This software is provided AS-IS with no warranty, either express or
5
   implied.
6
7
   This software is distributed under license and may not be copied,
8
   modified or distributed except as expressly authorized under the terms
9
   of the license contained in the file LICENSE in this distribution.
10
11
   Refer to licensing information at http://www.artifex.com or contact
12
   Artifex Software, Inc.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, for further information.
14
*/
15
16
17
#include "math_.h"
18
#include "gx.h"
19
#include "gxchrout.h"
20
#include "gxfarith.h"
21
#include "gxgstate.h"
22
23
/*
24
 * Determine the flatness for rendering a character in an outline font.
25
 * This may be less than the flatness in the gs_gstate.
26
 * The second argument is the default scaling for the font: 0.001 for
27
 * Type 1 fonts, 1.0 for TrueType fonts.
28
 */
29
double
30
gs_char_flatness(const gs_gstate *pgs, double default_scale)
31
820k
{
32
    /*
33
     * Set the flatness to a value that is likely to produce reasonably
34
     * good-looking curves, regardless of its current value in the
35
     * graphics state.  If the character is very small, set the flatness
36
     * to zero, which will produce very accurate curves.
37
     */
38
820k
    double cxx = fabs(pgs->ctm.xx), cyy = fabs(pgs->ctm.yy);
39
40
820k
    if (is_fzero(cxx) || (cyy < cxx && !is_fzero(cyy)))
41
21
        cxx = cyy;
42
820k
    if (!is_xxyy(&pgs->ctm)) {
43
333
        double cxy = fabs(pgs->ctm.xy), cyx = fabs(pgs->ctm.yx);
44
45
333
        if (is_fzero(cxx) || (cxy < cxx && !is_fzero(cxy)))
46
0
            cxx = cxy;
47
333
        if (is_fzero(cxx) || (cyx < cxx && !is_fzero(cyx)))
48
325
            cxx = cyx;
49
333
    }
50
    /* Correct for the default scaling. */
51
820k
    cxx *= 0.001 / default_scale;
52
    /* Don't let the flatness be worse than the default. */
53
820k
    if (cxx > pgs->flatness)
54
818k
        cxx = pgs->flatness;
55
    /* If the character is tiny, force accurate curves. */
56
820k
    if (cxx < 0.2)
57
820k
        cxx = 0;
58
820k
    return cxx;
59
820k
}