misc/libfreetype/src/smooth/ftsmooth.c
author mikade
Fri, 09 Sep 2011 03:21:16 +0200
changeset 5821 afb988c1a2fe
parent 5172 88f2e05288ba
permissions -rw-r--r--
Allow limited form of SuddenDeath (WaterRise = 0) in both CTF modes Fix missing case of support for more players in CTF_Blizzard
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
/*  ftsmooth.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
/*    Anti-aliasing renderer 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 2000-2001, 2002, 2003, 2004, 2005, 2006, 2009, 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 <ft2build.h>
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    20
#include FT_INTERNAL_DEBUG_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    21
#include FT_INTERNAL_OBJECTS_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    22
#include FT_OUTLINE_H
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    23
#include "ftsmooth.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    24
#include "ftgrays.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    25
#include "ftspic.h"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    26
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    27
#include "ftsmerrs.h"
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
  /* initialize renderer -- init its raster */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    31
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    32
  ft_smooth_init( FT_Renderer  render )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    33
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    34
    FT_Library  library = FT_MODULE_LIBRARY( render );
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
    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
    38
                                               library->raster_pool,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    39
                                               library->raster_pool_size );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    40
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    41
    return 0;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    45
  /* sets render-specific mode */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    46
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    47
  ft_smooth_set_mode( FT_Renderer  render,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    48
                      FT_ULong     mode_tag,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    49
                      FT_Pointer   data )
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
    /* we simply pass it to the raster */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    52
    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
    53
                                                         mode_tag,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
    54
                                                         data );
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_smooth_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 = Smooth_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 = Smooth_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_smooth_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_smooth_render_generic( 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
                            FT_Render_Mode    required_mode )
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
    FT_Error     error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   106
    FT_Outline*  outline = NULL;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   107
    FT_BBox      cbox;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   108
    FT_UInt      width, height, height_org, width_org, pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   109
    FT_Bitmap*   bitmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   110
    FT_Memory    memory;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   111
    FT_Int       hmul = mode == FT_RENDER_MODE_LCD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   112
    FT_Int       vmul = mode == FT_RENDER_MODE_LCD_V;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   113
    FT_Pos       x_shift, y_shift, x_left, y_top;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   114
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   115
    FT_Raster_Params  params;
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
    /* check glyph image format */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   119
    if ( slot->format != render->glyph_format )
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
      error = Smooth_Err_Invalid_Argument;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   122
      goto Exit;
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
    /* check mode */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   126
    if ( mode != required_mode )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   127
      return Smooth_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
    outline = &slot->outline;
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
    /* 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
   132
    if ( origin )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   133
      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
   134
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   135
    /* 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
   136
    FT_Outline_Get_CBox( outline, &cbox );
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
    cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   139
    cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   140
    cbox.xMax = FT_PIX_CEIL( cbox.xMax );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   141
    cbox.yMax = FT_PIX_CEIL( cbox.yMax );
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
    if ( cbox.xMin < 0 && cbox.xMax > FT_INT_MAX + cbox.xMin )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   144
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   145
      FT_ERROR(( "ft_smooth_render_generic: glyph too large:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   146
                 " xMin = %d, xMax = %d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   147
                 cbox.xMin >> 6, cbox.xMax >> 6 ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   148
      return Smooth_Err_Raster_Overflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   149
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   150
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   151
      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
   152
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   153
    if ( cbox.yMin < 0 && cbox.yMax > FT_INT_MAX + cbox.yMin )
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
      FT_ERROR(( "ft_smooth_render_generic: glyph too large:"
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   156
                 " yMin = %d, yMax = %d\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   157
                 cbox.yMin >> 6, cbox.yMax >> 6 ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   158
      return Smooth_Err_Raster_Overflow;
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
    else
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   161
      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
   162
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   163
    bitmap = &slot->bitmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   164
    memory = render->root.memory;
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
    width_org  = width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   167
    height_org = height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   168
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   169
    /* release old bitmap buffer */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   170
    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
   171
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   172
      FT_FREE( bitmap->buffer );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   173
      slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   174
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   175
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   176
    /* allocate new one */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   177
    pitch = width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   178
    if ( hmul )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   179
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   180
      width = width * 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   181
      pitch = FT_PAD_CEIL( width, 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   182
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   183
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   184
    if ( vmul )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   185
      height *= 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   186
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   187
    x_shift = (FT_Int) cbox.xMin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   188
    y_shift = (FT_Int) cbox.yMin;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   189
    x_left  = (FT_Int)( cbox.xMin >> 6 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   190
    y_top   = (FT_Int)( cbox.yMax >> 6 );
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
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   193
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   194
    if ( slot->library->lcd_filter_func )
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
      FT_Int  extra = slot->library->lcd_extra;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   197
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
      if ( hmul )
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
        x_shift -= 64 * ( extra >> 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   202
        width   += 3 * extra;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   203
        pitch    = FT_PAD_CEIL( width, 4 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   204
        x_left  -= extra >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   205
      }
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 ( vmul )
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
        y_shift -= 64 * ( extra >> 1 );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   210
        height  += 3 * extra;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   211
        y_top   += extra >> 1;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   212
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   213
    }
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
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   216
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   217
#if FT_UINT_MAX > 0xFFFFU
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   218
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   219
    /* Required check is ( pitch * height < FT_ULONG_MAX ),     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   220
    /* but we care realistic cases only. Always pitch <= width. */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   221
    if ( width > 0x7FFFU || height > 0x7FFFU )
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
      FT_ERROR(( "ft_smooth_render_generic: glyph too large: %u x %u\n",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   224
                 width, height ));
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   225
      return Smooth_Err_Raster_Overflow;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   226
    }
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
#endif
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   229
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   230
    bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   231
    bitmap->num_grays  = 256;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   232
    bitmap->width      = width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   233
    bitmap->rows       = height;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   234
    bitmap->pitch      = pitch;
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
    /* 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
   237
    FT_Outline_Translate( outline, -x_shift, -y_shift );
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
    if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   240
      goto Exit;
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
    slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
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
    /* set up parameters */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   245
    params.target = bitmap;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   246
    params.source = outline;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   247
    params.flags  = FT_RASTER_FLAG_AA;
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
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
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
    /* implode outline if needed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   252
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   253
      FT_Vector*  points     = outline->points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   254
      FT_Vector*  points_end = points + outline->n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   255
      FT_Vector*  vec;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   258
      if ( hmul )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   259
        for ( vec = points; vec < points_end; vec++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   260
          vec->x *= 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   261
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   262
      if ( vmul )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   263
        for ( vec = points; vec < points_end; vec++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   264
          vec->y *= 3;
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
    /* render outline into the bitmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   268
    error = render->raster_render( render->raster, &params );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   269
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   270
    /* deflate outline if needed */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   271
    {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   272
      FT_Vector*  points     = outline->points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   273
      FT_Vector*  points_end = points + outline->n_points;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   274
      FT_Vector*  vec;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   277
      if ( hmul )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   278
        for ( vec = points; vec < points_end; vec++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   279
          vec->x /= 3;
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
      if ( vmul )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   282
        for ( vec = points; vec < points_end; vec++ )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   283
          vec->y /= 3;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   284
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   285
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   286
    if ( slot->library->lcd_filter_func )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   287
      slot->library->lcd_filter_func( bitmap, mode, slot->library );
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
#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
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
    /* render outline into bitmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   292
    error = render->raster_render( render->raster, &params );
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
    /* expand it horizontally */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   295
    if ( hmul )
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
      FT_Byte*  line = bitmap->buffer;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   298
      FT_UInt   hh;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   299
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   300
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   301
      for ( hh = height_org; hh > 0; hh--, line += pitch )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   302
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   303
        FT_UInt   xx;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   304
        FT_Byte*  end = line + width;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   305
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
        for ( xx = width_org; xx > 0; xx-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   308
        {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   309
          FT_UInt  pixel = line[xx-1];
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   310
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
          end[-3] = (FT_Byte)pixel;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   313
          end[-2] = (FT_Byte)pixel;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   314
          end[-1] = (FT_Byte)pixel;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   315
          end    -= 3;
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
    }
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
    /* expand it vertically */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   321
    if ( vmul )
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
      FT_Byte*  read  = bitmap->buffer + ( height - height_org ) * pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   324
      FT_Byte*  write = bitmap->buffer;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   325
      FT_UInt   hh;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   326
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
      for ( hh = height_org; hh > 0; hh-- )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   329
      {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   330
        ft_memcpy( write, read, pitch );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   331
        write += pitch;
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
        ft_memcpy( write, read, pitch );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   334
        write += pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   335
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   336
        ft_memcpy( write, read, pitch );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   337
        write += pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   338
        read  += pitch;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   339
      }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   340
    }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   341
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   342
#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
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
    FT_Outline_Translate( outline, x_shift, y_shift );
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
    /*
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   347
     * XXX: on 16bit system, we return an error for huge bitmap
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   348
     * to prevent an overflow.
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   349
     */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   350
    if ( x_left > FT_INT_MAX || y_top > FT_INT_MAX )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   351
      return Smooth_Err_Invalid_Pixel_Size;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   352
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   353
    if ( error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   354
      goto Exit;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   355
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   356
    slot->format      = FT_GLYPH_FORMAT_BITMAP;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   357
    slot->bitmap_left = (FT_Int)x_left;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   358
    slot->bitmap_top  = (FT_Int)y_top;
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
  Exit:
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   361
    if ( outline && origin )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   362
      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
   363
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   364
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   365
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   368
  /* 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
   369
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   370
  ft_smooth_render( FT_Renderer       render,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   371
                    FT_GlyphSlot      slot,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   372
                    FT_Render_Mode    mode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   373
                    const FT_Vector*  origin )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   374
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   375
    if ( mode == FT_RENDER_MODE_LIGHT )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   376
      mode = FT_RENDER_MODE_NORMAL;
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
    return ft_smooth_render_generic( render, slot, mode, origin,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   379
                                     FT_RENDER_MODE_NORMAL );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   380
  }
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   383
  /* convert a slot's glyph image into a horizontal LCD bitmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   384
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   385
  ft_smooth_render_lcd( FT_Renderer       render,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   386
                        FT_GlyphSlot      slot,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   387
                        FT_Render_Mode    mode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   388
                        const FT_Vector*  origin )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   389
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   390
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   391
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   392
    error = ft_smooth_render_generic( render, slot, mode, origin,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   393
                                      FT_RENDER_MODE_LCD );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   394
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   395
      slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   396
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   397
    return error;
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   400
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   401
  /* convert a slot's glyph image into a vertical LCD bitmap */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   402
  static FT_Error
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   403
  ft_smooth_render_lcd_v( FT_Renderer       render,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   404
                          FT_GlyphSlot      slot,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   405
                          FT_Render_Mode    mode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   406
                          const FT_Vector*  origin )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   407
  {
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   408
    FT_Error  error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   409
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   410
    error = ft_smooth_render_generic( render, slot, mode, origin,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   411
                                      FT_RENDER_MODE_LCD_V );
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   412
    if ( !error )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   413
      slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD_V;
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
    return error;
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   416
  }
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   417
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   418
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   419
  FT_DEFINE_RENDERER(ft_smooth_renderer_class,
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
      FT_MODULE_RENDERER,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   422
      sizeof( FT_RendererRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   423
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   424
      "smooth",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   425
      0x10000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   426
      0x20000L,
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
      0,    /* module specific interface */
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
      (FT_Module_Constructor)ft_smooth_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   431
      (FT_Module_Destructor) 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   432
      (FT_Module_Requester)  0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   433
    ,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   434
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   435
    FT_GLYPH_FORMAT_OUTLINE,
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
    (FT_Renderer_RenderFunc)   ft_smooth_render,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   438
    (FT_Renderer_TransformFunc)ft_smooth_transform,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   439
    (FT_Renderer_GetCBoxFunc)  ft_smooth_get_cbox,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   440
    (FT_Renderer_SetModeFunc)  ft_smooth_set_mode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   441
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   442
    (FT_Raster_Funcs*)    &FT_GRAYS_RASTER_GET
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   443
  )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   444
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   445
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   446
  FT_DEFINE_RENDERER(ft_smooth_lcd_renderer_class,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   447
  
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   448
      FT_MODULE_RENDERER,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   449
      sizeof( FT_RendererRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   450
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   451
      "smooth-lcd",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   452
      0x10000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   453
      0x20000L,
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
      0,    /* module specific interface */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   456
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   457
      (FT_Module_Constructor)ft_smooth_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   458
      (FT_Module_Destructor) 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   459
      (FT_Module_Requester)  0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   460
    ,
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
    FT_GLYPH_FORMAT_OUTLINE,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   463
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   464
    (FT_Renderer_RenderFunc)   ft_smooth_render_lcd,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   465
    (FT_Renderer_TransformFunc)ft_smooth_transform,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   466
    (FT_Renderer_GetCBoxFunc)  ft_smooth_get_cbox,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   467
    (FT_Renderer_SetModeFunc)  ft_smooth_set_mode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   468
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   469
    (FT_Raster_Funcs*)    &FT_GRAYS_RASTER_GET
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   470
  )
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   471
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   472
  FT_DEFINE_RENDERER(ft_smooth_lcdv_renderer_class,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   473
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   474
      FT_MODULE_RENDERER,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   475
      sizeof( FT_RendererRec ),
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   476
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   477
      "smooth-lcdv",
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   478
      0x10000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   479
      0x20000L,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   480
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   481
      0,    /* module specific interface */
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   482
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   483
      (FT_Module_Constructor)ft_smooth_init,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   484
      (FT_Module_Destructor) 0,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   485
      (FT_Module_Requester)  0
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   486
    ,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   487
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   488
    FT_GLYPH_FORMAT_OUTLINE,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   489
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   490
    (FT_Renderer_RenderFunc)   ft_smooth_render_lcd_v,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   491
    (FT_Renderer_TransformFunc)ft_smooth_transform,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   492
    (FT_Renderer_GetCBoxFunc)  ft_smooth_get_cbox,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   493
    (FT_Renderer_SetModeFunc)  ft_smooth_set_mode,
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   494
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   495
    (FT_Raster_Funcs*)    &FT_GRAYS_RASTER_GET
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
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   498
88f2e05288ba aaand let's add freetype as well while we are at it
koda
parents:
diff changeset
   499
/* END */