misc/libfreetype/src/pfr/pfrgload.c
author sheepluva
Wed, 19 Oct 2011 16:10:18 +0200
changeset 6151 9fd5b70acb1a
parent 5172 88f2e05288ba
permissions -rw-r--r--
give the room name edit box a history of previous room. however I hate that box from the bottom of my heart, it shall dieeeee... later...
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
/*  pfrgload.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 PFR glyph loader (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, 2005, 2007, 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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    19
#include "pfrgload.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include "pfrsbit.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include "pfrload.h"            /* for macro definitions */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include "pfrerror.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
#undef  FT_COMPONENT
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#define FT_COMPONENT  trace_pfr
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
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
  /*************************************************************************/
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
  /*****                      PFR GLYPH BUILDER                        *****/
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
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_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
  pfr_glyph_init( PFR_Glyph       glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
                  FT_GlyphLoader  loader )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    42
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    43
    FT_ZERO( glyph );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
    glyph->loader     = loader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
    glyph->path_begun = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
    FT_GlyphLoader_Rewind( loader );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
  FT_LOCAL_DEF( void )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
  pfr_glyph_done( PFR_Glyph  glyph )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    55
    FT_Memory  memory = glyph->loader->memory;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
    FT_FREE( glyph->x_control );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
    glyph->y_control = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
    glyph->max_xy_control = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
#if 0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
    glyph->num_x_control  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
    glyph->num_y_control  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
