Imported Upstream version 2.13.2
[platform/upstream/freetype2.git] / src / base / ftmac.c
index e97fdbf..492d055 100644 (file)
@@ -1,23 +1,23 @@
-/***************************************************************************/
-/*                                                                         */
-/*  ftmac.c                                                                */
-/*                                                                         */
-/*    Mac FOND support.  Written by just@letterror.com.                    */
-/*  Heavily modified by mpsuzuki, George Williams, and Sean McBride.       */
-/*                                                                         */
-/*  This file is for Mac OS X only; see builds/mac/ftoldmac.c for          */
-/*  classic platforms built by MPW.                                        */
-/*                                                                         */
-/*  Copyright 1996-2016 by                                                 */
-/*  Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg.     */
-/*                                                                         */
-/*  This file is part of the FreeType project, and may only be used,       */
-/*  modified, and distributed under the terms of the FreeType project      */
-/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
-/*  this file you indicate that you have read the license and              */
-/*  understand and accept it fully.                                        */
-/*                                                                         */
-/***************************************************************************/
+/****************************************************************************
+ *
+ * ftmac.c
+ *
+ *   Mac FOND support.  Written by just@letterror.com.
+ * Heavily modified by mpsuzuki, George Williams, and Sean McBride.
+ *
+ * This file is for Mac OS X only; see builds/mac/ftoldmac.c for
+ * classic platforms built by MPW.
+ *
+ * Copyright (C) 1996-2023 by
+ * Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg.
+ *
+ * This file is part of the FreeType project, and may only be used,
+ * modified, and distributed under the terms of the FreeType project
+ * license, LICENSE.TXT.  By continuing to use, modify, or distribute
+ * this file you indicate that you have read the license and
+ * understand and accept it fully.
+ *
+ */
 
 
   /*
   */
 
 
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_TRUETYPE_TAGS_H
-#include FT_INTERNAL_STREAM_H
+#include <freetype/freetype.h>
+#include <freetype/tttags.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/internal/ftstream.h>
 #include "ftbase.h"
 
+
+#ifdef FT_MACINTOSH
+
   /* This is for Mac OS X.  Without redefinition, OS_INLINE */
   /* expands to `static inline' which doesn't survive the   */
   /* -ansi compilation flag of GCC.                         */
   /* Don't want warnings about our own use of deprecated functions. */
 #define FT_DEPRECATED_ATTRIBUTE
 
-#include FT_MAC_H
+#include <freetype/ftmac.h>
 
 #ifndef kATSOptionFlagsUnRestrictedScope /* since Mac OS X 10.1 */
 #define kATSOptionFlagsUnRestrictedScope kATSOptionFlagsDefault
 #endif
 
 
-#ifdef FT_MACINTOSH
-
   /* This function is deprecated because FSSpec is deprecated in Mac OS X  */
   FT_EXPORT_DEF( FT_Error )
   FT_GetFile_From_Mac_Name( const char*  fontName,
                                     NULL, NULL, NULL ) )
       return ( OSType ) 0;
 
-    return ((FInfo *)(info.finderInfo))->fdType;
+    return ( (FInfo *)( info.finderInfo ) )->fdType;
   }
 
 
 
         if ( ps_name_len != 0 )
         {
-          ft_memcpy(ps_name, names[0] + 1, ps_name_len);
+          ft_memcpy( ps_name, names[0] + 1, ps_name_len );
           ps_name[ps_name_len] = 0;
         }
         if ( style->indexes[face_index] > 1 &&
     if ( lwfn_file_name[0] )
     {
       err = lookup_lwfn_by_fond( pathname, lwfn_file_name,
-                                 buff, sizeof ( buff )  );
+                                 buff, sizeof ( buff ) );
       if ( !err )
         have_lwfn = 1;
     }
     for (;;)
     {
       post_data = Get1Resource( TTAG_POST, res_id++ );
-      if ( post_data == NULL )
+      if ( !post_data )
         break;  /* we are done */
 
       code = (*post_data)[0];
       old_total_size = total_size;
     }
 
