autotroll.m4: Minor comment fixes.
[ttfautohint.git] / lib / tamaxp.c
blobca10f7a7ff1d0173e24519303ef639ffeebb5b80
1 /* tamaxp.c */
3 /*
4 * Copyright (C) 2011-2017 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 (font->dehint)
37 buf[MAXP_MAX_ZONES_OFFSET] = 0;
38 buf[MAXP_MAX_ZONES_OFFSET + 1] = 0;
39 buf[MAXP_MAX_TWILIGHT_POINTS_OFFSET] = 0;
40 buf[MAXP_MAX_TWILIGHT_POINTS_OFFSET + 1] = 0;
41 buf[MAXP_MAX_STORAGE_OFFSET] = 0;
42 buf[MAXP_MAX_STORAGE_OFFSET + 1] = 0;
43 buf[MAXP_MAX_FUNCTION_DEFS_OFFSET] = 0;
44 buf[MAXP_MAX_FUNCTION_DEFS_OFFSET + 1] = 0;
45 buf[MAXP_MAX_INSTRUCTION_DEFS_OFFSET] = 0;
46 buf[MAXP_MAX_INSTRUCTION_DEFS_OFFSET + 1] = 0;
47 buf[MAXP_MAX_STACK_ELEMENTS_OFFSET] = 0;
48 buf[MAXP_MAX_STACK_ELEMENTS_OFFSET + 1] = 0;
49 buf[MAXP_MAX_INSTRUCTIONS_OFFSET] = 0;
50 buf[MAXP_MAX_INSTRUCTIONS_OFFSET + 1] = 0;
52 else
54 if (sfnt->max_components && font->hint_composites)
56 buf[MAXP_NUM_GLYPHS] = HIGH(data->num_glyphs);
57 buf[MAXP_NUM_GLYPHS + 1] = LOW(data->num_glyphs);
58 buf[MAXP_MAX_COMPOSITE_POINTS] = HIGH(sfnt->max_composite_points);
59 buf[MAXP_MAX_COMPOSITE_POINTS + 1] = LOW(sfnt->max_composite_points);
60 buf[MAXP_MAX_COMPOSITE_CONTOURS] = HIGH(sfnt->max_composite_contours);
61 buf[MAXP_MAX_COMPOSITE_CONTOURS + 1] = LOW(sfnt->max_composite_contours);
64 buf[MAXP_MAX_ZONES_OFFSET] = 0;
65 buf[MAXP_MAX_ZONES_OFFSET + 1] = 2;
66 buf[MAXP_MAX_TWILIGHT_POINTS_OFFSET] = HIGH(sfnt->max_twilight_points);
67 buf[MAXP_MAX_TWILIGHT_POINTS_OFFSET + 1] = LOW(sfnt->max_twilight_points);
68 buf[MAXP_MAX_STORAGE_OFFSET] = HIGH(sfnt->max_storage);
69 buf[MAXP_MAX_STORAGE_OFFSET + 1] = LOW(sfnt->max_storage);
70 buf[MAXP_MAX_FUNCTION_DEFS_OFFSET] = 0;
71 buf[MAXP_MAX_FUNCTION_DEFS_OFFSET + 1] = NUM_FDEFS;
72 buf[MAXP_MAX_INSTRUCTION_DEFS_OFFSET] = 0;
73 buf[MAXP_MAX_INSTRUCTION_DEFS_OFFSET + 1] = 0;
74 buf[MAXP_MAX_STACK_ELEMENTS_OFFSET] = HIGH(sfnt->max_stack_elements);
75 buf[MAXP_MAX_STACK_ELEMENTS_OFFSET + 1] = LOW(sfnt->max_stack_elements);
76 buf[MAXP_MAX_INSTRUCTIONS_OFFSET] = HIGH(sfnt->max_instructions);
77 buf[MAXP_MAX_INSTRUCTIONS_OFFSET + 1] = LOW(sfnt->max_instructions);
78 buf[MAXP_MAX_COMPONENTS_OFFSET] = HIGH(sfnt->max_components);
79 buf[MAXP_MAX_COMPONENTS_OFFSET + 1] = LOW(sfnt->max_components);
82 maxp_table->checksum = TA_table_compute_checksum(maxp_table->buf,
83 maxp_table->len);
84 maxp_table->processed = 1;
86 return TA_Err_Ok;
89 /* end of tamaxp.c */