/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 | 8.52M | { |
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 | 8.52M | double cxx = fabs(pgs->ctm.xx), cyy = fabs(pgs->ctm.yy); |
39 | | |
40 | 8.52M | if (is_fzero(cxx) || (cyy < cxx && !is_fzero(cyy))) |
41 | 424k | cxx = cyy; |
42 | 8.52M | if (!is_xxyy(&pgs->ctm)) { |
43 | 410k | double cxy = fabs(pgs->ctm.xy), cyx = fabs(pgs->ctm.yx); |
44 | | |
45 | 410k | if (is_fzero(cxx) || (cxy < cxx && !is_fzero(cxy))) |
46 | 157k | cxx = cxy; |
47 | 410k | if (is_fzero(cxx) || (cyx < cxx && !is_fzero(cyx))) |
48 | 43.3k | cxx = cyx; |
49 | 410k | } |
50 | | /* Correct for the default scaling. */ |
51 | 8.52M | cxx *= 0.001 / default_scale; |
52 | | /* Don't let the flatness be worse than the default. */ |
53 | 8.52M | if (cxx > pgs->flatness) |
54 | 1.90M | cxx = pgs->flatness; |
55 | | /* If the character is tiny, force accurate curves. */ |
56 | 8.52M | if (cxx < 0.2) |
57 | 8.26M | cxx = 0; |
58 | 8.52M | return cxx; |
59 | 8.52M | } |