Apply result of `update-copyright' script.
[ttfautohint.git] / src / tamaxp.c
blobf618497f01af4190ffda15b8b1c82d0be7a2df48
1 /* tamaxp.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 FT_Error
20 TA_sfnt_update_maxp_table(SFNT* sfnt,
21 FONT* font)
23 SFNT_Table* maxp_table = &font->tables[sfnt->maxp_idx];
24 SFNT_Table* glyf_table = &font->tables[sfnt->glyf_idx];
25 glyf_Data* data = (glyf_Data*)glyf_table->data;
26 FT_Byte* buf = maxp_table->buf;
29 if (maxp_table->processed)
30 return TA_Err_Ok;
32 if (maxp_table->len != MAXP_LEN)
33 return FT_Err_Invalid_Table;
35 if (sfnt->max_components)
37 buf[MAXP_NUM_GLYPHS] = HIGH(data->num_glyphs);
38 buf[MAXP_NUM_GLYPHS + 1] = LOW(data->num_glyphs);
39 buf[MAXP_MAX_COMPOSITE_POINTS] = HIGH(sfnt->max_composite_points);
40 buf[MAXP_MAX_COMPOSITE_POINTS + 1] = LOW(sfnt->max_composite_points);
41 buf[MAXP_MAX_COMPOSITE_CONTOURS] = HIGH(sfnt->max_composite_contours);
42 buf[MAXP_MAX_COMPOSITE_CONTOURS + 1] = LOW(sfnt->max_composite_contours);
45 buf[MAXP_MAX_ZONES_OFFSET] = 0;
46 buf[MAXP_MAX_ZONES_OFFSET + 1] = 2;
47 buf[MAXP_MAX_TWILIGHT_POINTS_OFFSET] = HIGH(sfnt->max_twilight_points);
48 buf[MAXP_MAX_TWILIGHT_POINTS_OFFSET + 1] = LOW(sfnt->max_twilight_points);
49 buf[MAXP_MAX_STORAGE_OFFSET] = HIGH(sfnt->max_storage);
50 buf[MAXP_MAX_STORAGE_OFFSET + 1] = LOW(sfnt->max_storage);
51 buf[MAXP_MAX_FUNCTION_DEFS_OFFSET] = 0;
52 buf[MAXP_MAX_FUNCTION_DEFS_OFFSET + 1] = NUM_FDEFS;
53 buf[MAXP_MAX_INSTRUCTION_DEFS_OFFSET] = 0;
54 buf[MAXP_MAX_INSTRUCTION_DEFS_OFFSET + 1] = 0;
55 buf[MAXP_MAX_STACK_ELEMENTS_OFFSET] = HIGH(sfnt->max_stack_elements);
56 buf[MAXP_MAX_STACK_ELEMENTS_OFFSET + 1] = LOW(sfnt->max_stack_elements);
57 buf[MAXP_MAX_INSTRUCTIONS_OFFSET] = HIGH(sfnt->max_instructions);
58 buf[MAXP_MAX_INSTRUCTIONS_OFFSET + 1] = LOW(sfnt->max_instructions);
59 buf[MAXP_MAX_COMPONENTS_OFFSET] = HIGH(sfnt->max_components);
60 buf[MAXP_MAX_COMPONENTS_OFFSET + 1] = LOW(sfnt->max_components);
63 maxp_table->checksum = TA_table_compute_checksum(maxp_table->buf,
64 maxp_table->len);
65 maxp_table->processed = 1;
67 return TA_Err_Ok;
70 /* end of tamaxp.c */