#endif
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
    FT_FREE( glyph->subs );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    68
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    69
    glyph->max_subs = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
    glyph->num_subs = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    71
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    72
    glyph->loader     = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
    glyph->path_begun = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    75
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
  /* close current contour, if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
  pfr_glyph_close_contour( PFR_Glyph  glyph )
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
    FT_GlyphLoader  loader  = glyph->loader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
    FT_Outline*     outline = &loader->current.outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
    FT_Int          last, first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
    if ( !glyph->path_begun )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
      return;
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
    /* compute first and last point indices in current glyph outline */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    last  = outline->n_points - 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
    first = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    if ( outline->n_contours > 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
      first = outline->contours[outline->n_contours - 1];
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 the last point falls on the same location than the first one */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
    /* we need to delete it                                            */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
    if ( last > first )
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
      FT_Vector*  p1 = outline->points + first;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
      FT_Vector*  p2 = outline->points + last;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
      if ( p1->x == p2->x && p1->y == p2->y )
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
        outline->n_points--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
        last--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
      }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
    /* don't add empty contours */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    if ( last >= first )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
      outline->contours[outline->n_contours++] = (short)last;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
    glyph->path_begun = 0;
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
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
  /* reset glyph to start the loading of a new glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
  pfr_glyph_start( PFR_Glyph  glyph )
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
    glyph->path_begun = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   124
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   125
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
  pfr_glyph_line_to( PFR_Glyph   glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
                     FT_Vector*  to )
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
    FT_GlyphLoader  loader  = glyph->loader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
    FT_Outline*     outline = &loader->current.outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
    FT_Error        error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
    /* check that we have begun a new path */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
    if ( !glyph->path_begun )
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
      error = PFR_Err_Invalid_Table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
      FT_ERROR(( "pfr_glyph_line_to: invalid glyph data\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
      goto Exit;
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
    error = FT_GLYPHLOADER_CHECK_POINTS( loader, 1, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
      FT_UInt  n = outline->n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
      outline->points[n] = *to;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
      outline->tags  [n] = FT_CURVE_TAG_ON;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
      outline->n_points++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   154
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   155
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
  pfr_glyph_curve_to( PFR_Glyph   glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
                      FT_Vector*  control1,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
                      FT_Vector*  control2,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
                      FT_Vector*  to )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
    FT_GlyphLoader  loader  = glyph->loader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
    FT_Outline*     outline = &loader->current.outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
    FT_Error        error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
    /* check that we have begun a new path */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
    if ( !glyph->path_begun )
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
      error = PFR_Err_Invalid_Table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
      FT_ERROR(( "pfr_glyph_line_to: invalid glyph data\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    error = FT_GLYPHLOADER_CHECK_POINTS( loader, 3, 0 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
    if ( !error )
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_Vector*  vec = outline->points         + outline->n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
      FT_Byte*    tag = (FT_Byte*)outline->tags + outline->n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
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
      vec[0] = *control1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
      vec[1] = *control2;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
      vec[2] = *to;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
      tag[0] = FT_CURVE_TAG_CUBIC;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
      tag[1] = FT_CURVE_TAG_CUBIC;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
      tag[2] = FT_CURVE_TAG_ON;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
      outline->n_points = (FT_Short)( outline->n_points + 3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
    }
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   198
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   199
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
  pfr_glyph_move_to( PFR_Glyph   glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
                     FT_Vector*  to )
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
    FT_GlyphLoader  loader  = glyph->loader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
    FT_Error        error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
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
    /* close current contour if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
    pfr_glyph_close_contour( glyph );
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
    /* indicate that a new contour has started */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    glyph->path_begun = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   214
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   215
    /* check that there is space for a new contour and a new point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
    error = FT_GLYPHLOADER_CHECK_POINTS( loader, 1, 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
      /* add new start point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
      error = pfr_glyph_line_to( glyph, to );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   222
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   223
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
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
  pfr_glyph_end( PFR_Glyph  glyph )
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
    /* close current contour if any */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
    pfr_glyph_close_contour( glyph );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
    /* merge the current glyph into the stack */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
    FT_GlyphLoader_Add( glyph->loader );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   237
  /*************************************************************************/
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
  /*****                      PFR GLYPH LOADER                         *****/
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
  /*************************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   244
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
  /* load a simple glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
  pfr_glyph_load_simple( PFR_Glyph  glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
                         FT_Byte*   p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
                         FT_Byte*   limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   250
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   251
    FT_Error   error  = PFR_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
    FT_Memory  memory = glyph->loader->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
    FT_UInt    flags, x_count, y_count, i, count, mask;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
    FT_Int     x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
    PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
    flags = PFR_NEXT_BYTE( p );
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
    /* test for composite glyphs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
    if ( flags & PFR_GLYPH_IS_COMPOUND )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
      goto Failure;
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
    x_count = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
    y_count = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
    if ( flags & PFR_GLYPH_1BYTE_XYCOUNT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
      PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
      count   = PFR_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
      x_count = count & 15;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
      y_count = count >> 4;
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
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
      if ( flags & PFR_GLYPH_XCOUNT )
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
        PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
        x_count = PFR_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   280
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   281
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
      if ( flags & PFR_GLYPH_YCOUNT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
        PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
        y_count = PFR_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
    }
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
    count = x_count + y_count;
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
    /* re-allocate array when necessary */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
    if ( count > glyph->max_xy_control )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
      FT_UInt  new_max = FT_PAD_CEIL( count, 8 );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   297
      if ( FT_RENEW_ARRAY( glyph->x_control,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
                           glyph->max_xy_control,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
                           new_max ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
      glyph->max_xy_control = new_max;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
    }
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
    glyph->y_control = glyph->x_control + x_count;
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
    mask  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
    x     = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
    for ( i = 0; i < count; i++ )
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
      if ( ( i & 7 ) == 0 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
        PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
        mask = PFR_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   316
      }
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
      if ( mask & 1 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   319
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   320
        PFR_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
        x = PFR_NEXT_SHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   322
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   323
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
        PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
        x += PFR_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   327
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   328
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
      glyph->x_control[i] = x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
      mask >>= 1;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
    /* XXX: for now we ignore the secondary stroke and edge definitions */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
    /*      since we don't want to support native PFR hinting           */
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
    if ( flags & PFR_GLYPH_EXTRA_ITEMS )
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
      error = pfr_extra_items_skip( &p, limit );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
    }
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
    pfr_glyph_start( glyph );
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
    /* now load a simple glyph */
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
      FT_Vector   pos[4];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
      FT_Vector*  cur;
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
      pos[0].x = pos[0].y = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
      pos[3]   = pos[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
      for (;;)
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
        FT_UInt  format, format_low, args_format = 0, args_count, n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   359
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   360
        /***************************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
        /*  read instruction                                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
        /*                                                             */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   363
        PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
        format     = PFR_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
        format_low = format & 15;
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
        switch ( format >> 4 )
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
        case 0:                             /* end glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
          FT_TRACE6(( "- end glyph" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
          args_count = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
        case 1:                             /* general line operation */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
          FT_TRACE6(( "- general line" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
          goto Line1;
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
        case 4:                             /* move to inside contour  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
          FT_TRACE6(( "- move to inside" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
          goto Line1;
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
        case 5:                             /* move to outside contour */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
          FT_TRACE6(( "- move to outside" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
        Line1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
          args_format = format_low;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
          args_count  = 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
          break;
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
        case 2:                             /* horizontal line to */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
          FT_TRACE6(( "- horizontal line to cx.%d", format_low ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
          if ( format_low >= x_count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
            goto Failure;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
          pos[0].x   = glyph->x_control[format_low];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
          pos[0].y   = pos[3].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
          pos[3]     = pos[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
          args_count = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   398
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   399
        case 3:                             /* vertical line to */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
          FT_TRACE6(( "- vertical line to cy.%d", format_low ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
          if ( format_low >= y_count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
            goto Failure;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
          pos[0].x   = pos[3].x;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
          pos[0].y   = glyph->y_control[format_low];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
          pos[3]     = pos[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
          args_count = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
          break;
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
        case 6:                             /* horizontal to vertical curve */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
          FT_TRACE6(( "- hv curve " ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
          args_format = 0xB8E;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
          args_count  = 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
          break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   414
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   415
        case 7:                             /* vertical to horizontal curve */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
          FT_TRACE6(( "- vh curve" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
          args_format = 0xE2B;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
          args_count  = 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
          break;
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
        default:                            /* general curve to */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
          FT_TRACE6(( "- general curve" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
          args_count  = 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
          args_format = format_low;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   427
        /***********************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   428
        /*  now read arguments                                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   429
        /*                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   430
        cur = pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
        for ( n = 0; n < args_count; n++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
          FT_UInt  idx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
          FT_Int   delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
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
          /* read the X argument */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
          switch ( args_format & 3 )
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
          case 0:                           /* 8-bit index */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
            PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
            idx  = PFR_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
            if ( idx >= x_count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
              goto Failure;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
            cur->x = glyph->x_control[idx];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
            FT_TRACE7(( " cx#%d", idx ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
            break;
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
          case 1:                           /* 16-bit value */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
            PFR_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
            cur->x = PFR_NEXT_SHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
            FT_TRACE7(( " x.%d", cur->x ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   454
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   455
          case 2:                           /* 8-bit delta */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
            PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
            delta  = PFR_NEXT_INT8( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
            cur->x = pos[3].x + delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
            FT_TRACE7(( " dx.%d", delta ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
            break;
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
          default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
            FT_TRACE7(( " |" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
            cur->x = pos[3].x;
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
          /* read the Y argument */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
          switch ( ( args_format >> 2 ) & 3 )
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
          case 0:                           /* 8-bit index */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
            PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
            idx  = PFR_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
            if ( idx >= y_count )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
              goto Failure;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
            cur->y = glyph->y_control[idx];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
            FT_TRACE7(( " cy#%d", idx ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
            break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
          case 1:                           /* 16-bit absolute value */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
            PFR_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
            cur->y = PFR_NEXT_SHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
            FT_TRACE7(( " y.%d", cur->y ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
            break;
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
          case 2:                           /* 8-bit delta */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
            PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
            delta  = PFR_NEXT_INT8( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
            cur->y = pos[3].y + delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
            FT_TRACE7(( " dy.%d", delta ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
            break;
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
          default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
            FT_TRACE7(( " -" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
            cur->y = pos[3].y;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   496
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   497
          /* read the additional format flag for the general curve */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
          if ( n == 0 && args_count == 4 )
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
            PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   501
            args_format = PFR_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   502
            args_count--;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   503
          }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   504
          else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   505
            args_format >>= 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   506
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   507
          /* save the previous point */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   508
          pos[3] = cur[0];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   509
          cur++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   510
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   511
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   512
        FT_TRACE7(( "\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   513
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   514
        /***********************************************************/
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   515
        /*  finally, execute instruction                           */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   516
        /*                                                         */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   517
        switch ( format >> 4 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   518
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   519
        case 0:                             /* end glyph => EXIT */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   520
          pfr_glyph_end( glyph );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   521
          goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   522
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   523
        case 1:                             /* line operations */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   524
        case 2:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   525
        case 3:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   526
          error = pfr_glyph_line_to( glyph, pos );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   527
          goto Test_Error;
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
        case 4:                             /* move to inside contour  */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   530
        case 5:                             /* move to outside contour */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   531
          error = pfr_glyph_move_to( glyph, pos );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   532
          goto Test_Error;
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
        default:                            /* curve operations */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   535
          error = pfr_glyph_curve_to( glyph, pos, pos + 1, pos + 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   536
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   537
        Test_Error:  /* test error condition */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   538
          if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   539
            goto Exit;
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
      } /* for (;;) */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   542
    }
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   545
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   546
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   547
  Failure:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   548
  Too_Short:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   549
    error = PFR_Err_Invalid_Table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   550
    FT_ERROR(( "pfr_glyph_load_simple: invalid glyph data\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   551
    goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   552
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   553
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   554
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   555
  /* load a composite/compound glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   556
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   557
  pfr_glyph_load_compound( PFR_Glyph  glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   558
                           FT_Byte*   p,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   559
                           FT_Byte*   limit )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   560
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   561
    FT_Error        error  = PFR_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   562
    FT_GlyphLoader  loader = glyph->loader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   563
    FT_Memory       memory = loader->memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   564
    PFR_SubGlyph    subglyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   565
    FT_UInt         flags, i, count, org_count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   566
    FT_Int          x_pos, y_pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   567
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
    PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   570
    flags = PFR_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   571
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   572
    /* test for composite glyphs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   573
    if ( !( flags & PFR_GLYPH_IS_COMPOUND ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   574
      goto Failure;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   575
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   576
    count = flags & 0x3F;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   577
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   578
    /* ignore extra items when present */
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
    if ( flags & PFR_GLYPH_EXTRA_ITEMS )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   581
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   582
      error = pfr_extra_items_skip( &p, limit );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   583
      if (error) goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   584
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   585
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   586
    /* we can't rely on the FT_GlyphLoader to load sub-glyphs, because   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   587
    /* the PFR format is dumb, using direct file offsets to point to the */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   588
    /* sub-glyphs (instead of glyph indices).  Sigh.                     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   589
    /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   590
    /* For now, we load the list of sub-glyphs into a different array    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   591
    /* but this will prevent us from using the auto-hinter at its best   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   592
    /* quality.                                                          */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   593
    /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   594
    org_count = glyph->num_subs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   595
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   596
    if ( org_count + count > glyph->max_subs )
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
      FT_UInt  new_max = ( org_count + count + 3 ) & (FT_UInt)-4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   599
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   600
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   601
      /* we arbitrarily limit the number of subglyphs */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   602
      /* to avoid endless recursion                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   603
      if ( new_max > 64 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   604
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   605
        error = PFR_Err_Invalid_Table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   606
        FT_ERROR(( "pfr_glyph_load_compound:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   607
                   " too many compound glyphs components\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   608
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   609
      }
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
      if ( FT_RENEW_ARRAY( glyph->subs, glyph->max_subs, new_max ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   612
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   613
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   614
      glyph->max_subs = new_max;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   615
    }
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
    subglyph = glyph->subs + org_count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   618
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   619
    for ( i = 0; i < count; i++, subglyph++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   620
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   621
      FT_UInt  format;
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
      x_pos = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   625
      y_pos = 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
      PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   628
      format = PFR_NEXT_BYTE( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   629
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   630
      /* read scale when available */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   631
      subglyph->x_scale = 0x10000L;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   632
      if ( format & PFR_SUBGLYPH_XSCALE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   633
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   634
        PFR_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   635
        subglyph->x_scale = PFR_NEXT_SHORT( p ) << 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   636
      }
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
      subglyph->y_scale = 0x10000L;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   639
      if ( format & PFR_SUBGLYPH_YSCALE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   640
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   641
        PFR_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   642
        subglyph->y_scale = PFR_NEXT_SHORT( p ) << 4;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   643
      }
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
      /* read offset */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   646
      switch ( format & 3 )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   647
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   648
      case 1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   649
        PFR_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   650
        x_pos = PFR_NEXT_SHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   651
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   652
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   653
      case 2:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   654
        PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   655
        x_pos += PFR_NEXT_INT8( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   656
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   657
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   658
      default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   659
        ;
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
      switch ( ( format >> 2 ) & 3 )
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
      case 1:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   665
        PFR_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   666
        y_pos = PFR_NEXT_SHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   667
        break;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   668
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   669
      case 2:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   670
        PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   671
        y_pos += PFR_NEXT_INT8( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   672
        break;
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
      default:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   675
        ;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   676
      }
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
      subglyph->x_delta = x_pos;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   679
      subglyph->y_delta = y_pos;
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
      /* read glyph position and size now */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   682
      if ( format & PFR_SUBGLYPH_2BYTE_SIZE )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   683
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   684
        PFR_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   685
        subglyph->gps_size = PFR_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   686
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   687
      else
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
        PFR_CHECK( 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   690
        subglyph->gps_size = PFR_NEXT_BYTE( p );
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
      if ( format & PFR_SUBGLYPH_3BYTE_OFFSET )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   694
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   695
        PFR_CHECK( 3 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   696
        subglyph->gps_offset = PFR_NEXT_LONG( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   697
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   698
      else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   699
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   700
        PFR_CHECK( 2 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   701
        subglyph->gps_offset = PFR_NEXT_USHORT( p );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   702
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   703
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   704
      glyph->num_subs++;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   705
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   706
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   707
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   708
    return error;
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
  Failure:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   711
  Too_Short:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   712
    error = PFR_Err_Invalid_Table;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   713
    FT_ERROR(( "pfr_glyph_load_compound: invalid glyph data\n" ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   714
    goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   718
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   719
  pfr_glyph_load_rec( PFR_Glyph  glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   720
                      FT_Stream  stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   721
                      FT_ULong   gps_offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   722
                      FT_ULong   offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   723
                      FT_ULong   size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   724
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   725
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   726
    FT_Byte*  p;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   727
    FT_Byte*  limit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   728
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   729
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   730
    if ( FT_STREAM_SEEK( gps_offset + offset ) ||
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   731
         FT_FRAME_ENTER( size )                )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   732
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   733
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   734
    p     = (FT_Byte*)stream->cursor;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   735
    limit = p + size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   736
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   737
    if ( size > 0 && *p & PFR_GLYPH_IS_COMPOUND )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   738
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   739
      FT_Int          n, old_count, count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   740
      FT_GlyphLoader  loader = glyph->loader;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   741
      FT_Outline*     base   = &loader->base.outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   742
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
      old_count = glyph->num_subs;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   745
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   746
      /* this is a compound glyph - load it */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   747
      error = pfr_glyph_load_compound( glyph, p, limit );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   748
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   749
      FT_FRAME_EXIT();
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
      if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   752
        goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   753
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   754
      count = glyph->num_subs - old_count;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   755
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   756
      FT_TRACE4(( "compound glyph with %d elements (offset %lu):\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   757
                  count, offset ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   758
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   759
      /* now, load each individual glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   760
      for ( n = 0; n < count; n++ )
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
        FT_Int        i, old_points, num_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   763
        PFR_SubGlyph  subglyph;
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
        FT_TRACE4(( "subglyph %d:\n", n ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   767
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   768
        subglyph   = glyph->subs + old_count + n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   769
        old_points = base->n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   770
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   771
        error = pfr_glyph_load_rec( glyph, stream, gps_offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   772
                                    subglyph->gps_offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   773
                                    subglyph->gps_size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   774
        if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   775
          break;
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
        /* note that `glyph->subs' might have been re-allocated */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   778
        subglyph   = glyph->subs + old_count + n;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   779
        num_points = base->n_points - old_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   780
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   781
        /* translate and eventually scale the new glyph points */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   782
        if ( subglyph->x_scale != 0x10000L || subglyph->y_scale != 0x10000L )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   783
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   784
          FT_Vector*  vec = base->points + old_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   785
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   786
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   787
          for ( i = 0; i < num_points; i++, vec++ )
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
            vec->x = FT_MulFix( vec->x, subglyph->x_scale ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   790
                       subglyph->x_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   791
            vec->y = FT_MulFix( vec->y, subglyph->y_scale ) +
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   792
                       subglyph->y_delta;
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
        }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   795
        else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   796
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   797
          FT_Vector*  vec = loader->base.outline.points + old_points;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   800
          for ( i = 0; i < num_points; i++, vec++ )
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
            vec->x += subglyph->x_delta;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   803
            vec->y += subglyph->y_delta;
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
        }
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
        /* proceed to next sub-glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   808
      }
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
      FT_TRACE4(( "end compound glyph with %d elements\n", count ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   811
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   812
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   813
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   814
      FT_TRACE4(( "simple glyph (offset %lu)\n", offset ));
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
      /* load a simple glyph */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   817
      error = pfr_glyph_load_simple( glyph, p, limit );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   818
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   819
      FT_FRAME_EXIT();
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   820
    }
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   823
    return error;
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
  FT_LOCAL_DEF( FT_Error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   828
  pfr_glyph_load( PFR_Glyph  glyph,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   829
                  FT_Stream  stream,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   830
                  FT_ULong   gps_offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   831
                  FT_ULong   offset,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   832
                  FT_ULong   size )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   833
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   834
    /* initialize glyph loader */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   835
    FT_GlyphLoader_Rewind( glyph->loader );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   836
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   837
    glyph->num_subs = 0;
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
    /* load the glyph, recursively when needed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   840
    return pfr_glyph_load_rec( glyph, stream, gps_offset, offset, size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   841
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   842
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
/* END */