4 * Copyright (C) 2011-2018 by Werner Lemberg.
6 * This file is part of the ttfautohint library, and may only be used,
7 * modified, and distributed under the terms given in `COPYING'. By
8 * continuing to use, modify, or distribute this file you indicate that you
9 * have read `COPYING' and understand and accept it fully.
11 * The file `COPYING' mentioned in the previous paragraph is distributed
12 * with the ttfautohint library.
16 /* originally file `afangles.c' (2011-Mar-28) from FreeType */
18 /* heavily modified 2011 by Werner Lemberg <wl@gnu.org> */
24 /* two bubble sort routines */
27 ta_sort_pos(FT_UInt count
,
34 for (i
= 1; i
< count
; i
++)
36 for (j
= i
; j
> 0; j
--)
38 if (table
[j
] >= table
[j
- 1])
42 table
[j
] = table
[j
- 1];
50 ta_sort_and_quantize_widths(FT_UInt
* count
,
66 for (i
= 1; i
< *count
; i
++)
68 for (j
= i
; j
> 0; j
--)
70 if (table
[j
].org
>= table
[j
- 1].org
)
74 table
[j
] = table
[j
- 1];
80 cur_val
= table
[cur_idx
].org
;
82 /* compute and use mean values for clusters not larger than `threshold'; */
83 /* this is very primitive and might not yield the best result, */
84 /* but normally, using reference character `o', `*count' is 2, */
85 /* so the code below is fully sufficient */
86 for (i
= 1; i
< *count
; i
++)
88 if (table
[i
].org
- cur_val
> threshold
93 /* fix loop for end of array */
94 if (table
[i
].org
- cur_val
<= threshold
98 for (j
= cur_idx
; j
< i
; j
++)
103 table
[cur_idx
].org
= sum
/ (FT_Pos
)j
;
108 cur_val
= table
[cur_idx
].org
;
115 /* compress array to remove zero values */
116 for (i
= 1; i
< *count
; i
++)
119 table
[cur_idx
++] = table
[i
];
125 /* end of tasort.c */