Source

Coin / src / glue / freetype.cpp

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
/**************************************************************************\
 * Copyright (c) Kongsberg Oil & Gas Technologies AS
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * 
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * Neither the name of the copyright holder nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\**************************************************************************/

#ifdef HAVE_CONFIG_H
#include "config.h"
#else /* No config.h? Hmm. Assume the freetype library is available for linking. */
#define FREETYPEGLUE_ASSUME_FREETYPE 1
#endif /* !HAVE_CONFIG_H */

#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stddef.h>

#include <sys/stat.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif /* HAVE_SYS_TYPES_H */

#ifdef HAVE_FONTCONFIG
#include <fontconfig/fontconfig.h>
#endif

#ifdef HAVE_FREETYPE /* In case we're _not_ doing runtime linking. */
#define FREETYPEGLUE_ASSUME_FREETYPE 1
#include <ft2build.h>
#include <freetype/freetype.h>
#include <freetype/ftglyph.h>
#include <freetype/ftoutln.h>
#endif /* FREETYPEGLUE_ASSUME_FREETYPE */

#include <Inventor/C/basic.h>
#include <Inventor/C/glue/dl.h>
#include <Inventor/C/tidbits.h>
#include <Inventor/C/errors/debugerror.h>

#include "tidbitsp.h"
#include "glue/freetype.h"
#include "threads/threadsutilp.h"

typedef int (*cc_fcglue_FcGetVersion_t)(void);
typedef FcPattern * (*cc_fcglue_FcNameParse_t)(const unsigned char * name);
typedef int (*cc_fcglue_FcConfigSubstitute_t)(void * config, FcPattern * p, FcMatchKind kind);
typedef void (*cc_fcglue_FcDefaultSubstitute_t)(FcPattern *pattern);
typedef FcPattern * (*cc_fcglue_FcFontMatch_t)(void * config, FcPattern * p, FcResult * result);
typedef FcResult (*cc_fcglue_FcPatternGetString_t)(const FcPattern * p, const char * object, int n, unsigned char ** s);
typedef void (*cc_fcglue_FcPatternDestroy_t)(FcPattern * p);
typedef void (*cc_fcglue_FcPatternPrint_t)(const FcPattern * p);
typedef int (*cc_fcglue_FcPatternAddDouble_t)(FcPattern *p, const char *object, double d);

typedef struct {
  int available;
  cc_fcglue_FcGetVersion_t FcGetVersion;
  cc_fcglue_FcNameParse_t FcNameParse;
  cc_fcglue_FcConfigSubstitute_t FcConfigSubstitute;
  cc_fcglue_FcDefaultSubstitute_t FcDefaultSubstitute;
  cc_fcglue_FcFontMatch_t FcFontMatch;
  cc_fcglue_FcPatternGetString_t FcPatternGetString;
  cc_fcglue_FcPatternDestroy_t FcPatternDestroy;
  cc_fcglue_FcPatternPrint_t FcPatternPrint;
  cc_fcglue_FcPatternAddDouble_t FcPatternAddDouble;
} cc_fcglue_t;

