~ubuntu-branches/ubuntu/hardy/texmacs/hardy

« back to all changes in this revision

Viewing changes to src/Plugins/Freetype/free_type.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ralf Treinen
  • Date: 2004-04-19 20:34:00 UTC
  • Revision ID: james.westby@ubuntu.com-20040419203400-g4e34ih0315wcn8v
Tags: upstream-1.0.3-R2
ImportĀ upstreamĀ versionĀ 1.0.3-R2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/******************************************************************************
 
3
* MODULE     : free_type.cpp
 
4
* DESCRIPTION: Interface with Free Type II
 
5
* COPYRIGHT  : (C) 2003  Joris van der Hoeven
 
6
*******************************************************************************
 
7
* This software falls under the GNU general public license and comes WITHOUT
 
8
* ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
 
9
* If you don't have this file, write to the Free Software Foundation, Inc.,
 
10
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
11
******************************************************************************/
 
12
 
 
13
#include "Freetype/free_type.hpp"
 
14
#include "Link/dyn_link.hpp"
 
15
 
 
16
#ifdef USE_FREETYPE
 
17
 
 
18
static bool ft_initialized= false;
 
19
static bool ft_error      = true;
 
20
 
 
21
FT_Library ft_library;
 
22
 
 
23
FT_Error (*ft_init_freetype)  (FT_Library     *alibrary);
 
24
FT_Error (*ft_new_face)       (FT_Library     library,
 
25
                               const char*    filepathname,
 
26
                               FT_Long        face_index,
 
27
                               FT_Face*       aface);
 
28
FT_Error (*ft_set_char_size)  (FT_Face        face,
 
29
                               FT_F26Dot6     char_width,
 
30
                               FT_F26Dot6     char_height,
 
31
                               FT_UInt        horz_resolution,
 
32
                               FT_UInt        vert_resolution);
 
33
FT_UInt  (*ft_get_char_index) (FT_Face        face,
 
34
                               FT_ULong       charcode);
 
35
FT_Error (*ft_load_glyph)     (FT_Face        face,
 
36
                               FT_UInt        glyph_index,
 
37
                               FT_Int         load_flags);
 
38
FT_Error (*ft_render_glyph)   (FT_GlyphSlot   slot,
 
39
                               FT_Render_Mode render_mode);
 
40
 
 
41
typedef FT_Error (*glyph_renderer) (FT_GlyphSlot, FT_Render_Mode);
 
42
 
 
43
bool
 
44
ft_initialize () {
 
45
  if (ft_initialized) return ft_error;
 
46
  ft_initialized= true;
 
47
#ifdef LINKED_FREETYPE
 
48
  ft_init_freetype = FT_Init_FreeType;
 
49
  ft_new_face      = FT_New_Face;
 
50
  ft_set_char_size = FT_Set_Char_Size;
 
51
  ft_get_char_index= FT_Get_Char_Index;
 
52
  ft_load_glyph    = FT_Load_Glyph;
 
53
  ft_render_glyph  = (glyph_renderer) ((void*) FT_Render_Glyph);
 
54
  if (ft_init_freetype (&ft_library)) return true;
 
55
  if (DEBUG_AUTO) cout << "TeXmacs] With linked TrueType support\n";
 
56
#else
 
57
  int status= debug_off ();
 
58
  (void) symbol_install ("/usr/lib/libfreetype.so", "FT_Init_FreeType" ,
 
59
                         (pointer&) ft_init_freetype);
 
60
  if (ft_init_freetype == NULL) return true;
 
61
  (void) symbol_install ("/usr/lib/libfreetype.so", "FT_New_Face"      ,
 
62
                         (pointer&) ft_new_face);
 
63
  if (ft_new_face == NULL) return true;
 
64
  (void) symbol_install ("/usr/lib/libfreetype.so", "FT_Set_Char_Size" ,
 
65
                         (pointer&) ft_set_char_size);
 
66
  if (ft_set_char_size == NULL) return true;
 
67
  (void) symbol_install ("/usr/lib/libfreetype.so", "FT_Get_Char_Index",
 
68
                         (pointer&) ft_get_char_index);
 
69
  if (ft_get_char_index == NULL) return true;
 
70
  (void) symbol_install ("/usr/lib/libfreetype.so", "FT_Load_Glyph"    ,
 
71
                         (pointer&) ft_load_glyph);
 
72
  if (ft_load_glyph == NULL) return true;
 
73
  (void) symbol_install ("/usr/lib/libfreetype.so", "FT_Render_Glyph"  ,
 
74
                         (pointer&) ft_render_glyph);
 
75
  if (ft_render_glyph == NULL) return true;
 
76
  debug_on (status);
 
77
  if (ft_init_freetype (&ft_library)) return true;
 
78
  if (DEBUG_AUTO) cout << "TeXmacs] Installed TrueType support\n";
 
79
#endif
 
80
  ft_error= false;
 
81
  return false;
 
82
}
 
83
 
 
84
bool
 
85
ft_present () {
 
86
  return !ft_initialize ();
 
87
}
 
88
 
 
89
#else
 
90
 
 
91
bool ft_initialize () { return true; }
 
92
bool ft_present () { return false; }
 
93
 
 
94
#endif