1 /*
2  * FTGL - OpenGL font library
3  *
4  * Copyright (c) 2001-2004 Henry Maddocks <ftgl@opengl.geek.nz>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
26 #include "config.h"
27 
28 #include "FTLibrary.h"
29 
30 
Instance()31 const FTLibrary&  FTLibrary::Instance()
32 {
33     static FTLibrary ftlib;
34     return ftlib;
35 }
36 
37 
~FTLibrary()38 FTLibrary::~FTLibrary()
39 {
40     if(library != 0)
41     {
42         FT_Done_FreeType(*library);
43 
44         delete library;
45         library= 0;
46     }
47 
48 //  if(manager != 0)
49 //  {
50 //      FTC_Manager_Done(manager);
51 //
52 //      delete manager;
53 //      manager= 0;
54 //  }
55 }
56 
57 
FTLibrary()58 FTLibrary::FTLibrary()
59 :   library(0),
60     err(0)
61 {
62     Initialise();
63 }
64 
65 
Initialise()66 bool FTLibrary::Initialise()
67 {
68     if(library != 0)
69         return true;
70 
71     library = new FT_Library;
72 
73     err = FT_Init_FreeType(library);
74     if(err)
75     {
76         delete library;
77         library = 0;
78         return false;
79     }
80 
81 //  FTC_Manager* manager;
82 //
83 //  if(FTC_Manager_New(lib, 0, 0, 0, my_face_requester, 0, manager)
84 //  {
85 //      delete manager;
86 //      manager= 0;
87 //      return false;
88 //  }
89 
90     return true;
91 }
92