typedef FT_Error (*cc_ftglue_FT_Init_FreeType_t)(FT_Library * library);
typedef void (*cc_ftglue_FT_Library_Version_t)(void * library, int * major, int * minor, int * patch);
typedef FT_Error (*cc_ftglue_FT_Done_FreeType_t)(void * library);
typedef FT_Error (*cc_ftglue_FT_New_Face_t)(void * library, const char * filepathname, long faceindex, FT_Face * face);
typedef FT_Error (*cc_ftglue_FT_Done_Face_t)(void * face);
typedef FT_Error (*cc_ftglue_FT_Select_Charmap_t)(FT_Face face, int encoding);
typedef FT_Error (*cc_ftglue_FT_Set_Char_Size_t)(FT_Face face, long width, long height, unsigned int hres, unsigned int vres);
typedef void (*cc_ftglue_FT_Set_Transform_t)(FT_Face face, FT_Matrix * matrix, FT_Vector * delta);
typedef FT_UInt (*cc_ftglue_FT_Get_Char_Index_t)(FT_Face face, unsigned long charidx);
typedef FT_Error (*cc_ftglue_FT_Load_Glyph_t)(FT_Face face, unsigned int glyph, int32_t loadflags);
typedef FT_Error (*cc_ftglue_FT_Get_Kerning_t)(FT_Face face, unsigned int left, unsigned int right, unsigned int kernmode, FT_Vector * akerning);
typedef FT_Error (*cc_ftglue_FT_Get_Glyph_t)(void * glyphslot, FT_Glyph * glyph);
typedef FT_Error (*cc_ftglue_FT_Glyph_To_Bitmap_t)(FT_Glyph * glyph, int rendermode, FT_Vector * origin, int destroy);
typedef void (*cc_ftglue_FT_Done_Glyph_t)(FT_Glyph glyph);
typedef FT_Error (*cc_ftglue_FT_Outline_Decompose_t)(FT_Outline * outline, const FT_Outline_Funcs * func_interface, void * user);
typedef FT_Error (*cc_ftglue_FT_Render_Glyph_t)(void * glyphslot, int rendermode);

typedef struct {
  int available;
  cc_ftglue_FT_Init_FreeType_t FT_Init_FreeType;
  cc_ftglue_FT_Library_Version_t FT_Library_Version;
  cc_ftglue_FT_Done_FreeType_t FT_Done_FreeType;
  cc_ftglue_FT_New_Face_t FT_New_Face;
  cc_ftglue_FT_Done_Face_t  FT_Done_Face;
  cc_ftglue_FT_Select_Charmap_t FT_Select_Charmap; 
  cc_ftglue_FT_Set_Char_Size_t FT_Set_Char_Size;
  cc_ftglue_FT_Set_Transform_t FT_Set_Transform;
  cc_ftglue_FT_Get_Char_Index_t FT_Get_Char_Index;
  cc_ftglue_FT_Load_Glyph_t FT_Load_Glyph;
  cc_ftglue_FT_Get_Kerning_t FT_Get_Kerning;
  cc_ftglue_FT_Get_Glyph_t FT_Get_Glyph; 
  cc_ftglue_FT_Glyph_To_Bitmap_t FT_Glyph_To_Bitmap; 
  cc_ftglue_FT_Done_Glyph_t FT_Done_Glyph;
  cc_ftglue_FT_Outline_Decompose_t FT_Outline_Decompose;
} cc_ftglue_t;

static cc_fcglue_t * fontconfig_instance = NULL;
static cc_libhandle fontconfig_libhandle = NULL;
static int fontconfig_failed_to_load = 0;

static cc_ftglue_t * freetype_instance = NULL;
static cc_libhandle freetype_libhandle = NULL;
static int freetype_failed_to_load = 0;

/* Cleans up fontconfig at exit. */
static void
fcglue_cleanup(void)
{
#ifdef FONTCONFIG_RUNTIME_LINKING
  if (fontconfig_libhandle) {
    cc_dl_close(fontconfig_libhandle);
    fontconfig_libhandle = NULL;
  }
#endif /* FONTCONFIG_RUNTIME_LINKING */
  assert(fontconfig_instance);
  free(fontconfig_instance);
  fontconfig_instance = NULL;
  fontconfig_failed_to_load = 0;
}

static const cc_fcglue_t *
fcglue_init(void)
{
  CC_SYNC_BEGIN(fcglue_init);

  if (!fontconfig_instance && !fontconfig_failed_to_load) {
    /* First invocation, do initializations. */
    cc_fcglue_t * fi = (cc_fcglue_t *)malloc(sizeof(cc_fcglue_t));
    (void)coin_atexit((coin_atexit_f *)fcglue_cleanup, CC_ATEXIT_DYNLIBS);

    /* The common case is that fontconfig is either available from the
       linking process or we're successfully going to link it in. */
    fi->available = 1;

#ifdef FONTCONFIG_RUNTIME_LINKING
    {
      int idx;
      /* FIXME: should we get the system shared library name from an
         Autoconf check? 20000930 mortene. */
      const char * possiblelibnames[] = {
        NULL, /* is set below */
        "fontconfig", "libfontconfig", "libfontconfig.so",
        "libfontconfig.dylib",
        NULL
      };
      possiblelibnames[0] = coin_getenv("COIN_FONTCONFIG_LIBNAME");
      idx = possiblelibnames[0] ? 0 : 1;
      while (!fontconfig_libhandle && possiblelibnames[idx]) {
        fontconfig_libhandle = cc_dl_open(possiblelibnames[idx]);
        idx++;
      }

      if (!fontconfig_libhandle) {
        fi->available = 0;
        fontconfig_failed_to_load = 1;
      }
    }
    /* Define FCGLUE_REGISTER_FUNC macro. Casting the type is
       necessary for this file to be compatible with C++ compilers. */
#define FCGLUE_REGISTER_FUNC(_funcsig_, _funcname_) \
    do { \
      fi->_funcname_ = (_funcsig_)cc_dl_sym(fontconfig_libhandle, SO__QUOTE(_funcname_)); \
      if (fi->_funcname_ == NULL) fi->available = 0; \
    } while (0)

#elif defined(FONTCONFIGGLUE_ASSUME_FONTCONFIG) /* !FONTCONFIG_RUNTIME_LINKING */

    /* Define FCGLUE_REGISTER_FUNC macro. */
#define FCGLUE_REGISTER_FUNC(_funcsig_, _funcname_) \
    fi->_funcname_ = (_funcsig_)_funcname_

#else /* !FONTCONFIGGLUE_ASSUME_FONTCONFIG */
    fi->available = 0;
    /* Define FCGLUE_REGISTER_FUNC macro. */
#define FCGLUE_REGISTER_FUNC(_funcsig_, _funcname_) \
    fi->_funcname_ = NULL

#endif /* !FONTCONFIGGLUE_ASSUME_FONTCONFIG */

    FCGLUE_REGISTER_FUNC(cc_fcglue_FcGetVersion_t, FcGetVersion);

    if (fi->available && (!fi->FcGetVersion)) {
      /* something is seriously wrong */
      cc_debugerror_post("fontconfig glue",
                         "Loaded fontconfig DLL ok, but couldn't resolve some symbols.");
      fi->available = 0;
      fontconfig_failed_to_load = 1;
      fontconfig_instance = fi;
    }
    else {
      FCGLUE_REGISTER_FUNC(cc_fcglue_FcNameParse_t, FcNameParse);
      FCGLUE_REGISTER_FUNC(cc_fcglue_FcConfigSubstitute_t, FcConfigSubstitute);
      FCGLUE_REGISTER_FUNC(cc_fcglue_FcDefaultSubstitute_t, FcDefaultSubstitute); 
      FCGLUE_REGISTER_FUNC(cc_fcglue_FcFontMatch_t, FcFontMatch);
      FCGLUE_REGISTER_FUNC(cc_fcglue_FcPatternGetString_t, FcPatternGetString);
      FCGLUE_REGISTER_FUNC(cc_fcglue_FcPatternDestroy_t, FcPatternDestroy);
      FCGLUE_REGISTER_FUNC(cc_fcglue_FcPatternPrint_t, FcPatternPrint);
      FCGLUE_REGISTER_FUNC(cc_fcglue_FcPatternAddDouble_t, FcPatternAddDouble);

      /* Do this late, so we can detect recursive calls to this function. */
      fontconfig_instance = fi;
    }
  }
  CC_SYNC_END(fcglue_init);
  return fontconfig_instance;
}


int
cc_fcglue_FcGetVersion(void)
{
  assert(fontconfig_instance && fontconfig_instance->available);
  return fontconfig_instance->FcGetVersion();
}

FcPattern * 
cc_fcglue_FcNameParse(const unsigned char * name)
{
  assert(fontconfig_instance && fontconfig_instance->available);
  return fontconfig_instance->FcNameParse(name);
}

int
cc_fcglue_FcConfigSubstitute(void * config, FcPattern * pattern, FcMatchKind kind)
{
  assert(fontconfig_instance && fontconfig_instance->available);
  return fontconfig_instance->FcConfigSubstitute(config, pattern, kind);
}

void
cc_fcglue_FcDefaultSubstitute(FcPattern *pattern)
{
  assert(fontconfig_instance && fontconfig_instance->available);
  fontconfig_instance->FcDefaultSubstitute(pattern);
}

FcPattern *
cc_fcglue_FcFontMatch(void * config, FcPattern * pattern, FcResult * result)
{
  assert(fontconfig_instance && fontconfig_instance->available);
  return fontconfig_instance->FcFontMatch(config, pattern, result);
}

FcResult
cc_fcglue_FcPatternGetString(const FcPattern * pattern, const char * object, int n, unsigned char ** s)
{
  assert(fontconfig_instance && fontconfig_instance->available);
  return fontconfig_instance->FcPatternGetString(pattern, object, n, s);
}

void
cc_fcglue_FcPatternDestroy(FcPattern * pattern)
{
  assert(fontconfig_instance && fontconfig_instance->available);
  fontconfig_instance->FcPatternDestroy(pattern);
}

void
cc_fcglue_FcPatternPrint(const FcPattern * pattern)
{
  assert(fontconfig_instance && fontconfig_instance->available);
  fontconfig_instance->FcPatternPrint(pattern);
}

int
cc_fcglue_FcPatternAddDouble(FcPattern *p, const char *object, double d)
{
  assert(fontconfig_instance && fontconfig_instance->available);
  return fontconfig_instance->FcPatternAddDouble(p, object, d);
}

int
cc_fcglue_available(void)
{
  const char * env;
  
  if (!((env = coin_getenv("COIN_FORCE_FONTCONFIG_OFF")) && (atoi(env) > 0))) {
    fcglue_init();
  }
  return fontconfig_instance && fontconfig_instance->available;
}


/* Cleans up freetype at exit. */
static void
ftglue_cleanup(void)
{
#ifdef FREETYPE_RUNTIME_LINKING
  if (freetype_libhandle) {
    cc_dl_close(freetype_libhandle);
    freetype_libhandle = NULL;
  }
#endif /* FREETYPE_RUNTIME_LINKING */
  assert(freetype_instance);
  free(freetype_instance);
  freetype_instance = NULL;
  freetype_failed_to_load = 0;
}

static const cc_ftglue_t *
ftglue_init(void)
{
  CC_SYNC_BEGIN(ftglue_init);

  if (!freetype_instance && !freetype_failed_to_load) {
    /* First invocation, do initializations. */
    cc_ftglue_t * fi = (cc_ftglue_t *)malloc(sizeof(cc_ftglue_t));
    (void)coin_atexit((coin_atexit_f *)ftglue_cleanup, CC_ATEXIT_DYNLIBS);

    /* The common case is that FreeType is either available from the
       linking process or we're successfully going to link it in. */
    fi->available = 1;

#ifdef FREETYPE_RUNTIME_LINKING
    {
      int idx;
      /* FIXME: should we get the system shared library name from an
         Autoconf check? 20000930 mortene. */
      const char * possiblelibnames[] = {
        NULL, /* is set below */
        "freetype", "libfreetype", "libfreetype.so",
        "libfreetype.dylib",
        NULL
      };
      possiblelibnames[0] = coin_getenv("COIN_FREETYPE2_LIBNAME");
      idx = possiblelibnames[0] ? 0 : 1;

      while (!freetype_libhandle && possiblelibnames[idx]) {
        freetype_libhandle = cc_dl_open(possiblelibnames[idx]);
        idx++;
      }

      if (!freetype_libhandle) {
        fi->available = 0;
        freetype_failed_to_load = 1;
      }
    }
    /* Define FTGLUE_REGISTER_FUNC macro. Casting the type is
       necessary for this file to be compatible with C++ compilers. */
#define FTGLUE_REGISTER_FUNC(_funcsig_, _funcname_) \
    do { \
      fi->_funcname_ = (_funcsig_)cc_dl_sym(freetype_libhandle, SO__QUOTE(_funcname_)); \
      if (fi->_funcname_ == NULL) fi->available = 0; \
    } while (0)

#elif defined(FREETYPEGLUE_ASSUME_FREETYPE) /* !FREETYPE_RUNTIME_LINKING */

    /* Define FTGLUE_REGISTER_FUNC macro. */
#define FTGLUE_REGISTER_FUNC(_funcsig_, _funcname_) \
    fi->_funcname_ = (_funcsig_)_funcname_

#else /* !FREETYPEGLUE_ASSUME_FREETYPE */
    fi->available = 0;
    /* Define FTGLUE_REGISTER_FUNC macro. */
#define FTGLUE_REGISTER_FUNC(_funcsig_, _funcname_) \
    fi->_funcname_ = NULL

#endif /* !FREETYPEGLUE_ASSUME_FREETYPE */

    FTGLUE_REGISTER_FUNC(cc_ftglue_FT_Init_FreeType_t, FT_Init_FreeType);
    FTGLUE_REGISTER_FUNC(cc_ftglue_FT_Library_Version_t, FT_Library_Version);
    FTGLUE_REGISTER_FUNC(cc_ftglue_FT_Done_FreeType_t, FT_Done_FreeType);

    if (fi->available && (!fi->FT_Init_FreeType ||
                          !fi->FT_Library_Version ||
                          !fi->FT_Done_FreeType)) {
      /* something is seriously wrong */
      cc_debugerror_post("freetype glue",
                         "Loaded freetype DLL ok, but couldn't resolve basic symbols.");
      fi->available = 0;
      freetype_failed_to_load = 1;
      freetype_instance = fi;
    }
    else {
      FTGLUE_REGISTER_FUNC(cc_ftglue_FT_New_Face_t, FT_New_Face);
      FTGLUE_REGISTER_FUNC(cc_ftglue_FT_Done_Face_t, FT_Done_Face);
      FTGLUE_REGISTER_FUNC(cc_ftglue_FT_Select_Charmap_t, FT_Select_Charmap); 
      FTGLUE_REGISTER_FUNC(cc_ftglue_FT_Set_Char_Size_t, FT_Set_Char_Size);
      FTGLUE_REGISTER_FUNC(cc_ftglue_FT_Set_Transform_t, FT_Set_Transform);
      FTGLUE_REGISTER_FUNC(cc_ftglue_FT_Get_Char_Index_t, FT_Get_Char_Index);
      FTGLUE_REGISTER_FUNC(cc_ftglue_FT_Load_Glyph_t, FT_Load_Glyph);
      FTGLUE_REGISTER_FUNC(cc_ftglue_FT_Get_Kerning_t, FT_Get_Kerning);
      FTGLUE_REGISTER_FUNC(cc_ftglue_FT_Get_Glyph_t, FT_Get_Glyph); 
      FTGLUE_REGISTER_FUNC(cc_ftglue_FT_Glyph_To_Bitmap_t, FT_Glyph_To_Bitmap); 
      FTGLUE_REGISTER_FUNC(cc_ftglue_FT_Done_Glyph_t, FT_Done_Glyph);
      FTGLUE_REGISTER_FUNC(cc_ftglue_FT_Outline_Decompose_t, FT_Outline_Decompose);

      /* Do this late, so we can detect recursive calls to this function. */
      freetype_instance = fi;
    }
  }
  CC_SYNC_END(ftglue_init);
  return freetype_instance;
}


