`number_set_parse': Improve diagnostics.
[ttfautohint.git] / lib / tagasp.c
blob9e530eff556db9add5f6b27a4a910200acb8583b
1 /* tagasp.c */
3 /*
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 #include "ta.h"
19 static FT_Error
20 TA_table_build_gasp(FT_Byte** gasp)
22 FT_Byte* buf;
25 buf = (FT_Byte*)malloc(GASP_LEN);
26 if (!buf)
27 return FT_Err_Out_Of_Memory;
29 /* version */
30 buf[0] = 0x00;
31 buf[1] = 0x01;
33 /* one range */
34 buf[2] = 0x00;
35 buf[3] = 0x01;
37 /* entry valid for all sizes */
38 buf[4] = 0xFF;
39 buf[5] = 0xFF;
40 buf[6] = 0x00;
41 buf[7] = 0x0F; /* always use grayscale rendering with grid-fitting, */
42 /* symmetric grid-fitting and symmetric smoothing */
44 *gasp = buf;
46 return TA_Err_Ok;
50 FT_Error
51 TA_sfnt_build_gasp_table(SFNT* sfnt,
52 FONT* font)
54 FT_Error error = FT_Err_Ok;
56 FT_Byte* gasp_buf;
59 error = TA_sfnt_add_table_info(sfnt);
60 if (error)
61 goto Exit;
63 if (font->gasp_idx != MISSING)
65 sfnt->table_infos[sfnt->num_table_infos - 1] = font->gasp_idx;
66 goto Exit;
69 error = TA_table_build_gasp(&gasp_buf);
70 if (error)
71 goto Exit;
73 /* in case of success, `gasp_buf' gets linked */
74 /* and is eventually freed in `TA_font_unload' */
75 error = TA_font_add_table(font,
76 &sfnt->table_infos[sfnt->num_table_infos - 1],
77 TTAG_gasp, GASP_LEN, gasp_buf);
78 if (error)
79 free(gasp_buf);
80 else
81 font->gasp_idx = sfnt->table_infos[sfnt->num_table_infos - 1];
83 Exit:
84 return error;
87 /* end of tagasp.c */