4 * Copyright (C) 2011-2012 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
,
35 for (i
= 1; i
< count
; i
++)
37 for (j
= i
; j
> 0; j
--)
39 if (table
[j
] >= table
[j
- 1])
43 table
[j
] = table
[j
- 1];
51 ta_sort_and_quantize_widths(FT_UInt
* count
,
67 for (i
= 1; i
< *count
; i
++)
69 for (j
= i
; j
> 0; j
--)
71 if (table
[j
].org
>= table
[j
- 1].org
)
75 table
[j
] = table
[j
- 1];
81 cur_val
= table
[cur_idx
].org
;
83 /* compute and use mean values for clusters not larger than `threshold'; */
84 /* this is very primitive and might not yield the best result, */
85 /* but normally, using reference character `o', `*count' is 2, */
86 /* so the code below is fully sufficient */
87 for (i
= 1; i
< *count
; i
++)
89 if (table
[i
].org
- cur_val
> threshold
94 /* fix loop for end of array */
95 if (table
[i
].org
- cur_val
<= threshold
99 for (j
= cur_idx
; j
< i
; j
++)
104 table
[cur_idx
].org
= sum
/ j
;
109 cur_val
= table
[cur_idx
].org
;
116 /* compress array to remove zero values */
117 for (i
= 1; i
< *count
; i
++)
120 table
[cur_idx
++] = table
[i
];
126 /* end of tasort.c */