Use `Control_Type' to handle different segment directions.
[ttfautohint.git] / lib / tattfa.c
blob1d140476549c78e81d5a131ed5d7983b9a1432c2
1 /* tattfa.c */
3 /*
4 * Copyright (C) 2014 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 #include "ta.h"
19 FT_Error
20 TA_table_build_TTFA(FT_Byte** TTFA,
21 FT_ULong* TTFA_len,
22 FONT* font)
24 FT_Byte* buf;
25 FT_UInt buf_len;
27 FT_UInt len;
28 FT_Byte* buf_new;
29 FT_Byte* p;
32 buf = (FT_Byte*)TA_font_dump_parameters(font, 0);
33 if (!buf)
34 return FT_Err_Out_Of_Memory;
35 buf_len = strlen((char*)buf);
37 /* buffer length must be a multiple of four */
38 len = (buf_len + 3) & ~3;
39 buf_new = (FT_Byte*)realloc(buf, len);
40 if (!buf_new)
42 free(buf);
43 return FT_Err_Out_Of_Memory;
45 buf = buf_new;
47 /* pad end of buffer with zeros */
48 p = buf + buf_len;
49 switch (buf_len % 4)
51 case 1:
52 *(p++) = 0x00;
53 case 2:
54 *(p++) = 0x00;
55 case 3:
56 *(p++) = 0x00;
57 default:
58 break;
61 *TTFA = buf;
62 *TTFA_len = buf_len;
64 return TA_Err_Ok;
68 /* end of tattfa.c */