Coverage Report

Created: 2025-06-10 07:27

/src/ghostpdl/base/gxchrout.c
Line
Count
Source
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
55.8k
{
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
55.8k
    double cxx = fabs(pgs->ctm.xx), cyy = fabs(pgs->ctm.yy);
39
40
55.8k
    if (is_fzero(cxx) || (cyy < cxx && !is_fzero(cyy)))
41
10.4k
        cxx = cyy;
42
55.8k
    if (!is_xxyy(&pgs->ctm)) {
43
10.1k
        double cxy = fabs(pgs->ctm.xy), cyx = fabs(pgs->ctm.yx);
44
45
10.1k
        if (is_fzero(cxx) || (cxy < cxx && !is_fzero(cxy)))
46
4.89k
            cxx = cxy;
47
10.1k
        if (is_fzero(cxx) || (cyx < cxx && !is_fzero(cyx)))
48
3.43k
            cxx = cyx;
49
10.1k
    }
50
    /* Correct for the default scaling. */
51
55.8k
    cxx *= 0.001 / default_scale;
52
    /* Don't let the flatness be worse than the default. */
53
55.8k
    if (cxx > pgs->flatness)
54
8.84k
        cxx = pgs->flatness;
55
    /* If the character is tiny, force accurate curves. */
56
55.8k
    if (cxx < 0.2)
57
45.8k
        cxx = 0;
58
55.8k
    return cxx;
59
55.8k
}