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.
19 #define BUF_SIZE 0x10000
22 TA_font_file_read(FONT
* font
,
25 FT_Byte buf
[BUF_SIZE
];
30 font
->in_buf
= (FT_Byte
*)malloc(BUF_SIZE
);
32 return FT_Err_Out_Of_Memory
;
34 while ((read_bytes
= fread(buf
, 1, BUF_SIZE
, in_file
)) > 0)
39 in_buf_new
= (FT_Byte
*)realloc(font
->in_buf
, in_len
+ read_bytes
);
41 return FT_Err_Out_Of_Memory
;
43 font
->in_buf
= in_buf_new
;
45 memcpy(font
->in_buf
+ in_len
, buf
, read_bytes
);
51 return FT_Err_Invalid_Stream_Read
;
53 /* a valid TTF can never be that small */
55 return TA_Err_Invalid_Font_Type
;
57 font
->in_len
= in_len
;
64 TA_font_file_write(FONT
* font
,
67 if (fwrite(font
->out_buf
, 1, font
->out_len
, out_file
) != font
->out_len
)
68 return TA_Err_Invalid_Stream_Write
;