basepic.c revision fb6b5b10aaa74b8c8974714b41bac35bdd1c772d
1894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/***************************************************************************/
2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*                                                                         */
3894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*  basepic.c                                                              */
4894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*                                                                         */
5894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*    The FreeType position independent code services for base.            */
6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*                                                                         */
7894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*  Copyright 2009-2015 by                                                 */
8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*  Oran Agra and Mickey Gabel.                                            */
9894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*                                                                         */
10894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*  This file is part of the FreeType project, and may only be used,       */
11894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*  modified, and distributed under the terms of the FreeType project      */
12894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
13894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*  this file you indicate that you have read the license and              */
14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*  understand and accept it fully.                                        */
15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/*                                                                         */
16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/***************************************************************************/
17894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
19894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include <ft2build.h>
20894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include FT_FREETYPE_H
21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include FT_INTERNAL_OBJECTS_H
22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "basepic.h"
23894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
24894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
25894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifdef FT_CONFIG_OPTION_PIC
26894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
27894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /* forward declaration of PIC init functions from ftglyph.c */
28894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  void
29894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  FT_Init_Class_ft_outline_glyph_class( FT_Glyph_Class*  clazz );
30894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
31894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  void
32894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  FT_Init_Class_ft_bitmap_glyph_class( FT_Glyph_Class*  clazz );
33894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
34894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifdef FT_CONFIG_OPTION_MAC_FONTS
35894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /* forward declaration of PIC init function from ftrfork.c */
36894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /* (not modularized)                                       */
37894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  void
38894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  FT_Init_Table_ft_raccess_guess_table( ft_raccess_guess_rec*  record );
39894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
40894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
41894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  /* forward declaration of PIC init functions from ftinit.c */
42894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  FT_Error
43894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ft_create_default_module_classes( FT_Library  library );
44894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
45894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  void
46894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ft_destroy_default_module_classes( FT_Library  library );
47894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
48894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
49894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  void
50894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ft_base_pic_free( FT_Library  library )
51894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  {
52894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    FT_PIC_Container*  pic_container = &library->pic_container;
53894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    FT_Memory          memory        = library->memory;
54894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
55894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
56894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    if ( pic_container->base )
57894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    {
58894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      /* destroy default module classes            */
59894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      /* (in case FT_Add_Default_Modules was used) */
60894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      ft_destroy_default_module_classes( library );
61894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
62894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      FT_FREE( pic_container->base );
63894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      pic_container->base = NULL;
64894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    }
65894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  }
66894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
67894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
68894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  FT_Error
69894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  ft_base_pic_init( FT_Library  library )
70894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  {
71894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    FT_PIC_Container*  pic_container = &library->pic_container;
72894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    FT_Error           error         = FT_Err_Ok;
73894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    BasePIC*           container     = NULL;
74894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    FT_Memory          memory        = library->memory;
75894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
76894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
77894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    /* allocate pointer, clear and set global container pointer */
78894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    if ( FT_ALLOC( container, sizeof ( *container ) ) )
79894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      return error;
80894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    FT_MEM_SET( container, 0, sizeof ( *container ) );
81894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    pic_container->base = container;
82894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
83894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    /* initialize default modules list and pointers */
84894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    error = ft_create_default_module_classes( library );
85894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    if ( error )
86894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      goto Exit;
87894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
88894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    /* initialize pointer table -                       */
89894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    /* this is how the module usually expects this data */
90894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    FT_Init_Class_ft_outline_glyph_class(
91894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      &container->ft_outline_glyph_class );
92894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    FT_Init_Class_ft_bitmap_glyph_class(
93894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      &container->ft_bitmap_glyph_class );
94894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#ifdef FT_CONFIG_OPTION_MAC_FONTS
95894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    FT_Init_Table_ft_raccess_guess_table(
96894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      (ft_raccess_guess_rec*)&container->ft_raccess_guess_table );
97894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif
98894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
99894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  Exit:
100894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    if ( error )
101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman      ft_base_pic_free( library );
102894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman    return error;
103894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman  }
104894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
105894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#endif /* FT_CONFIG_OPTION_PIC */
106894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
107894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman
108894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman/* END */
109894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman