misc/libfreetype/builds/mac/ftmac.c
author nemo
Sun, 25 Sep 2011 15:40:01 -0400
changeset 6028 335eaf56d976
parent 5172 88f2e05288ba
permissions -rw-r--r--
rename to match prior mass hat rename
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5172
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     1
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     2
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     3
/*  ftmac.c                                                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     4
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     5
/*    Mac FOND support.  Written by just@letterror.com.                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*  Heavily Fixed by mpsuzuki, George Williams and Sean McBride            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*  Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg.     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    11
/*  This file is part of the FreeType project, and may only be used,       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    12
/*  modified, and distributed under the terms of the FreeType project      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    13
/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    14
/*  this file you indicate that you have read the license and              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    16
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    17
/***************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    18
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
  /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
    Notes
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
    Mac suitcase files can (and often do!) contain multiple fonts.  To
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
    support this I use the face_index argument of FT_(Open|New)_Face()
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
    functions, and pretend the suitcase file is a collection.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
    Warning: fbit and NFNT bitmap resources are not supported yet.  In old
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
    sfnt fonts, bitmap glyph data for each size is stored in each `NFNT'
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
    resources instead of the `bdat' table in the sfnt resource.  Therefore,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
    face->num_fixed_sizes is set to 0, because bitmap data in `NFNT'
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
    resource is unavailable at present.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
    The Mac FOND support works roughly like this:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    35
    - Check whether the offered stream points to a Mac suitcase file.  This
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
      is done by checking the file type: it has to be 'FFIL' or 'tfil'.  The
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
      stream that gets passed to our init_face() routine is a stdio stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
      which isn't usable for us, since the FOND resources live in the
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
      resource fork.  So we just grab the stream->pathname field.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
    - Read the FOND resource into memory, then check whether there is a
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
      TrueType font and/or(!) a Type 1 font available.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
    - If there is a Type 1 font available (as a separate `LWFN' file), read
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
      its data into memory, massage it slightly so it becomes PFB data, wrap
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
      it into a memory stream, load the Type 1 driver and delegate the rest
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
      of the work to it by calling FT_Open_Face().  (XXX TODO: after this
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
      has been done, the kerning data from the FOND resource should be
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
      appended to the face: On the Mac there are usually no AFM files
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
      available.  However, this is tricky since we need to map Mac char
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
      codes to ps glyph names to glyph ID's...)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
    - If there is a TrueType font (an `sfnt' resource), read it into memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
      wrap it into a memory stream, load the TrueType driver and delegate
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
      the rest of the work to it, by calling FT_Open_Face().
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
    - Some suitcase fonts (notably Onyx) might point the `LWFN' file to
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
      itself, even though it doesn't contains `POST' resources.  To handle
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
      this special case without opening the file an extra time, we just
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
      ignore errors from the `LWFN' and fallback to the `sfnt' if both are
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
      available.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
#include FT_FREETYPE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
#include FT_TRUETYPE_TAGS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
#include FT_INTERNAL_STREAM_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
#include "ftbase.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
#if defined( __GNUC__ ) || defined( __IBMC__ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
  /* This is for Mac OS X.  Without redefinition, OS_INLINE */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
  /* expands to `static inline' which doesn't survive the   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
  /* -ansi compilation flag of GCC.                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
#if !HAVE_ANSI_OS_INLINE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
#undef  OS_INLINE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
#define OS_INLINE   static __inline__
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
#include <CoreServices/CoreServices.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
#include <ApplicationServices/ApplicationServices.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
#include <sys/syslimits.h> /* PATH_MAX */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
#include <Resources.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
#include <Fonts.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
#include <Endian.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
#include <Errors.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
#include <Files.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
#include <TextUtils.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
#ifndef PATH_MAX
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
#define PATH_MAX 1024 /* same with Mac OS X's syslimits.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
#if defined( __MWERKS__ ) && !TARGET_RT_MAC_MACHO
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
#include <FSp_fopen.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
#define FT_DEPRECATED_ATTRIBUTE
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
#include FT_MAC_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
  /* undefine blocking-macros in ftmac.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
#undef FT_GetFile_From_Mac_Name
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
#undef FT_GetFile_From_Mac_ATS_Name
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
#undef FT_New_Face_From_FOND
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
#undef FT_New_Face_From_FSSpec
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
#undef FT_New_Face_From_FSRef
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
  /* FSSpec functions are deprecated since Mac OS X 10.4 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
#ifndef HAVE_FSSPEC
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
#if TARGET_API_MAC_OS8 || TARGET_API_MAC_CARBON
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
#define HAVE_FSSPEC  1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
#define HAVE_FSSPEC  0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
  /* most FSRef functions were introduced since Mac OS 9 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
#ifndef HAVE_FSREF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
#if TARGET_API_MAC_OSX
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
#define HAVE_FSREF  1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
#define HAVE_FSREF  0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
  /* QuickDraw is deprecated since Mac OS X 10.4 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
#ifndef HAVE_QUICKDRAW_CARBON
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
#if TARGET_API_MAC_OS8 || TARGET_API_MAC_CARBON
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
#define HAVE_QUICKDRAW_CARBON  1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
#define HAVE_QUICKDRAW_CARBON  0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
  /* AppleTypeService is available since Mac OS X */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
#ifndef HAVE_ATS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
#if TARGET_API_MAC_OSX
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
#define HAVE_ATS  1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
#ifndef kATSOptionFlagsUnRestrictedScope /* since Mac OS X 10.1 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
#define kATSOptionFlagsUnRestrictedScope kATSOptionFlagsDefault
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
#define HAVE_ATS  0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
  /* `configure' checks the availability of `ResourceIndex' strictly */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
  /* and sets HAVE_TYPE_RESOURCE_INDEX to 1 or 0 always.  If it is   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
  /* not set (e.g., a build without `configure'), the availability   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
  /* is guessed from the SDK version.                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
#ifndef HAVE_TYPE_RESOURCE_INDEX
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
#if !defined( MAC_OS_X_VERSION_10_5 ) || \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    ( MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
#define HAVE_TYPE_RESOURCE_INDEX 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
#define HAVE_TYPE_RESOURCE_INDEX 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
#endif /* !HAVE_TYPE_RESOURCE_INDEX */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
#if ( HAVE_TYPE_RESOURCE_INDEX == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
typedef short ResourceIndex;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
  /* Set PREFER_LWFN to 1 if LWFN (Type 1) is preferred over
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
     TrueType in case *both* are available (this is not common,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
     but it *is* possible). */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
