Home | History | Annotate | Download | only in base
      1 /***************************************************************************/
      2 /*                                                                         */
      3 /*  ftmm.c                                                                 */
      4 /*                                                                         */
      5 /*    Multiple Master font support (body).                                 */
      6 /*                                                                         */
      7 /*  Copyright 1996-2016 by                                                 */
      8 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
      9 /*                                                                         */
     10 /*  This file is part of the FreeType project, and may only be used,       */
     11 /*  modified, and distributed under the terms of the FreeType project      */
     12 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
     13 /*  this file you indicate that you have read the license and              */
     14 /*  understand and accept it fully.                                        */
     15 /*                                                                         */
     16 /***************************************************************************/
     17 
     18 
     19 #include <ft2build.h>
     20 #include FT_INTERNAL_DEBUG_H
     21 
     22 #include FT_MULTIPLE_MASTERS_H
     23 #include FT_INTERNAL_OBJECTS_H
     24 #include FT_SERVICE_MULTIPLE_MASTERS_H
     25 
     26 
     27   /*************************************************************************/
     28   /*                                                                       */
     29   /* The macro FT_COMPONENT is used in trace mode.  It is an implicit      */
     30   /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log  */
     31   /* messages during execution.                                            */
     32   /*                                                                       */
     33 #undef  FT_COMPONENT
     34 #define FT_COMPONENT  trace_mm
     35 
     36 
     37   static FT_Error
     38   ft_face_get_mm_service( FT_Face                   face,
     39                           FT_Service_MultiMasters  *aservice )
     40   {
     41     FT_Error  error;
     42 
     43 
     44     *aservice = NULL;
     45 
     46     if ( !face )
     47       return FT_THROW( Invalid_Face_Handle );
     48 
     49     error = FT_ERR( Invalid_Argument );
     50 
     51     if ( FT_HAS_MULTIPLE_MASTERS( face ) )
     52     {
     53       FT_FACE_LOOKUP_SERVICE( face,
     54                               *aservice,
     55                               MULTI_MASTERS );
     56 
     57       if ( *aservice )
     58         error = FT_Err_Ok;
     59     }
     60 
     61     return error;
     62   }
     63 
     64 
     65   /* documentation is in ftmm.h */
     66 
     67   FT_EXPORT_DEF( FT_Error )
     68   FT_Get_Multi_Master( FT_Face           face,
     69                        FT_Multi_Master  *amaster )
     70   {
     71     FT_Error                 error;
     72     FT_Service_MultiMasters  service;
     73 
     74 
     75     /* check of `face' delayed to `ft_face_get_mm_service' */
     76 
     77     if ( !amaster )
     78       return FT_THROW( Invalid_Argument );
     79 
     80     error = ft_face_get_mm_service( face, &service );
     81     if ( !error )
     82     {
     83       error = FT_ERR( Invalid_Argument );
     84       if ( service->get_mm )
     85         error = service->get_mm( face, amaster );
     86     }
     87 
     88     return error;
     89   }
     90 
     91 
     92   /* documentation is in ftmm.h */
     93 
     94   FT_EXPORT_DEF( FT_Error )
     95   FT_Get_MM_Var( FT_Face      face,
     96                  FT_MM_Var*  *amaster )
     97   {
     98     FT_Error                 error;
     99     FT_Service_MultiMasters  service;
    100 
    101 
    102     /* check of `face' delayed to `ft_face_get_mm_service' */
    103 
    104     if ( !amaster )
    105       return FT_THROW( Invalid_Argument );
    106 
    107     error = ft_face_get_mm_service( face, &service );
    108     if ( !error )
    109     {
    110       error = FT_ERR( Invalid_Argument );
    111       if ( service->get_mm_var )
    112         error = service->get_mm_var( face, amaster );
    113     }
    114 
    115     return error;
    116   }
    117 
    118 
    119   /* documentation is in ftmm.h */
    120 
    121   FT_EXPORT_DEF( FT_Error )
    122   FT_Set_MM_Design_Coordinates( FT_Face   face,
    123                                 FT_UInt   num_coords,
    124                                 FT_Long*  coords )
    125   {
    126     FT_Error                 error;
    127     FT_Service_MultiMasters  service;
    128 
    129 
    130     /* check of `face' delayed to `ft_face_get_mm_service' */
    131 
    132     if ( !coords )
    133       return FT_THROW( Invalid_Argument );
    134 
    135     error = ft_face_get_mm_service( face, &service );
    136     if ( !error )
    137     {
    138       error = FT_ERR( Invalid_Argument );
    139       if ( service->set_mm_design )
    140         error = service->set_mm_design( face, num_coords, coords );
    141     }
    142 
    143     return error;
    144   }
    145 
    146 
    147   /* documentation is in ftmm.h */
    148 
    149   FT_EXPORT_DEF( FT_Error )
    150   FT_Set_Var_Design_Coordinates( FT_Face    face,
    151                                  FT_UInt    num_coords,
    152                                  FT_Fixed*  coords )
    153   {
    154     FT_Error                 error;
    155     FT_Service_MultiMasters  service;
    156 
    157 
    158     /* check of `face' delayed to `ft_face_get_mm_service' */
    159 
    160     if ( !coords )
    161       return FT_THROW( Invalid_Argument );
    162 
    163     error = ft_face_get_mm_service( face, &service );
    164     if ( !error )
    165     {
    166       error = FT_ERR( Invalid_Argument );
    167       if ( service->set_var_design )
    168         error = service->set_var_design( face, num_coords, coords );
    169     }
    170 
    171     return error;
    172   }
    173 
    174 
    175   /* documentation is in ftmm.h */
    176 
    177   FT_EXPORT_DEF( FT_Error )
    178   FT_Set_MM_Blend_Coordinates( FT_Face    face,
    179                                FT_UInt    num_coords,
    180                                FT_Fixed*  coords )
    181   {
    182     FT_Error                 error;
    183     FT_Service_MultiMasters  service;
    184 
    185 
    186     /* check of `face' delayed to `ft_face_get_mm_service' */
    187 
    188     if ( !coords )
    189       return FT_THROW( Invalid_Argument );
    190 
    191     error = ft_face_get_mm_service( face, &service );
    192     if ( !error )
    193     {
    194       error = FT_ERR( Invalid_Argument );
    195       if ( service->set_mm_blend )
    196          error = service->set_mm_blend( face, num_coords, coords );
    197     }
    198 
    199     return error;
    200   }
    201 
    202 
    203   /* documentation is in ftmm.h */
    204 
    205   /* This is exactly the same as the previous function.  It exists for */
    206   /* orthogonality.                                                    */
    207 
    208   FT_EXPORT_DEF( FT_Error )
    209   FT_Set_Var_Blend_Coordinates( FT_Face    face,
    210                                 FT_UInt    num_coords,
    211                                 FT_Fixed*  coords )
    212   {
    213     FT_Error                 error;
    214     FT_Service_MultiMasters  service;
    215 
    216 
    217     /* check of `face' delayed to `ft_face_get_mm_service' */
    218 
    219     if ( !coords )
    220       return FT_THROW( Invalid_Argument );
    221 
    222     error = ft_face_get_mm_service( face, &service );
    223     if ( !error )
    224     {
    225       error = FT_ERR( Invalid_Argument );
    226       if ( service->set_mm_blend )
    227          error = service->set_mm_blend( face, num_coords, coords );
    228     }
    229 
    230     return error;
    231   }
    232 
    233 
    234 /* END */
    235