revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / freetype2 / freetype-2.10.0-aros.diff
blobbd5d62ed7ae8158317b7559e1ef845493d7fdd2f
1 diff -ruN freetype-2.10.0/builds/aros/src/base/ftsystem.c freetype-2.10.0.aros/builds/aros/src/base/ftsystem.c
2 --- freetype-2.10.0/builds/aros/src/base/ftsystem.c 1970-01-01 01:00:00.000000000 +0100
3 +++ freetype-2.10.0.aros/builds/aros/src/base/ftsystem.c 2019-04-11 14:31:03.250183154 +0200
4 @@ -0,0 +1,359 @@
5 +/***************************************************************************/
6 +/* */
7 +/* ftsystem.c */
8 +/* */
9 +/* ANSI-specific FreeType low-level system interface (body). */
10 +/* */
11 +/* Copyright 1996-2018 by */
12 +/* David Turner, Robert Wilhelm, and Werner Lemberg. */
13 +/* */
14 +/* This file is part of the FreeType project, and may only be used, */
15 +/* modified, and distributed under the terms of the FreeType project */
16 +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
17 +/* this file you indicate that you have read the license and */
18 +/* understand and accept it fully. */
19 +/* */
20 +/***************************************************************************/
22 + /*************************************************************************/
23 + /* */
24 + /* This file contains the default interface used by FreeType to access */
25 + /* low-level, i.e. memory management, i/o access as well as thread */
26 + /* synchronisation. It can be replaced by user-specific routines if */
27 + /* necessary. */
28 + /* */
29 + /*************************************************************************/
32 +#include <ft2build.h>
33 +#include FT_CONFIG_CONFIG_H
34 +#include FT_INTERNAL_DEBUG_H
35 +#include FT_SYSTEM_H
36 +#include FT_ERRORS_H
37 +#include FT_TYPES_H
39 +#include <stdio.h>
40 +#include <stdlib.h>
42 +#include <exec/types.h>
43 +#include <exec/memory.h>
44 +#include <dos/dos.h>
45 +#include <proto/exec.h>
46 +#include <proto/dos.h>
48 +//#define DEBUG 1
49 +#include <aros/debug.h>
52 + /*************************************************************************/
53 + /* */
54 + /* MEMORY MANAGEMENT INTERFACE */
55 + /* */
56 + /*************************************************************************/
58 + /*************************************************************************/
59 + /* */
60 + /* It is not necessary to do any error checking for the */
61 + /* allocation-related functions. This will be done by the higher level */
62 + /* routines like FT_Alloc() or FT_Realloc(). */
63 + /* */
64 + /*************************************************************************/
67 + /*************************************************************************/
68 + /* */
69 + /* <Function> */
70 + /* ft_alloc */
71 + /* */
72 + /* <Description> */
73 + /* The memory allocation function. */
74 + /* */
75 + /* <Input> */
76 + /* memory :: A pointer to the memory object. */
77 + /* */
78 + /* size :: The requested size in bytes. */
79 + /* */
80 + /* <Return> */
81 + /* The address of newly allocated block. */
82 + /* */
83 + FT_CALLBACK_DEF( void* )
84 + ft_alloc( FT_Memory memory,
85 + long size )
86 + {
87 + ULONG memsize = size + sizeof(ULONG);
88 + void* retval;
89 + APTR MemPool = (APTR)memory->user;
91 + D(bug("Entering ft_alloc(memory=%x,size=%ld)\n", memory, size));
93 + retval = AllocPooled(MemPool, memsize);
95 + D(bug("Allocated retval=%x\n", (void*)retval));
97 + *((ULONG *)retval) = memsize;
99 + D(bug("Leaving ft_alloc retval=%x\n", (void*)((ULONG*)retval + 1)));
101 + return (void*)((ULONG*)retval + 1);
105 + /*************************************************************************/
106 + /* */
107 + /* <Function> */
108 + /* ft_free */
109 + /* */
110 + /* <Description> */
111 + /* The memory release function. */
112 + /* */
113 + /* <Input> */
114 + /* memory :: A pointer to the memory object. */
115 + /* */
116 + /* block :: The address of block in memory to be freed. */
117 + /* */
118 + FT_CALLBACK_DEF( void )
119 + ft_free( FT_Memory memory,
120 + void* block )
122 + APTR mem = (APTR)((char*)block - sizeof(ULONG));
123 + APTR MemPool = (APTR)memory->user;
125 + D(bug("Entering ft_free(memory=%x, block=%x)\n", memory, block));
127 + FreePooled( MemPool, mem, *((ULONG*)mem) );
129 + D(bug("Leaving ft_free\n"));
133 + /*************************************************************************/
134 + /* */
135 + /* <Function> */
136 + /* ft_realloc */
137 + /* */
138 + /* <Description> */
139 + /* The memory reallocation function. */
140 + /* */
141 + /* <Input> */
142 + /* memory :: A pointer to the memory object. */
143 + /* */
144 + /* cur_size :: The current size of the allocated memory block. */
145 + /* */
146 + /* new_size :: The newly requested size in bytes. */
147 + /* */
148 + /* block :: The current address of the block in memory. */
149 + /* */
150 + /* <Return> */
151 + /* The address of the reallocated memory block. */
152 + /* */
153 + FT_CALLBACK_DEF( void* )
154 + ft_realloc( FT_Memory memory,
155 + long cur_size,
156 + long new_size,
157 + void* block )
159 + void* retval;
161 + D(bug("Entering ft_free(memory=%x, cur_size=%ld, new_size=%ld, block=%x)\n",
162 + memory, cur_size, new_size, block));
164 + if ((retval = ft_alloc( memory, new_size )) != NULL)
166 + CopyMem( block, retval, cur_size );
167 + ft_free( memory, block );
170 + D(bug("Leaving ft_free retval=%x\n", retval));
172 + return retval;
176 + /*************************************************************************/
177 + /* */
178 + /* RESOURCE MANAGEMENT INTERFACE */
179 + /* */
180 + /*************************************************************************/
183 + /*************************************************************************/
184 + /* */
185 + /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
186 + /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
187 + /* messages during execution. */
188 + /* */
189 +#undef FT_COMPONENT
190 +#define FT_COMPONENT trace_io
192 + /* We use the macro STREAM_FILE for convenience to extract the */
193 + /* system-specific stream handle from a given FreeType stream object */
194 +#define STREAM_FILE( stream ) ( (BPTR)stream->descriptor.pointer )
197 + /*************************************************************************/
198 + /* */
199 + /* <Function> */
200 + /* ft_ansi_stream_close */
201 + /* */
202 + /* <Description> */
203 + /* The function to close a stream. */
204 + /* */
205 + /* <Input> */
206 + /* stream :: A pointer to the stream object. */
207 + /* */
208 + FT_CALLBACK_DEF( void )
209 + ft_ansi_stream_close( FT_Stream stream )
211 + D(bug("Entering ft_ansi_stream_close(stream=%x)\n", stream));
213 + Close( STREAM_FILE( stream ) );
215 + stream->descriptor.pointer = NULL;
216 + stream->size = 0;
217 + stream->base = 0;
219 + D(bug("Entering ft_ansi_stream_close\n"));
223 + /*************************************************************************/
224 + /* */
225 + /* <Function> */
226 + /* ft_ansi_stream_io */
227 + /* */
228 + /* <Description> */
229 + /* The function to open a stream. */
230 + /* */
231 + /* <Input> */
232 + /* stream :: A pointer to the stream object. */
233 + /* */
234 + /* offset :: The position in the data stream to start reading. */
235 + /* */
236 + /* buffer :: The address of buffer to store the read data. */
237 + /* */
238 + /* count :: The number of bytes to read from the stream. */
239 + /* */
240 + /* <Return> */
241 + /* The number of bytes actually read. */
242 + /* */
243 + FT_CALLBACK_DEF( unsigned long )
244 + ft_ansi_stream_io( FT_Stream stream,
245 + unsigned long offset,
246 + unsigned char* buffer,
247 + unsigned long count )
249 + BPTR file;
250 + unsigned long actcount;
252 + D(bug("Entering ft_ansi_stream_io(stream=%x,offset=%ld,buffer=%x,count=%ld)\n",
253 + stream, offset, buffer, count));
254 + file = STREAM_FILE( stream );
256 + Seek( file, offset, OFFSET_BEGINNING );
257 + if (count>0)
258 + actcount = (unsigned long)Read( file, buffer, count );
259 + else
260 + actcount = 0;
262 + D(bug("Leaving ft_ansi_stream_io actcount=%ld",actcount));
264 + return actcount;
268 + /* documentation is in ftobjs.h */
270 + FT_EXPORT_DEF( FT_Error )
271 + FT_Stream_Open( FT_Stream stream,
272 + const char* filepathname )
274 + BPTR file;
276 + if ( !stream )
277 + return FT_Err_Invalid_Stream_Handle;
279 + file = Open( filepathname, MODE_OLDFILE );
280 + if ( !file )
282 + FT_ERROR(( "FT_Stream_Open:" ));
283 + FT_ERROR(( " could not open `%s'\n", filepathname ));
285 + return FT_Err_Cannot_Open_Resource;
288 + Seek( file, 0, OFFSET_END );
289 + stream->size = Seek( file, 0, OFFSET_BEGINNING );
291 + stream->descriptor.pointer = (APTR)file;
292 + stream->pathname.pointer = (char*)filepathname;
293 + stream->pos = 0;
295 + stream->read = ft_ansi_stream_io;
296 + stream->close = ft_ansi_stream_close;
298 + FT_TRACE1(( "FT_Stream_Open:" ));
299 + FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
300 + filepathname, stream->size ));
302 + return FT_Err_Ok;
306 +#ifdef FT_DEBUG_MEMORY
308 + extern FT_Int
309 + ft_mem_debug_init( FT_Memory memory );
311 + extern void
312 + ft_mem_debug_done( FT_Memory memory );
314 +#endif
317 + /* documentation is in ftobjs.h */
319 + FT_EXPORT_DEF( FT_Memory )
320 + FT_New_Memory( void )
322 + FT_Memory memory;
323 + APTR MemPool;
325 + D(bug("Entering FT_New_Memory\n"));
327 + MemPool = CreatePool(MEMF_ANY, 2048, 256);
328 + if (MemPool)
330 + memory = (FT_Memory)AllocPooled( MemPool, sizeof ( *memory ) );
331 + if ( memory )
333 + memory->user = (void*)MemPool;
334 + memory->alloc = ft_alloc;
335 + memory->realloc = ft_realloc;
336 + memory->free = ft_free;
337 +#ifdef FT_DEBUG_MEMORY
338 + ft_mem_debug_init( memory );
339 +#endif
342 + else
343 + memory=NULL;
345 + D(bug("Leaving FT_New_Memory memory=%x\n", memory));
347 + return memory;
351 + /* documentation is in ftobjs.h */
353 + FT_EXPORT_DEF( void )
354 + FT_Done_Memory( FT_Memory memory )
356 +#ifdef FT_DEBUG_MEMORY
357 + ft_mem_debug_done( memory );
358 +#endif
359 + DeletePool((APTR)memory->user);
363 +/* END */
364 diff -ruN freetype-2.10.0/src/autofit/afcjk.c freetype-2.10.0.aros/src/autofit/afcjk.c
365 --- freetype-2.10.0/src/autofit/afcjk.c 2019-02-23 10:06:07.000000000 +0100
366 +++ freetype-2.10.0.aros/src/autofit/afcjk.c 2019-04-11 14:31:46.282454489 +0200
367 @@ -22,6 +22,9 @@
371 +#include <exec/exec.h>
372 +#include <proto/exec.h>
374 #include <ft2build.h>
375 #include FT_ADVANCES_H
376 #include FT_INTERNAL_DEBUG_H
377 @@ -70,8 +73,13 @@
378 FT_Face face )
380 /* scan the array of segments in each direction */
381 - AF_GlyphHintsRec hints[1];
383 + //AF_GlyphHintsRec hints[1];
384 + AF_GlyphHintsRec *hints = (AF_GlyphHintsRec *)AllocVec(sizeof(AF_GlyphHintsRec) * 2, MEMF_ANY);
385 + if(!hints)
387 + /* no reasonable error handling possible */
388 + return;
391 FT_TRACE5(( "\n"
392 "cjk standard widths computation (style `%s')\n"
393 @@ -88,7 +96,12 @@
394 FT_Error error;
395 FT_ULong glyph_index;
396 int dim;
397 - AF_CJKMetricsRec dummy[1];
398 + //AF_CJKMetricsRec dummy[1];
399 + AF_CJKMetricsRec *dummy = (AF_CJKMetricsRec *) AllocVec(sizeof(AF_CJKMetricsRec) * 2, MEMF_ANY);
400 + if(!dummy)
402 + goto ErrorExit;
404 AF_Scaler scaler = &dummy->root.scaler;
406 AF_StyleClass style_class = metrics->root.style_class;
407 @@ -269,11 +282,15 @@
409 #endif
411 + FreeVec(dummy);
412 + ErrorExit:
416 FT_TRACE5(( "\n" ));
418 af_glyph_hints_done( hints );
419 + FreeVec(hints);
423 diff -ruN freetype-2.10.0/src/autofit/aflatin2.c freetype-2.10.0.aros/src/autofit/aflatin2.c
424 --- freetype-2.10.0/src/autofit/aflatin2.c 2019-02-23 10:06:07.000000000 +0100
425 +++ freetype-2.10.0.aros/src/autofit/aflatin2.c 2019-04-11 14:31:46.282454489 +0200
426 @@ -20,7 +20,6 @@
431 #include FT_ADVANCES_H
434 @@ -68,8 +67,13 @@
435 FT_Face face )
437 /* scan the array of segments in each direction */
438 - AF_GlyphHintsRec hints[1];
440 + //AF_GlyphHintsRec hints[1];
441 + AF_GlyphHintsRec *hints = (AF_GlyphHintsRec *)AllocVec(sizeof(AF_GlyphHintsRec) * 2, MEMF_ANY);
442 + if(!hints)
444 + /* no reasonable error handling possible */
445 + return;
448 af_glyph_hints_init( hints, face->memory );
450 @@ -80,7 +84,12 @@
451 FT_Error error;
452 FT_UInt glyph_index;
453 int dim;
454 - AF_LatinMetricsRec dummy[1];
455 + //AF_LatinMetricsRec dummy[1];
456 + AF_LatinMetricsRec *dummy = (AF_LatinMetricsRec *) AllocVec(sizeof(AF_LatinMetricsRec) * 2, MEMF_ANY);
457 + if(!dummy)
459 + goto ErrorExit;
461 AF_Scaler scaler = &dummy->root.scaler;
464 @@ -167,9 +176,12 @@
465 axis->standard_width = stdw;
466 axis->extra_light = 0;
468 + ErrorExit:
469 + FreeVec(dummy);
472 af_glyph_hints_done( hints );
473 + FreeVec(hints);
477 diff -ruN freetype-2.10.0/src/autofit/aflatin.c freetype-2.10.0.aros/src/autofit/aflatin.c
478 --- freetype-2.10.0/src/autofit/aflatin.c 2019-02-23 10:06:07.000000000 +0100
479 +++ freetype-2.10.0.aros/src/autofit/aflatin.c 2019-04-11 14:31:46.282454489 +0200
480 @@ -15,6 +15,8 @@
484 +#include <exec/exec.h>
485 +#include <proto/exec.h>
487 #include <ft2build.h>
488 #include FT_ADVANCES_H
489 @@ -61,8 +63,8 @@
490 FT_Face face )
492 /* scan the array of segments in each direction */
493 - AF_GlyphHintsRec hints[1];
495 + //AF_GlyphHintsRec hints[1];
496 + AF_GlyphHintsRec *hints;
498 FT_TRACE5(( "\n"
499 "latin standard widths computation (style `%s')\n"
500 @@ -70,6 +72,13 @@
501 "\n",
502 af_style_names[metrics->root.style_class->style] ));
504 + hints = (AF_GlyphHintsRec *)AllocVec(sizeof(AF_GlyphHintsRec) * 2, MEMF_ANY);
505 + if(!hints)
507 + /* no reasonable error handling possible */
508 + return;
511 af_glyph_hints_init( hints, face->memory );
513 metrics->axis[AF_DIMENSION_HORZ].width_count = 0;
514 @@ -79,7 +88,12 @@
515 FT_Error error;
516 FT_ULong glyph_index;
517 int dim;
518 - AF_LatinMetricsRec dummy[1];
519 + //AF_LatinMetricsRec dummy[1];
520 + AF_LatinMetricsRec *dummy = (AF_LatinMetricsRec *) AllocVec(sizeof(AF_LatinMetricsRec) * 2, MEMF_ANY);
522 + if(!dummy)
523 + goto ErrorExit;
525 AF_Scaler scaler = &dummy->root.scaler;
527 AF_StyleClass style_class = metrics->root.style_class;
528 @@ -261,12 +275,17 @@
529 FT_TRACE5(( "\n" ));
531 #endif
534 + FreeVec(dummy);
535 + ErrorExit:
539 FT_TRACE5(( "\n" ));
541 af_glyph_hints_done( hints );
542 + FreeVec(hints);
546 diff -ruN freetype-2.10.0/src/autofit/afmodule.c freetype-2.10.0.aros/src/autofit/afmodule.c
547 --- freetype-2.10.0/src/autofit/afmodule.c 2019-02-23 10:06:07.000000000 +0100
548 +++ freetype-2.10.0.aros/src/autofit/afmodule.c 2019-04-11 14:31:46.282454489 +0200
549 @@ -523,8 +523,19 @@
551 #else /* !FT_DEBUG_AUTOFIT */
553 - AF_GlyphHintsRec hints[1];
554 - AF_LoaderRec loader[1];
555 + //AF_GlyphHintsRec hints[1];
556 + AF_GlyphHintsRec *hints = (AF_GlyphHintsRec *)AllocVec(sizeof(AF_GlyphHintsRec) * 2, MEMF_ANY);
557 + if(!hints)
559 + return !FT_Err_Ok; /* ? */
561 + //AF_LoaderRec loader[1];
562 + AF_LoaderRec *loader = (AF_LoaderRec *)AllocVec(sizeof(AF_LoaderRec) * 2, MEMF_ANY);
563 + if(!loader)
565 + FreeVec(hints);
566 + return !FT_Err_Ok; /* ? */
569 FT_UNUSED( size );
571 @@ -538,6 +549,9 @@
572 af_loader_done( loader );
573 af_glyph_hints_done( hints );
575 + FreeVec(hints);
576 + FreeVec(loader);
578 return error;
580 #endif /* !FT_DEBUG_AUTOFIT */