#ifndef PREFER_LWFN
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
#define PREFER_LWFN  1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
#if !HAVE_QUICKDRAW_CARBON  /* QuickDraw is deprecated since Mac OS X 10.4 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
  FT_GetFile_From_Mac_Name( const char*  fontName,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
                            FSSpec*      pathSpec,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
                            FT_Long*     face_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
    FT_UNUSED( fontName );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
    FT_UNUSED( pathSpec );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    FT_UNUSED( face_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
    return FT_Err_Unimplemented_Feature;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
  FT_GetFile_From_Mac_Name( const char*  fontName,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
                            FSSpec*      pathSpec,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
                            FT_Long*     face_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
    OptionBits            options = kFMUseGlobalScopeOption;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
    FMFontFamilyIterator  famIter;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
    OSStatus              status = FMCreateFontFamilyIterator( NULL, NULL,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
                                                               options,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
                                                               &famIter );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
    FMFont                the_font = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
    FMFontFamily          family   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    *face_index = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
    while ( status == 0 && !the_font )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
      status = FMGetNextFontFamily( &famIter, &family );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
      if ( status == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
        int                           stat2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
        FMFontFamilyInstanceIterator  instIter;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
        Str255                        famNameStr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
        char                          famName[256];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
        /* get the family name */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
        FMGetFontFamilyName( family, famNameStr );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
        CopyPascalStringToC( famNameStr, famName );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
        /* iterate through the styles */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
        FMCreateFontFamilyInstanceIterator( family, &instIter );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
        *face_index = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
        stat2       = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   227
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   228
        while ( stat2 == 0 && !the_font )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
          FMFontStyle  style;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
          FMFontSize   size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
          FMFont       font;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   235
          stat2 = FMGetNextFontFamilyInstance( &instIter, &font,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
                                               &style, &size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
          if ( stat2 == 0 && size == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   238
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   239
            char  fullName[256];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   241
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   242
            /* build up a complete face name */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
            ft_strcpy( fullName, famName );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
            if ( style & bold )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
              ft_strcat( fullName, " Bold" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
            if ( style & italic )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
              ft_strcat( fullName, " Italic" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
            /* compare with the name we are looking for */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
            if ( ft_strcmp( fullName, fontName ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
              /* found it! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
              the_font = font;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
            else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
              ++(*face_index);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
        FMDisposeFontFamilyInstanceIterator( &instIter );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
    FMDisposeFontFamilyIterator( &famIter );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
    if ( the_font )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
      FMGetFontContainer( the_font, pathSpec );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
      return FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
      return FT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
#endif /* HAVE_QUICKDRAW_CARBON */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
#if HAVE_ATS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
  /* Private function.                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
  /* The FSSpec type has been discouraged for a long time,     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
  /* unfortunately an FSRef replacement API for                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
  /* ATSFontGetFileSpecification() is only available in        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
  /* Mac OS X 10.5 and later.                                  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
  static OSStatus
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
  FT_ATSFontGetFileReference( ATSFontRef  ats_font_id,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
                              FSRef*      ats_font_ref )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   288
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
    OSStatus  err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
#if !defined( MAC_OS_X_VERSION_10_5 ) || \
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
    MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
    FSSpec    spec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   296
    err = ATSFontGetFileSpecification( ats_font_id, &spec );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
    if ( noErr == err )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
      err = FSpMakeFSRef( &spec, ats_font_ref );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
    err = ATSFontGetFileReference( ats_font_id, ats_font_ref );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
    return err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   306
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   307
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
  FT_GetFileRef_From_Mac_ATS_Name( const char*  fontName,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
                                   FSRef*       ats_font_ref,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
                                   FT_Long*     face_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   311
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   312
    CFStringRef  cf_fontName;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
    ATSFontRef   ats_font_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
    *face_index = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   317
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   318
    cf_fontName = CFStringCreateWithCString( NULL, fontName,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
                                             kCFStringEncodingMacRoman );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
    ats_font_id = ATSFontFindFromName( cf_fontName,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
                                       kATSOptionFlagsUnRestrictedScope );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
    CFRelease( cf_fontName );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
    if ( ats_font_id == 0 || ats_font_id == 0xFFFFFFFFUL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
      return FT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
    if ( noErr != FT_ATSFontGetFileReference( ats_font_id, ats_font_ref ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
      return FT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
    /* face_index calculation by searching preceding fontIDs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
    /* with same FSRef                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   332
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   333
      ATSFontRef  id2 = ats_font_id - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
      FSRef       ref2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
      while ( id2 > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
        if ( noErr != FT_ATSFontGetFileReference( id2, &ref2 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
        if ( noErr != FSCompareFSRefs( ats_font_ref, &ref2 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   343
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   344
        id2--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   345
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   346
      *face_index = ats_font_id - ( id2 + 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
    return FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
#if !HAVE_ATS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
  FT_GetFilePath_From_Mac_ATS_Name( const char*  fontName,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
                                    UInt8*       path,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
                                    UInt32       maxPathSize,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
                                    FT_Long*     face_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
    FT_UNUSED( fontName );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
    FT_UNUSED( path );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
    FT_UNUSED( maxPathSize );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
    FT_UNUSED( face_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   366
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   367
    return FT_Err_Unimplemented_Feature;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   369
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
  FT_GetFilePath_From_Mac_ATS_Name( const char*  fontName,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
                                    UInt8*       path,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
                                    UInt32       maxPathSize,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
                                    FT_Long*     face_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   377
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   378
    FSRef     ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
    FT_Error  err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   381
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   382
    err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
    if ( FT_Err_Ok != err )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
      return err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
    if ( noErr != FSRefMakePath( &ref, path, maxPathSize ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
      return FT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
    return FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
#endif /* HAVE_ATS */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
#if !HAVE_FSSPEC || !HAVE_ATS
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
  FT_GetFile_From_Mac_ATS_Name( const char*  fontName,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
                                FSSpec*      pathSpec,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
                                FT_Long*     face_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
    FT_UNUSED( fontName );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
    FT_UNUSED( pathSpec );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
    FT_UNUSED( face_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
    return FT_Err_Unimplemented_Feature;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
  /* This function is deprecated because FSSpec is deprecated in Mac OS X. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
  FT_GetFile_From_Mac_ATS_Name( const char*  fontName,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
                                FSSpec*      pathSpec,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
                                FT_Long*     face_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
    FSRef     ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
    FT_Error  err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   420
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   421
    err = FT_GetFileRef_From_Mac_ATS_Name( fontName, &ref, face_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
    if ( FT_Err_Ok != err )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
      return err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
    if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone, NULL, NULL,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
                                    pathSpec, NULL ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
      return FT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
    return FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
#if defined( __MWERKS__ ) && !TARGET_RT_MAC_MACHO
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   436
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   437
#define STREAM_FILE( stream )  ( (FT_FILE*)stream->descriptor.pointer )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
  FT_CALLBACK_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
  ft_FSp_stream_close( FT_Stream  stream )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
    ft_fclose( STREAM_FILE( stream ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
    stream->descriptor.pointer = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
    stream->size               = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
    stream->base               = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
  FT_CALLBACK_DEF( unsigned long )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
  ft_FSp_stream_io( FT_Stream       stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
                    unsigned long   offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
                    unsigned char*  buffer,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
                    unsigned long   count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
    FT_FILE*  file;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
    file = STREAM_FILE( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   461
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   462
    ft_fseek( file, offset, SEEK_SET );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
    return (unsigned long)ft_fread( buffer, 1, count, file );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
#endif  /* __MWERKS__ && !TARGET_RT_MAC_MACHO */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
#if HAVE_FSSPEC && !HAVE_FSREF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
  /* isDirectory is a dummy to synchronize API with FSPathMakeRef() */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
  static OSErr
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
  FT_FSPathMakeSpec( const UInt8*  pathname,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
                     FSSpec*       spec_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
                     Boolean       isDirectory )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
    const char  *p, *q;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
    short       vRefNum;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
    long        dirID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
    Str255      nodeName;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
    OSErr       err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
    FT_UNUSED( isDirectory );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
    p = q = (const char *)pathname;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
    dirID   = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
    vRefNum = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
    while ( 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
      int  len = ft_strlen( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
      if ( len > 255 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
        len = 255;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
      q = p + len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   500
      if ( q == p )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
        return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
      if ( 255 < ft_strlen( (char *)pathname ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
        while ( p < q && *q != ':' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
          q--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
      if ( p < q )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
        *(char *)nodeName = q - p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
      else if ( ft_strlen( p ) < 256 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
        *(char *)nodeName = ft_strlen( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
        return errFSNameTooLong;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
      ft_strncpy( (char *)nodeName + 1, (char *)p, *(char *)nodeName );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
      err = FSMakeFSSpec( vRefNum, dirID, nodeName, spec_p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
      if ( err || '\0' == *q )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
        return err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
      vRefNum = spec_p->vRefNum;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
      dirID   = spec_p->parID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
      p = q;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   528
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   529
  static OSErr
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
  FT_FSpMakePath( const FSSpec*  spec_p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
                  UInt8*         path,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
                  UInt32         maxPathSize )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   533
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   534
    OSErr   err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
    FSSpec  spec = *spec_p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
    short   vRefNum;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
    long    dirID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
    Str255  parDir_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   540
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   541
    FT_MEM_SET( path, 0, maxPathSize );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
    while ( 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   543
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   544
      int             child_namelen = ft_strlen( (char *)path );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
      unsigned char   node_namelen  = spec.name[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
      unsigned char*  node_name     = spec.name + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
      if ( node_namelen + child_namelen > maxPathSize )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
        return errFSNameTooLong;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
      FT_MEM_MOVE( path + node_namelen + 1, path, child_namelen );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
      FT_MEM_COPY( path, node_name, node_namelen );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
      if ( child_namelen > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
        path[node_namelen] = ':';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
      vRefNum        = spec.vRefNum;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
      dirID          = spec.parID;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
      parDir_name[0] = '\0';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
      err = FSMakeFSSpec( vRefNum, dirID, parDir_name, &spec );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
      if ( noErr != err || dirID == spec.parID )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
    return noErr;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
#endif /* HAVE_FSSPEC && !HAVE_FSREF */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   568
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   569
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
  static OSErr
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
  FT_FSPathMakeRes( const UInt8*    pathname,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
                    ResFileRefNum*  res )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
#if HAVE_FSREF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
    OSErr  err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
    FSRef  ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   579
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   580
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
    if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
      return FT_Err_Cannot_Open_Resource;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
    /* at present, no support for dfont format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
    err = FSOpenResourceFile( &ref, 0, NULL, fsRdPerm, res );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
    if ( noErr == err )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
      return err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
    /* fallback to original resource-fork font */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
    *res = FSOpenResFile( &ref, fsRdPerm );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
    err  = ResError();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
    OSErr   err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
    FSSpec  spec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   597
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   598
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
    if ( noErr != FT_FSPathMakeSpec( pathname, &spec, FALSE ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
      return FT_Err_Cannot_Open_Resource;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
    /* at present, no support for dfont format without FSRef */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
    /* (see above), try original resource-fork font          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
    *res = FSpOpenResFile( &spec, fsRdPerm );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
    err  = ResError();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
#endif /* HAVE_FSREF */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
    return err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   610
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   611
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
  /* Return the file type for given pathname */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
  static OSType
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
  get_file_type_from_path( const UInt8*  pathname )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   616
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   617
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
#if HAVE_FSREF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
    FSRef          ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
    FSCatalogInfo  info;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   622
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   623
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   624
    if ( noErr != FSPathMakeRef( pathname, &ref, FALSE ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
      return ( OSType ) 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   626
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   627
    if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoFinderInfo, &info,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
                                    NULL, NULL, NULL ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
      return ( OSType ) 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
    return ((FInfo *)(info.finderInfo))->fdType;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
    FSSpec  spec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
    FInfo   finfo;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   637
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   638
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
    if ( noErr != FT_FSPathMakeSpec( pathname, &spec, FALSE ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
      return ( OSType ) 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
    if ( noErr != FSpGetFInfo( &spec, &finfo ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
      return ( OSType ) 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   644
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   645
    return finfo.fdType;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
#endif /* HAVE_FSREF */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
  /* Given a PostScript font name, create the Macintosh LWFN file name. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
  create_lwfn_name( char*   ps_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
                    Str255  lwfn_file_name )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
    int       max = 5, count = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
    FT_Byte*  p = lwfn_file_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
    FT_Byte*  q = (FT_Byte*)ps_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   660
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   661
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   662
    lwfn_file_name[0] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   663
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   664
    while ( *q )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
      if ( ft_isupper( *q ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
        if ( count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
          max = 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
        count = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
      if ( count < max && ( ft_isalnum( *q ) || *q == '_' ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   673
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   674
        *++p = *q;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
        lwfn_file_name[0]++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
        count++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   677
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   678
      q++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   680
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   681
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
  static short
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
  count_faces_sfnt( char*  fond_data )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
    /* The count is 1 greater than the value in the FOND.  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
    /* Isn't that cute? :-)                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   688
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   689
    return EndianS16_BtoN( *( (short*)( fond_data +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
                                        sizeof ( FamRec ) ) ) ) + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   691
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   692
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   693
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
  static short
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
  count_faces_scalable( char*  fond_data )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
    AsscEntry*  assoc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
    FamRec*     fond;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
    short       i, face, face_all;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
    fond     = (FamRec*)fond_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
    face_all = EndianS16_BtoN( *( (short *)( fond_data +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
                                             sizeof ( FamRec ) ) ) ) + 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
    assoc    = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
    face     = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
    for ( i = 0; i < face_all; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   709
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   710
      if ( 0 == EndianS16_BtoN( assoc[i].fontSize ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
        face++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
    return face;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   715
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   716
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   717
  /* Look inside the FOND data, answer whether there should be an SFNT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
     resource, and answer the name of a possible LWFN Type 1 file.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
     Thanks to Paul Miller (paulm@profoundeffects.com) for the fix
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
     to load a face OTHER than the first one in the FOND!
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
  parse_fond( char*   fond_data,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
              short*  have_sfnt,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
              ResID*  sfnt_id,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
              Str255  lwfn_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
              short   face_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
    AsscEntry*  assoc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
    AsscEntry*  base_assoc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
    FamRec*     fond;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
    *sfnt_id          = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
    *have_sfnt        = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
    lwfn_file_name[0] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
    fond       = (FamRec*)fond_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
    assoc      = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
    base_assoc = assoc;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   743
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   744
    /* the maximum faces in a FOND is 48, size of StyleTable.indexes[] */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
    if ( 47 < face_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
      return;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   747
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   748
    /* Let's do a little range checking before we get too excited here */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
    if ( face_index < count_faces_sfnt( fond_data ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   750
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   751
      assoc += face_index;        /* add on the face_index! */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
      /* if the face at this index is not scalable,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
         fall back to the first one (old behavior) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
      if ( EndianS16_BtoN( assoc->fontSize ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   757
        *have_sfnt = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
        *sfnt_id   = EndianS16_BtoN( assoc->fontID );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
      else if ( base_assoc->fontSize == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   761
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   762
        *have_sfnt = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
        *sfnt_id   = EndianS16_BtoN( base_assoc->fontID );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   764
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   765
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   766
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
    if ( EndianS32_BtoN( fond->ffStylOff ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
      unsigned char*  p = (unsigned char*)fond_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
      StyleTable*     style;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
      unsigned short  string_count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
      char            ps_name[256];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
      unsigned char*  names[64];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
      int             i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   776
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   777
      p += EndianS32_BtoN( fond->ffStylOff );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   778
      style = (StyleTable*)p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
      p += sizeof ( StyleTable );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
      string_count = EndianS16_BtoN( *(short*)(p) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   781
      p += sizeof ( short );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   783
      for ( i = 0; i < string_count && i < 64; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   784
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
        names[i] = p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
        p       += names[i][0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   787
        p++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   788
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   789
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   790
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   791
        size_t  ps_name_len = (size_t)names[0][0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   793
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   794
        if ( ps_name_len != 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
          ft_memcpy(ps_name, names[0] + 1, ps_name_len);
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
          ps_name[ps_name_len] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   798
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   799
        if ( style->indexes[face_index] > 1 &&
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
             style->indexes[face_index] <= FT_MIN( string_count, 64 ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   801
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   802
          unsigned char*  suffixes = names[style->indexes[face_index] - 1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   804
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   805
          for ( i = 1; i <= suffixes[0]; i++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   806
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   807
            unsigned char*  s;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   808
            size_t          j = suffixes[i] - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   809
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   810
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
            if ( j < string_count && ( s = names[j] ) != NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
            {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
              size_t  s_len = (size_t)s[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   815
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   816
              if ( s_len != 0 && ps_name_len + s_len < sizeof ( ps_name ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
              {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
                ft_memcpy( ps_name + ps_name_len, s + 1, s_len );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
                ps_name_len += s_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
                ps_name[ps_name_len] = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   821
              }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   822
            }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   824
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   825
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   826
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   827
      create_lwfn_name( ps_name, lwfn_file_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   828
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   829
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
  static  FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
  lookup_lwfn_by_fond( const UInt8*      path_fond,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
                       ConstStr255Param  base_lwfn,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
                       UInt8*            path_lwfn,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
                       int               path_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   838
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   839
#if HAVE_FSREF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
    FSRef  ref, par_ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   842
    int    dirname_len;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   843
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   844
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   845
    /* Pathname for FSRef can be in various formats: HFS, HFS+, and POSIX. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   846
    /* We should not extract parent directory by string manipulation.      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   847
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   848
    if ( noErr != FSPathMakeRef( path_fond, &ref, FALSE ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   849
      return FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   850
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   851
    if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   852
                                    NULL, NULL, NULL, &par_ref ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   853
      return FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   854
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   855
    if ( noErr != FSRefMakePath( &par_ref, path_lwfn, path_size ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   856
      return FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   857
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   858
    if ( ft_strlen( (char *)path_lwfn ) + 1 + base_lwfn[0] > path_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   859
      return FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   860
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   861
    /* now we have absolute dirname in path_lwfn */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   862
    if ( path_lwfn[0] == '/' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   863
      ft_strcat( (char *)path_lwfn, "/" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   864
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   865
      ft_strcat( (char *)path_lwfn, ":" );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   866
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   867
    dirname_len = ft_strlen( (char *)path_lwfn );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   868
    ft_strcat( (char *)path_lwfn, (char *)base_lwfn + 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   869
    path_lwfn[dirname_len + base_lwfn[0]] = '\0';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   870
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   871
    if ( noErr != FSPathMakeRef( path_lwfn, &ref, FALSE ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   872
      return FT_Err_Cannot_Open_Resource;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   873
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   874
    if ( noErr != FSGetCatalogInfo( &ref, kFSCatInfoNone,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   875
                                    NULL, NULL, NULL, NULL ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   876
      return FT_Err_Cannot_Open_Resource;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   877
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   878
    return FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   879
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   880
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   881
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   882
    int     i;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   883
    FSSpec  spec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   884
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   885
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   886
    /* pathname for FSSpec is always HFS format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   887
    if ( ft_strlen( (char *)path_fond ) > path_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   888
      return FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   889
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   890
    ft_strcpy( (char *)path_lwfn, (char *)path_fond );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   891
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   892
    i = ft_strlen( (char *)path_lwfn ) - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   893
    while ( i > 0 && ':' != path_lwfn[i] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   894
      i--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   895
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   896
    if ( i + 1 + base_lwfn[0] > path_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   897
      return FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   898
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   899
    if ( ':' == path_lwfn[i] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   900
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   901
      ft_strcpy( (char *)path_lwfn + i + 1, (char *)base_lwfn + 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   902
      path_lwfn[i + 1 + base_lwfn[0]] = '\0';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   903
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   904
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   905
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   906
      ft_strcpy( (char *)path_lwfn, (char *)base_lwfn + 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   907
      path_lwfn[base_lwfn[0]] = '\0';
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   908
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   909
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   910
    if ( noErr != FT_FSPathMakeSpec( path_lwfn, &spec, FALSE ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   911
      return FT_Err_Cannot_Open_Resource;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   912
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   913
    return FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   914
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   915
#endif /* HAVE_FSREF */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   916
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   917
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   918
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   919
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   920
  static short
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   921
  count_faces( Handle        fond,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   922
               const UInt8*  pathname )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   923
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   924
    ResID     sfnt_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   925
    short     have_sfnt, have_lwfn;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   926
    Str255    lwfn_file_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   927
    UInt8     buff[PATH_MAX];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   928
    FT_Error  err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   929
    short     num_faces;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   930
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   931
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   932
    have_sfnt = have_lwfn = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   933
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   934
    HLock( fond );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   935
    parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   936
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   937
    if ( lwfn_file_name[0] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   938
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   939
      err = lookup_lwfn_by_fond( pathname, lwfn_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   940
                                 buff, sizeof ( buff )  );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   941
      if ( FT_Err_Ok == err )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   942
        have_lwfn = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   943
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   944
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   945
    if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   946
      num_faces = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   947
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   948
      num_faces = count_faces_scalable( *fond );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   949
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   950
    HUnlock( fond );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   951
    return num_faces;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   952
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   953
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   954
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   955
  /* Read Type 1 data from the POST resources inside the LWFN file,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   956
     return a PFB buffer.  This is somewhat convoluted because the FT2
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   957
     PFB parser wants the ASCII header as one chunk, and the LWFN
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   958
     chunks are often not organized that way, so we glue chunks
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   959
     of the same type together. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   960
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   961
  read_lwfn( FT_Memory      memory,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   962
             ResFileRefNum  res,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   963
             FT_Byte**      pfb_data,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   964
             FT_ULong*      size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   965
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   966
    FT_Error       error = FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   967
    ResID          res_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   968
    unsigned char  *buffer, *p, *size_p = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   969
    FT_ULong       total_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   970
    FT_ULong       old_total_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   971
    FT_ULong       post_size, pfb_chunk_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   972
    Handle         post_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   973
    char           code, last_code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   974
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   975
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   976
    UseResFile( res );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   977
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   978
    /* First pass: load all POST resources, and determine the size of */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   979
    /* the output buffer.                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   980
    res_id    = 501;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   981
    last_code = -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   982
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   983
    for (;;)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   984
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   985
      post_data = Get1Resource( TTAG_POST, res_id++ );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   986
      if ( post_data == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   987
        break;  /* we are done */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   988
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   989
      code = (*post_data)[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   990
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   991
      if ( code != last_code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   992
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   993
        if ( code == 5 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   994
          total_size += 2; /* just the end code */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   995
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   996
          total_size += 6; /* code + 4 bytes chunk length */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   997
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   998
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   999
      total_size += GetHandleSize( post_data ) - 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1000
      last_code = code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1001
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1002
      /* detect integer overflows */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1003
      if ( total_size < old_total_size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1004
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1005
        error = FT_Err_Array_Too_Large;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1006
        goto Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1007
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1008
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1009
      old_total_size = total_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1010
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1011
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1012
    if ( FT_ALLOC( buffer, (FT_Long)total_size ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1013
      goto Error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1014
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1015
    /* Second pass: append all POST data to the buffer, add PFB fields. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1016
    /* Glue all consecutive chunks of the same type together.           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1017
    p              = buffer;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1018
    res_id         = 501;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1019
    last_code      = -1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1020
    pfb_chunk_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1021
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1022
    for (;;)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1023
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1024
      post_data = Get1Resource( TTAG_POST, res_id++ );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1025
      if ( post_data == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1026
        break;  /* we are done */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1027
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1028
      post_size = (FT_ULong)GetHandleSize( post_data ) - 2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1029
      code = (*post_data)[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1030
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1031
      if ( code != last_code )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1032
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1033
        if ( last_code != -1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1034
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1035
          /* we are done adding a chunk, fill in the size field */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1036
          if ( size_p != NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1037
          {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1038
            *size_p++ = (FT_Byte)(   pfb_chunk_size         & 0xFF );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1039
            *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 8  ) & 0xFF );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1040
            *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 16 ) & 0xFF );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1041
            *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 24 ) & 0xFF );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1042
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1043
          pfb_chunk_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1044
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1045
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1046
        *p++ = 0x80;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1047
        if ( code == 5 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1048
          *p++ = 0x03;  /* the end */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1049
        else if ( code == 2 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1050
          *p++ = 0x02;  /* binary segment */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1051
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1052
          *p++ = 0x01;  /* ASCII segment */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1053
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1054
        if ( code != 5 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1055
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1056
          size_p = p;   /* save for later */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1057
          p += 4;       /* make space for size field */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1058
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1059
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1060
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1061
      ft_memcpy( p, *post_data + 2, post_size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1062
      pfb_chunk_size += post_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1063
      p += post_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1064
      last_code = code;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1065
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1066
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1067
    *pfb_data = buffer;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1068
    *size = total_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1069
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1070
  Error:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1071
    CloseResFile( res );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1072
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1073
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1074
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1075
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1076
  /* Create a new FT_Face from a file spec to an LWFN file. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1077
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1078
  FT_New_Face_From_LWFN( FT_Library    library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1079
                         const UInt8*  pathname,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1080
                         FT_Long       face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1081
                         FT_Face*      aface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1082
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1083
    FT_Byte*       pfb_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1084
    FT_ULong       pfb_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1085
    FT_Error       error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1086
    ResFileRefNum  res;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1087
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1088
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1089
    if ( noErr != FT_FSPathMakeRes( pathname, &res ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1090
      return FT_Err_Cannot_Open_Resource;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1091
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1092
    pfb_data = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1093
    pfb_size = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1094
    error = read_lwfn( library->memory, res, &pfb_data, &pfb_size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1095
    CloseResFile( res ); /* PFB is already loaded, useless anymore */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1096
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1097
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1098
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1099
    return open_face_from_buffer( library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1100
                                  pfb_data,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1101
                                  pfb_size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1102
                                  face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1103
                                  "type1",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1104
                                  aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1105
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1106
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1107
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1108
  /* Create a new FT_Face from an SFNT resource, specified by res ID. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1109
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1110
  FT_New_Face_From_SFNT( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1111
                         ResID       sfnt_id,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1112
                         FT_Long     face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1113
                         FT_Face*    aface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1114
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1115
    Handle     sfnt = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1116
    FT_Byte*   sfnt_data;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1117
    size_t     sfnt_size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1118
    FT_Error   error  = FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1119
    FT_Memory  memory = library->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1120
    int        is_cff, is_sfnt_ps;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1121
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1122
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1123
    sfnt = GetResource( TTAG_sfnt, sfnt_id );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1124
    if ( sfnt == NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1125
      return FT_Err_Invalid_Handle;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1126
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1127
    sfnt_size = (FT_ULong)GetHandleSize( sfnt );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1128
    if ( FT_ALLOC( sfnt_data, (FT_Long)sfnt_size ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1129
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1130
      ReleaseResource( sfnt );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1131
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1132
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1133
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1134
    HLock( sfnt );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1135
    ft_memcpy( sfnt_data, *sfnt, sfnt_size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1136
    HUnlock( sfnt );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1137
    ReleaseResource( sfnt );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1138
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1139
    is_cff     = sfnt_size > 4 && !ft_memcmp( sfnt_data, "OTTO", 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1140
    is_sfnt_ps = sfnt_size > 4 && !ft_memcmp( sfnt_data, "typ1", 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1141
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1142
    if ( is_sfnt_ps )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1143
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1144
      FT_Stream  stream;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1145
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1146
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1147
      if ( FT_NEW( stream ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1148
        goto Try_OpenType;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1149
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1150
      FT_Stream_OpenMemory( stream, sfnt_data, sfnt_size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1151
      if ( !open_face_PS_from_sfnt_stream( library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1152
                                           stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1153
                                           face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1154
                                           0, NULL,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1155
                                           aface ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1156
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1157
        FT_Stream_Close( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1158
        FT_FREE( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1159
        FT_FREE( sfnt_data );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1160
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1161
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1162
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1163
      FT_FREE( stream );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1164
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1165
  Try_OpenType:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1166
    error = open_face_from_buffer( library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1167
                                   sfnt_data,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1168
                                   sfnt_size,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1169
                                   face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1170
                                   is_cff ? "cff" : "truetype",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1171
                                   aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1172
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1173
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1174
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1175
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1176
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1177
  /* Create a new FT_Face from a file spec to a suitcase file. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1178
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1179
  FT_New_Face_From_Suitcase( FT_Library    library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1180
                             const UInt8*  pathname,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1181
                             FT_Long       face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1182
                             FT_Face*      aface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1183
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1184
    FT_Error       error = FT_Err_Cannot_Open_Resource;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1185
    ResFileRefNum  res_ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1186
    ResourceIndex  res_index;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1187
    Handle         fond;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1188
    short          num_faces_in_res, num_faces_in_fond;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1189
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1190
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1191
    if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1192
      return FT_Err_Cannot_Open_Resource;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1193
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1194
    UseResFile( res_ref );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1195
    if ( ResError() )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1196
      return FT_Err_Cannot_Open_Resource;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1197
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1198
    num_faces_in_res = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1199
    for ( res_index = 1; ; ++res_index )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1200
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1201
      fond = Get1IndResource( TTAG_FOND, res_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1202
      if ( ResError() )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1203
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1204
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1205
      num_faces_in_fond  = count_faces( fond, pathname );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1206
      num_faces_in_res  += num_faces_in_fond;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1207
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1208
      if ( 0 <= face_index && face_index < num_faces_in_fond && error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1209
        error = FT_New_Face_From_FOND( library, fond, face_index, aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1210
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1211
      face_index -= num_faces_in_fond;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1212
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1213
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1214
    CloseResFile( res_ref );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1215
    if ( FT_Err_Ok == error && NULL != aface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1216
      (*aface)->num_faces = num_faces_in_res;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1217
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1218
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1219
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1220
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1221
  /* documentation is in ftmac.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1222
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1223
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1224
  FT_New_Face_From_FOND( FT_Library  library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1225
                         Handle      fond,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1226
                         FT_Long     face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1227
                         FT_Face*    aface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1228
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1229
    short     have_sfnt, have_lwfn = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1230
    ResID     sfnt_id, fond_id;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1231
    OSType    fond_type;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1232
    Str255    fond_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1233
    Str255    lwfn_file_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1234
    UInt8     path_lwfn[PATH_MAX];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1235
    OSErr     err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1236
    FT_Error  error = FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1237
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1238
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1239
    GetResInfo( fond, &fond_id, &fond_type, fond_name );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1240
    if ( ResError() != noErr || fond_type != TTAG_FOND )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1241
      return FT_Err_Invalid_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1242
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1243
    HLock( fond );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1244
    parse_fond( *fond, &have_sfnt, &sfnt_id, lwfn_file_name, face_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1245
    HUnlock( fond );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1246
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1247
    if ( lwfn_file_name[0] )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1248
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1249
      ResFileRefNum  res;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1250
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1251
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1252
      res = HomeResFile( fond );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1253
      if ( noErr != ResError() )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1254
        goto found_no_lwfn_file;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1255
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1256
#if HAVE_FSREF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1257
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1258
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1259
        UInt8  path_fond[PATH_MAX];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1260
        FSRef  ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1261
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1262
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1263
        err = FSGetForkCBInfo( res, kFSInvalidVolumeRefNum,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1264
                               NULL, NULL, NULL, &ref, NULL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1265
        if ( noErr != err )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1266
          goto found_no_lwfn_file;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1267
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1268
        err = FSRefMakePath( &ref, path_fond, sizeof ( path_fond ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1269
        if ( noErr != err )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1270
          goto found_no_lwfn_file;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1271
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1272
        error = lookup_lwfn_by_fond( path_fond, lwfn_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1273
                                     path_lwfn, sizeof ( path_lwfn ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1274
        if ( FT_Err_Ok == error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1275
          have_lwfn = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1276
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1277
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1278
#elif HAVE_FSSPEC
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1279
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1280
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1281
        UInt8     path_fond[PATH_MAX];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1282
        FCBPBRec  pb;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1283
        Str255    fond_file_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1284
        FSSpec    spec;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1285
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1286
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1287
        FT_MEM_SET( &spec, 0, sizeof ( FSSpec ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1288
        FT_MEM_SET( &pb,   0, sizeof ( FCBPBRec ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1289
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1290
        pb.ioNamePtr = fond_file_name;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1291
        pb.ioVRefNum = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1292
        pb.ioRefNum  = res;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1293
        pb.ioFCBIndx = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1294
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1295
        err = PBGetFCBInfoSync( &pb );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1296
        if ( noErr != err )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1297
          goto found_no_lwfn_file;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1298
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1299
        err = FSMakeFSSpec( pb.ioFCBVRefNum, pb.ioFCBParID,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1300
                            fond_file_name, &spec );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1301
        if ( noErr != err )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1302
          goto found_no_lwfn_file;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1303
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1304
        err = FT_FSpMakePath( &spec, path_fond, sizeof ( path_fond ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1305
        if ( noErr != err )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1306
          goto found_no_lwfn_file;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1307
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1308
        error = lookup_lwfn_by_fond( path_fond, lwfn_file_name,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1309
                                     path_lwfn, sizeof ( path_lwfn ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1310
        if ( FT_Err_Ok == error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1311
          have_lwfn = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1312
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1313
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1314
#endif /* HAVE_FSREF, HAVE_FSSPEC */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1315
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1316
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1317
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1318
    if ( have_lwfn && ( !have_sfnt || PREFER_LWFN ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1319
      error = FT_New_Face_From_LWFN( library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1320
                                     path_lwfn,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1321
                                     face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1322
                                     aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1323
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1324
      error = FT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1325
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1326
  found_no_lwfn_file:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1327
    if ( have_sfnt && FT_Err_Ok != error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1328
      error = FT_New_Face_From_SFNT( library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1329
                                     sfnt_id,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1330
                                     face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1331
                                     aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1332
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1333
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1334
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1335
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1336
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1337
  /* Common function to load a new FT_Face from a resource file. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1338
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1339
  FT_New_Face_From_Resource( FT_Library    library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1340
                             const UInt8*  pathname,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1341
                             FT_Long       face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1342
                             FT_Face*      aface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1343
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1344
    OSType    file_type;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1345
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1346
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1347
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1348
    /* LWFN is a (very) specific file format, check for it explicitly */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1349
    file_type = get_file_type_from_path( pathname );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1350
    if ( file_type == TTAG_LWFN )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1351
      return FT_New_Face_From_LWFN( library, pathname, face_index, aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1352
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1353
    /* Otherwise the file type doesn't matter (there are more than  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1354
    /* `FFIL' and `tfil').  Just try opening it as a font suitcase; */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1355
    /* if it works, fine.                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1356
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1357
    error = FT_New_Face_From_Suitcase( library, pathname, face_index, aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1358
    if ( error == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1359
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1360
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1361
    /* let it fall through to normal loader (.ttf, .otf, etc.); */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1362
    /* we signal this by returning no error and no FT_Face      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1363
    *aface = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1364
    return 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1365
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1366
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1367
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1368
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1369
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1370
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1371
  /*    FT_New_Face                                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1372
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1373
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1374
  /*    This is the Mac-specific implementation of FT_New_Face.  In        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1375
  /*    addition to the standard FT_New_Face() functionality, it also      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1376
  /*    accepts pathnames to Mac suitcase files.  For further              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1377
  /*    documentation see the original FT_New_Face() in freetype.h.        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1378
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1379
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1380
  FT_New_Face( FT_Library   library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1381
               const char*  pathname,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1382
               FT_Long      face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1383
               FT_Face*     aface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1384
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1385
    FT_Open_Args  args;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1386
    FT_Error      error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1387
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1388
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1389
    /* test for valid `library' and `aface' delayed to FT_Open_Face() */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1390
    if ( !pathname )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1391
      return FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1392
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1393
    error  = FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1394
    *aface = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1395
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1396
    /* try resourcefork based font: LWFN, FFIL */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1397
    error = FT_New_Face_From_Resource( library, (UInt8 *)pathname,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1398
                                       face_index, aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1399
    if ( error != 0 || *aface != NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1400
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1401
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1402
    /* let it fall through to normal loader (.ttf, .otf, etc.) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1403
    args.flags    = FT_OPEN_PATHNAME;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1404
    args.pathname = (char*)pathname;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1405
    return FT_Open_Face( library, &args, face_index, aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1406
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1407
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1408
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1409
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1410
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1411
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1412
  /*    FT_New_Face_From_FSRef                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1413
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1414
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1415
  /*    FT_New_Face_From_FSRef is identical to FT_New_Face except it       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1416
  /*    accepts an FSRef instead of a path.                                */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1417
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1418
  /* This function is deprecated because Carbon data types (FSRef)         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1419
  /* are not cross-platform, and thus not suitable for the freetype API.   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1420
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1421
  FT_New_Face_From_FSRef( FT_Library    library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1422
                          const FSRef*  ref,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1423
                          FT_Long       face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1424
                          FT_Face*      aface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1425
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1426
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1427
#if !HAVE_FSREF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1428
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1429
    FT_UNUSED( library );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1430
    FT_UNUSED( ref );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1431
    FT_UNUSED( face_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1432
    FT_UNUSED( aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1433
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1434
    return FT_Err_Unimplemented_Feature;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1435
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1436
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1437
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1438
    FT_Error      error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1439
    FT_Open_Args  args;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1440
    OSErr   err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1441
    UInt8   pathname[PATH_MAX];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1442
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1443
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1444
    if ( !ref )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1445
      return FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1446
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1447
    err = FSRefMakePath( ref, pathname, sizeof ( pathname ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1448
    if ( err )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1449
      error = FT_Err_Cannot_Open_Resource;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1450
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1451
    error = FT_New_Face_From_Resource( library, pathname, face_index, aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1452
    if ( error != 0 || *aface != NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1453
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1454
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1455
    /* fallback to datafork font */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1456
    args.flags    = FT_OPEN_PATHNAME;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1457
    args.pathname = (char*)pathname;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1458
    return FT_Open_Face( library, &args, face_index, aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1459
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1460
#endif /* HAVE_FSREF */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1461
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1462
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1463
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1464
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1465
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1466
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1467
  /* <Function>                                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1468
  /*    FT_New_Face_From_FSSpec                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1469
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1470
  /* <Description>                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1471
  /*    FT_New_Face_From_FSSpec is identical to FT_New_Face except it      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1472
  /*    accepts an FSSpec instead of a path.                               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1473
  /*                                                                       */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1474
  /* This function is deprecated because Carbon data types (FSSpec)        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1475
  /* are not cross-platform, and thus not suitable for the freetype API.   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1476
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1477
  FT_New_Face_From_FSSpec( FT_Library     library,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1478
                           const FSSpec*  spec,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1479
                           FT_Long        face_index,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1480
                           FT_Face*       aface )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1481
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1482
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1483
#if HAVE_FSREF
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1484
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1485
    FSRef  ref;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1486
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1487
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1488
    if ( !spec || FSpMakeFSRef( spec, &ref ) != noErr )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1489
      return FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1490
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1491
      return FT_New_Face_From_FSRef( library, &ref, face_index, aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1492
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1493
#elif HAVE_FSSPEC
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1494
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1495
    FT_Error      error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1496
    FT_Open_Args  args;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1497
    OSErr         err;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1498
    UInt8         pathname[PATH_MAX];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1499
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1500
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1501
    if ( !spec )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1502
      return FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1503
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1504
    err = FT_FSpMakePath( spec, pathname, sizeof ( pathname ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1505
    if ( err )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1506
      error = FT_Err_Cannot_Open_Resource;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1507
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1508
    error = FT_New_Face_From_Resource( library, pathname, face_index, aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1509
    if ( error != 0 || *aface != NULL )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1510
      return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1511
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1512
    /* fallback to datafork font */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1513
    args.flags    = FT_OPEN_PATHNAME;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1514
    args.pathname = (char*)pathname;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1515
    return FT_Open_Face( library, &args, face_index, aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1516
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1517
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1518
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1519
    FT_UNUSED( library );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1520
    FT_UNUSED( spec );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1521
    FT_UNUSED( face_index );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1522
    FT_UNUSED( aface );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1523
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1524
    return FT_Err_Unimplemented_Feature;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1525
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1526
#endif /* HAVE_FSREF, HAVE_FSSPEC */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1527
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1528
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1529
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1530
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
  1531
/* END */