FT_Error 
cc_ftglue_FT_Init_FreeType(FT_Library * library)
{
  assert(freetype_instance && freetype_instance->available);
  return freetype_instance->FT_Init_FreeType(library);
}

void 
cc_ftglue_FT_Library_Version(void * library, int * major, int * minor, int * patch)
{
  assert(freetype_instance && freetype_instance->available);
  freetype_instance->FT_Library_Version(library, major, minor, patch);
}

void 
cc_ftglue_FT_Done_FreeType(void * library)
{
  FT_Error err;
  assert(freetype_instance && freetype_instance->available);
  err = freetype_instance->FT_Done_FreeType(library);
  assert(err == 0 && "something bad happened at FreeType exit");
}

FT_Error 
cc_ftglue_FT_New_Face(void * library, const char * filepathname, long faceindex, FT_Face * face)
{
  assert(freetype_instance && freetype_instance->available);
  return freetype_instance->FT_New_Face(library, filepathname, faceindex, face);
}

FT_Error 
cc_ftglue_FT_Done_Face(void * face)
{
  assert(freetype_instance && freetype_instance->available);
  return freetype_instance->FT_Done_Face(face);
}

FT_Error 
cc_ftglue_FT_Select_Charmap(FT_Face face, int encoding)
{
  assert(freetype_instance && freetype_instance->available);
  return freetype_instance->FT_Select_Charmap(face, encoding);
}

FT_Error 
cc_ftglue_FT_Set_Char_Size(FT_Face face, long width, long height, unsigned int hres, unsigned int vres)
{
  assert(freetype_instance && freetype_instance->available);
  return freetype_instance->FT_Set_Char_Size(face, width, height, hres, vres);
}

void 
cc_ftglue_FT_Set_Transform(FT_Face face, FT_Matrix * matrix, FT_Vector * delta)
{
  assert(freetype_instance && freetype_instance->available);
  freetype_instance->FT_Set_Transform(face, matrix, delta);
}

FT_UInt
cc_ftglue_FT_Get_Char_Index(FT_Face face, unsigned long charidx)
{
  assert(freetype_instance && freetype_instance->available);
  return freetype_instance->FT_Get_Char_Index(face, charidx);
}

FT_Error 
cc_ftglue_FT_Load_Glyph(FT_Face face, unsigned int glyph, int32_t loadflags)
{
  assert(freetype_instance && freetype_instance->available);
  return freetype_instance->FT_Load_Glyph(face, glyph, loadflags);
}

FT_Error 
cc_ftglue_FT_Get_Kerning(FT_Face face, unsigned int left, unsigned int right, unsigned int kernmode, FT_Vector * akerning)
{
  assert(freetype_instance && freetype_instance->available);
  return freetype_instance->FT_Get_Kerning(face, left, right, kernmode, akerning);
}

FT_Error 
cc_ftglue_FT_Get_Glyph(void * glyphslot, FT_Glyph * glyph)
{
  assert(freetype_instance && freetype_instance->available);
  return freetype_instance->FT_Get_Glyph(glyphslot, glyph);
}

FT_Error 
cc_ftglue_FT_Glyph_To_Bitmap(FT_Glyph * glyph, int rendermode, FT_Vector * origin, int destroy)
{
  assert(freetype_instance && freetype_instance->available);
  return freetype_instance->FT_Glyph_To_Bitmap(glyph, rendermode, origin, destroy);
}

void 
cc_ftglue_FT_Done_Glyph(FT_Glyph glyph)
{
  assert(freetype_instance && freetype_instance->available);
  freetype_instance->FT_Done_Glyph(glyph);
}

int
cc_ftglue_available(void)
{
  ftglue_init();
  return freetype_instance && freetype_instance->available;
}

FT_Error 
cc_ftglue_FT_Outline_Decompose(FT_Outline * outline, const FT_Outline_Funcs * func_interface, void * user)
{
  assert(freetype_instance && freetype_instance->available);
  return freetype_instance->FT_Outline_Decompose(outline, func_interface, user);
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.