misc/libfreetype/src/raster/ftrend1.c
author koda
Mon, 25 Apr 2011 01:46:54 +0200
changeset 5172 88f2e05288ba
permissions -rw-r--r--
aaand let's add freetype as well while we are at it other smaller changes
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
/*  ftrend1.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
/*    The FreeType glyph rasterizer interface (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 1996-2001, 2002, 2003, 2005, 2006 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 <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include FT_INTERNAL_OBJECTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include FT_OUTLINE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include "ftrend1.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include "ftraster.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include "rastpic.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
#include "rasterrs.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
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
  /* initialize renderer -- init its raster */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    30
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
  ft_raster1_init( FT_Renderer  render )
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
    FT_Library  library = FT_MODULE_LIBRARY( render );
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
    render->clazz->raster_class->raster_reset( render->raster,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    37
                                               library->raster_pool,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    38
                                               library->raster_pool_size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
    return Raster_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    44
  /* set render-specific mode */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
  ft_raster1_set_mode( FT_Renderer  render,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
                       FT_ULong     mode_tag,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
                       FT_Pointer   data )
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
    /* we simply pass it to the raster */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    51
    return render->clazz->raster_class->raster_set_mode( render->raster,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
                                                         mode_tag,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    53
                                                         data );
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
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
  /* transform a given glyph image */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    58
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    59
  ft_raster1_transform( FT_Renderer       render,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    60
                        FT_GlyphSlot      slot,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    61
                        const FT_Matrix*  matrix,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    62
                        const FT_Vector*  delta )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    63
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    64
    FT_Error error = Raster_Err_Ok;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    65
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    66
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    67
    if ( slot->format != render->glyph_format )
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
      error = Raster_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    70
      goto Exit;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    73
    if ( matrix )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    74
      FT_Outline_Transform( &slot->outline, matrix );
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
    if ( delta )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    77
      FT_Outline_Translate( &slot->outline, delta->x, delta->y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    78
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    79
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    80
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    81
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    82
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    83
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    84
  /* return the glyph's control box */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    85
  static void
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    86
  ft_raster1_get_cbox( FT_Renderer   render,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    87
                       FT_GlyphSlot  slot,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    88
                       FT_BBox*      cbox )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    89
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    90
    FT_MEM_ZERO( cbox, sizeof ( *cbox ) );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    91
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    92
    if ( slot->format == render->glyph_format )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    93
      FT_Outline_Get_CBox( &slot->outline, cbox );
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    96
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    97
  /* convert a slot's glyph image into a bitmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    98
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    99
  ft_raster1_render( FT_Renderer       render,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   100
                     FT_GlyphSlot      slot,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   101
                     FT_Render_Mode    mode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   102
                     const FT_Vector*  origin )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   103
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   104
    FT_Error     error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   105
    FT_Outline*  outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
    FT_BBox      cbox;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
    FT_UInt      width, height, pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
    FT_Bitmap*   bitmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
    FT_Memory    memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    FT_Raster_Params  params;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
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
    /* check glyph image format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
    if ( slot->format != render->glyph_format )
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
      error = Raster_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   118
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   120
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   121
    /* check rendering mode */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
#ifndef FT_CONFIG_OPTION_PIC
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   123
    if ( mode != FT_RENDER_MODE_MONO )
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
      /* raster1 is only capable of producing monochrome bitmaps */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
      if ( render->clazz == &ft_raster1_renderer_class )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
        return Raster_Err_Cannot_Render_Glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   128
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   129
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   130
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   131
      /* raster5 is only capable of producing 5-gray-levels bitmaps */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   132
      if ( render->clazz == &ft_raster5_renderer_class )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
        return Raster_Err_Cannot_Render_Glyph;
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
#else /* FT_CONFIG_OPTION_PIC */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   136
    /* When PIC is enabled, we cannot get to the class object      */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   137
    /* so instead we check the final character in the class name   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   138
    /* ("raster5" or "raster1"). Yes this is a hack.               */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    /* The "correct" thing to do is have different render function */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    /* for each of the classes.                                    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    if ( mode != FT_RENDER_MODE_MONO )
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
      /* raster1 is only capable of producing monochrome bitmaps */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
      if ( render->clazz->root.module_name[6] == '1' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
        return Raster_Err_Cannot_Render_Glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
    else
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
      /* raster5 is only capable of producing 5-gray-levels bitmaps */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
      if ( render->clazz->root.module_name[6] == '5' )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
        return Raster_Err_Cannot_Render_Glyph;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   152
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
#endif /* FT_CONFIG_OPTION_PIC */
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
    outline = &slot->outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
    /* translate the outline to the new origin if needed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
    if ( origin )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   159
      FT_Outline_Translate( outline, origin->x, origin->y );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   160
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
    /* compute the control box, and grid fit it */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   162
    FT_Outline_Get_CBox( outline, &cbox );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
    /* undocumented but confirmed: bbox values get rounded */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   165
#if 1
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   166
    cbox.xMin = FT_PIX_ROUND( cbox.xMin );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
    cbox.yMin = FT_PIX_ROUND( cbox.yMin );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
    cbox.xMax = FT_PIX_ROUND( cbox.xMax );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
    cbox.yMax = FT_PIX_ROUND( cbox.yMax );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
#else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   171
    cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
    cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
    cbox.xMax = FT_PIX_CEIL( cbox.xMax );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
    cbox.yMax = FT_PIX_CEIL( cbox.yMax );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
    width  = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    bitmap = &slot->bitmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
    memory = render->root.memory;
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
    /* release old bitmap buffer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
    if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
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
      FT_FREE( bitmap->buffer );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
      slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
    /* allocate new one, depends on pixel format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
    if ( !( mode & FT_RENDER_MODE_MONO ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   191
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   192
      /* we pad to 32 bits, only for backwards compatibility with FT 1.x */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
      pitch              = FT_PAD_CEIL( width, 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
      bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   195
      bitmap->num_grays  = 256;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   196
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
    else
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
      pitch              = ( ( width + 15 ) >> 4 ) << 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   200
      bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   201
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
    bitmap->width = width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
    bitmap->rows  = height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
    bitmap->pitch = pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   206
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   207
    if ( FT_ALLOC_MULT( bitmap->buffer, pitch, height ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   208
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   209
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
    slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
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
    /* translate outline to render it into the bitmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    FT_Outline_Translate( outline, -cbox.xMin, -cbox.yMin );
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
    /* set up parameters */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
    params.target = bitmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
    params.source = outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
    params.flags  = 0;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    if ( bitmap->pixel_mode == FT_PIXEL_MODE_GRAY )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
      params.flags |= FT_RASTER_FLAG_AA;
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
    /* render outline into the bitmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
    error = render->raster_render( render->raster, &params );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    FT_Outline_Translate( outline, cbox.xMin, cbox.yMin );
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
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
      goto Exit;
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
    slot->format      = FT_GLYPH_FORMAT_BITMAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
    slot->bitmap_left = (FT_Int)( cbox.xMin >> 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
    slot->bitmap_top  = (FT_Int)( cbox.yMax >> 6 );
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   236
    return error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
  FT_DEFINE_RENDERER(ft_raster1_renderer_class,
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
      FT_MODULE_RENDERER,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   243
      sizeof( FT_RendererRec ),
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
      "raster1",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
      0x10000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
      0x20000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   248
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   249
      0,    /* module specific interface */
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_Module_Constructor)ft_raster1_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
      (FT_Module_Destructor) 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
      (FT_Module_Requester)  0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
    ,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   256
    FT_GLYPH_FORMAT_OUTLINE,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   257
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
    (FT_Renderer_RenderFunc)   ft_raster1_render,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
    (FT_Renderer_TransformFunc)ft_raster1_transform,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
    (FT_Renderer_GetCBoxFunc)  ft_raster1_get_cbox,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
    (FT_Renderer_SetModeFunc)  ft_raster1_set_mode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
    (FT_Raster_Funcs*)    &FT_STANDARD_RASTER_GET
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
  )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   265
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   266
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   267
  /* This renderer is _NOT_ part of the default modules; you will need */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
  /* to register it by hand in your application.  It should only be    */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
  /* used for backwards-compatibility with FT 1.x anyway.              */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
  /*                                                                   */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
  FT_DEFINE_RENDERER(ft_raster5_renderer_class,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
  
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
      FT_MODULE_RENDERER,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   275
      sizeof( FT_RendererRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   276
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
      "raster5",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
      0x10000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
      0x20000L,
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
      0,    /* module specific interface */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
      (FT_Module_Constructor)ft_raster1_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
      (FT_Module_Destructor) 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
      (FT_Module_Requester)  0
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
    FT_GLYPH_FORMAT_OUTLINE,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   289
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   290
    (FT_Renderer_RenderFunc)   ft_raster1_render,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   291
    (FT_Renderer_TransformFunc)ft_raster1_transform,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
    (FT_Renderer_GetCBoxFunc)  ft_raster1_get_cbox,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   293
    (FT_Renderer_SetModeFunc)  ft_raster1_set_mode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   294
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
    (FT_Raster_Funcs*)    &FT_STANDARD_RASTER_GET
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
/* END */