misc/libfreetype/src/base/ftpfr.c
author nemo
Sat, 25 Aug 2012 21:14:07 -0400
changeset 7607 0cae2a3e562c
parent 5172 88f2e05288ba
permissions -rw-r--r--
shoppa hack guesses. continued. let's assume there's a small Y component.
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
/*  ftpfr.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
/*    FreeType API for accessing PFR-specific data (body).                 */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     6
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     7
/*  Copyright 2002, 2003, 2004, 2008, 2010 by                              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     8
/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
     9
/*                                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    10
/*  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
    11
/*  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
    12
/*  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
    13
/*  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
    14
/*  understand and accept it fully.                                        */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    15
/*                                                                         */
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
#include <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
#include FT_INTERNAL_OBJECTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include FT_SERVICE_PFR_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
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
  /* check the format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
  static FT_Service_PfrMetrics
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
  ft_pfr_check( FT_Face  face )
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
    FT_Service_PfrMetrics  service = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    28
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    29
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
    if ( face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
      FT_FACE_LOOKUP_SERVICE( face, service, PFR_METRICS );
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
    return service;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    36
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
  /* documentation is in ftpfr.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
  FT_Get_PFR_Metrics( FT_Face    face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
                      FT_UInt   *aoutline_resolution,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
                      FT_UInt   *ametrics_resolution,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
                      FT_Fixed  *ametrics_x_scale,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
                      FT_Fixed  *ametrics_y_scale )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
    FT_Error               error = FT_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
    FT_Service_PfrMetrics  service;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    50
    if ( !face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
      return FT_Err_Invalid_Argument;
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
    service = ft_pfr_check( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
    if ( service )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    56
      error = service->get_metrics( face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    57
                                    aoutline_resolution,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
                                    ametrics_resolution,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
                                    ametrics_x_scale,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
                                    ametrics_y_scale );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
    else
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
      FT_Fixed  x_scale, y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
      /* this is not a PFR font */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
      if ( aoutline_resolution )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
        *aoutline_resolution = face->units_per_EM;
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 ( ametrics_resolution )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
        *ametrics_resolution = face->units_per_EM;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
      x_scale = y_scale = 0x10000L;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
      if ( face->size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    76
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
        x_scale = face->size->metrics.x_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
        y_scale = face->size->metrics.y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
      if ( ametrics_x_scale )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
        *ametrics_x_scale = x_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
      if ( ametrics_y_scale )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
        *ametrics_y_scale = y_scale;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
      error = FT_Err_Unknown_File_Format;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    94
  /* documentation is in ftpfr.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    95
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
  FT_Get_PFR_Kerning( FT_Face     face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
                      FT_UInt     left,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
                      FT_UInt     right,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
                      FT_Vector  *avector )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
    FT_Error               error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
    FT_Service_PfrMetrics  service;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
    if ( !face )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
      return FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
    service = ft_pfr_check( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
    if ( service )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
      error = service->get_kerning( face, left, right, avector );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
      error = FT_Get_Kerning( face, left, right,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
                              FT_KERNING_UNSCALED, avector );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   116
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   117
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
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
  /* documentation is in ftpfr.h */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
  FT_EXPORT_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
  FT_Get_PFR_Advance( FT_Face   face,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
                      FT_UInt   gindex,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
                      FT_Pos   *aadvance )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
    FT_Error               error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
    FT_Service_PfrMetrics  service;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
    service = ft_pfr_check( face );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
    if ( service )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   134
      error = service->get_advance( face, gindex, aadvance );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
      /* XXX: TODO: PROVIDE ADVANCE-LOADING METHOD TO ALL FONT DRIVERS */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
      error = FT_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   142
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   143
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
/* END */