Version 0.6.1.
[ttfautohint.git] / src / tagasp.c
blob5ce33699a0f12d5a470067042e32781c2dcabbba
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;
56 FT_Byte* gasp_buf;
59 error = TA_sfnt_add_table_info(sfnt);
60 if (error)
61 return error;
63 error = TA_table_build_gasp(&gasp_buf);
64 if (error)
65 return error;
67 /* in case of success, `gasp_buf' gets linked */
68 /* and is eventually freed in `TA_font_unload' */
69 error = TA_font_add_table(font,
70 &sfnt->table_infos[sfnt->num_table_infos - 1],
71 TTAG_gasp, GASP_LEN, gasp_buf);
72 if (error)
74 free(gasp_buf);
75 return error;
78 return FT_Err_Ok;
81 /* end of tagasp.c */