Comment formatting, minor improvement.
[ttfautohint.git] / lib / tafile.c
blob8729c0f4a2c31069f548931385699d850db506c4
1 /* tafile.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_font_file_read(FONT* font,
21 FILE* in_file)
23 fseek(in_file, 0, SEEK_END);
24 font->in_len = ftell(in_file);
25 fseek(in_file, 0, SEEK_SET);
27 /* a valid TTF can never be that small */
28 if (font->in_len < 100)
29 return FT_Err_Invalid_Argument;
31 font->in_buf = (FT_Byte*)malloc(font->in_len);
32 if (!font->in_buf)
33 return FT_Err_Out_Of_Memory;
35 if (fread(font->in_buf, 1, font->in_len, in_file) != font->in_len)
36 return FT_Err_Invalid_Stream_Read;
38 return TA_Err_Ok;
42 FT_Error
43 TA_font_file_write(FONT* font,
44 FILE* out_file)
46 if (fwrite(font->out_buf, 1, font->out_len, out_file) != font->out_len)
47 return TA_Err_Invalid_Stream_Write;
49 return TA_Err_Ok;
52 /* end of tafile.c */