-    if ( FT_ALLOC( buffer, (FT_Long)total_size ) )
+    if ( FT_QALLOC( buffer, (FT_Long)total_size ) )
       goto Error;
 
     /* Second pass: append all POST data to the buffer, add PFB fields. */
     for (;;)
     {
       post_data = Get1Resource( TTAG_POST, res_id++ );
-      if ( post_data == NULL )
+      if ( !post_data )
         break;  /* we are done */
 
       post_size = (FT_ULong)GetHandleSize( post_data ) - 2;
         if ( last_code != -1 )
         {
           /* we are done adding a chunk, fill in the size field */
-          if ( size_p != NULL )
+          if ( size_p )
           {
             *size_p++ = (FT_Byte)(   pfb_chunk_size         & 0xFF );
             *size_p++ = (FT_Byte)( ( pfb_chunk_size >> 8  ) & 0xFF );
 
 
     sfnt = GetResource( TTAG_sfnt, sfnt_id );
-    if ( sfnt == NULL )
+    if ( !sfnt )
       return FT_THROW( Invalid_Handle );
 
     sfnt_size = (FT_ULong)GetHandleSize( sfnt );
     if ( FT_MAC_RFORK_MAX_LEN < sfnt_size )
       return FT_THROW( Array_Too_Large );
 
-    if ( FT_ALLOC( sfnt_data, (FT_Long)sfnt_size ) )
+    if ( FT_QALLOC( sfnt_data, (FT_Long)sfnt_size ) )
     {
       ReleaseResource( sfnt );
       return error;
       return FT_THROW( Cannot_Open_Resource );
 
     num_faces_in_res = 0;
-    for ( res_index = 1; ; ++res_index )
+    for ( res_index = 1; ; res_index++ )
     {
       short  num_faces_in_fond;
 
     /* if it works, fine.                                           */
 
     error = FT_New_Face_From_Suitcase( library, pathname, face_index, aface );
-    if ( error == 0 )
-      return error;
+    if ( error )
+    {
+      /* let it fall through to normal loader (.ttf, .otf, etc.); */
+      /* we signal this by returning no error and no FT_Face      */
+      *aface = NULL;
+    }
 
-    /* let it fall through to normal loader (.ttf, .otf, etc.); */
-    /* we signal this by returning no error and no FT_Face      */
-    *aface = NULL;
-    return 0;
+    return FT_Err_Ok;
   }
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    FT_New_Face                                                        */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    This is the Mac-specific implementation of FT_New_Face.  In        */
-  /*    addition to the standard FT_New_Face() functionality, it also      */
-  /*    accepts pathnames to Mac suitcase files.  For further              */
-  /*    documentation see the original FT_New_Face() in freetype.h.        */
-  /*                                                                       */
+  /**************************************************************************
+   *
+   * @Function:
+   *   FT_New_Face
+   *
+   * @Description:
+   *   This is the Mac-specific implementation of FT_New_Face.  In
+   *   addition to the standard FT_New_Face() functionality, it also
+   *   accepts pathnames to Mac suitcase files.  For further
+   *   documentation see the original FT_New_Face() in freetype.h.
+   */
   FT_EXPORT_DEF( FT_Error )
   FT_New_Face( FT_Library   library,
                const char*  pathname,
     /* try resourcefork based font: LWFN, FFIL */
     error = FT_New_Face_From_Resource( library, (UInt8 *)pathname,
                                        face_index, aface );
-    if ( error != 0 || *aface != NULL )
+    if ( error || *aface )
       return error;
 
     /* let it fall through to normal loader (.ttf, .otf, etc.) */
     args.flags    = FT_OPEN_PATHNAME;
     args.pathname = (char*)pathname;
+
     return FT_Open_Face( library, &args, face_index, aface );
   }
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    FT_New_Face_From_FSRef                                             */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    FT_New_Face_From_FSRef is identical to FT_New_Face except it       */
-  /*    accepts an FSRef instead of a path.                                */
-  /*                                                                       */
-  /* This function is deprecated because Carbon data types (FSRef)         */
-  /* are not cross-platform, and thus not suitable for the freetype API.   */
+  /**************************************************************************
+   *
+   * @Function:
+   *   FT_New_Face_From_FSRef
+   *
+   * @Description:
+   *   FT_New_Face_From_FSRef is identical to FT_New_Face except it
+   *   accepts an FSRef instead of a path.
+   *
+   * This function is deprecated because Carbon data types (FSRef)
+   * are not cross-platform, and thus not suitable for the FreeType API.
+   */
   FT_EXPORT_DEF( FT_Error )
   FT_New_Face_From_FSRef( FT_Library    library,
                           const FSRef*  ref,
       error = FT_THROW( Cannot_Open_Resource );
 
     error = FT_New_Face_From_Resource( library, pathname, face_index, aface );
-    if ( error != 0 || *aface != NULL )
+    if ( error || *aface )
       return error;
 
     /* fallback to datafork font */
   }
 
 
-  /*************************************************************************/
-  /*                                                                       */
-  /* <Function>                                                            */
-  /*    FT_New_Face_From_FSSpec                                            */
-  /*                                                                       */
-  /* <Description>                                                         */
-  /*    FT_New_Face_From_FSSpec is identical to FT_New_Face except it      */
-  /*    accepts an FSSpec instead of a path.                               */
-  /*                                                                       */
-  /* This function is deprecated because FSSpec is deprecated in Mac OS X  */
+  /**************************************************************************
+   *
+   * @Function:
+   *   FT_New_Face_From_FSSpec
+   *
+   * @Description:
+   *   FT_New_Face_From_FSSpec is identical to FT_New_Face except it
+   *   accepts an FSSpec instead of a path.
+   *
+   * This function is deprecated because FSSpec is deprecated in Mac OS X
+   */
   FT_EXPORT_DEF( FT_Error )
   FT_New_Face_From_FSSpec( FT_Library     library,
                            const FSSpec*  spec,
 #endif
   }
 
-#endif /* FT_MACINTOSH */
+#else /* !FT_MACINTOSH */
+
+  /* ANSI C doesn't like empty source files */
+  typedef int  ft_mac_dummy_;
+
+#endif /* !FT_MACINTOSH */
 
 
 /* END */