Delete all Trailing spaces in code.
[reactos.git] / reactos / dll / 3rdparty / freetype / src / smooth / ftsmooth.c
index 85d04eb..688aa2e 100644 (file)
-/***************************************************************************/
-/*                                                                         */
-/*  ftsmooth.c                                                             */
-/*                                                                         */
-/*    Anti-aliasing renderer interface (body).                             */
-/*                                                                         */
-/*  Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by                   */
-/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
-/*                                                                         */
-/*  This file is part of the FreeType project, and may only be used,       */
-/*  modified, and distributed under the terms of the FreeType project      */
-/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
-/*  this file you indicate that you have read the license and              */
-/*  understand and accept it fully.                                        */
-/*                                                                         */
-/***************************************************************************/
-
-
-#include <ft2build.h>
-#include FT_INTERNAL_OBJECTS_H
-#include FT_OUTLINE_H
-#include "ftsmooth.h"
-#include "ftgrays.h"
-
-#include "ftsmerrs.h"
-
-
-  /* initialize renderer -- init its raster */
-  static FT_Error
-  ft_smooth_init( FT_Renderer  render )
-  {
-    FT_Library  library = FT_MODULE_LIBRARY( render );
-
-
-    render->clazz->raster_class->raster_reset( render->raster,
-                                               library->raster_pool,
-                                               library->raster_pool_size );
-
-    return 0;
-  }
-
-
-  /* sets render-specific mode */
-  static FT_Error
-  ft_smooth_set_mode( FT_Renderer  render,
-                      FT_ULong     mode_tag,
-                      FT_Pointer   data )
-  {
-    /* we simply pass it to the raster */
-    return render->clazz->raster_class->raster_set_mode( render->raster,
-                                                         mode_tag,
-                                                         data );
-  }
-
-  /* transform a given glyph image */
-  static FT_Error
-  ft_smooth_transform( FT_Renderer       render,
-                       FT_GlyphSlot      slot,
-                       const FT_Matrix*  matrix,
-                       const FT_Vector*  delta )
-  {
-    FT_Error  error = Smooth_Err_Ok;
-
-
-    if ( slot->format != render->glyph_format )
-    {
-      error = Smooth_Err_Invalid_Argument;
-      goto Exit;
-    }
-
-    if ( matrix )
-      FT_Outline_Transform( &slot->outline, matrix );
-
-    if ( delta )
-      FT_Outline_Translate( &slot->outline, delta->x, delta->y );
-
-  Exit:
-    return error;
-  }
-
-
-  /* return the glyph's control box */
-  static void
-  ft_smooth_get_cbox( FT_Renderer   render,
-                      FT_GlyphSlot  slot,
-                      FT_BBox*      cbox )
-  {
-    FT_MEM_ZERO( cbox, sizeof ( *cbox ) );
-
-    if ( slot->format == render->glyph_format )
-      FT_Outline_Get_CBox( &slot->outline, cbox );
-  }
-
-
-  /* convert a slot's glyph image into a bitmap */
-  static FT_Error
-  ft_smooth_render_generic( FT_Renderer       render,
-                            FT_GlyphSlot      slot,
-                            FT_Render_Mode    mode,
-                            const FT_Vector*  origin,
-                            FT_Render_Mode    required_mode )
-  {
-    FT_Error     error;
-    FT_Outline*  outline = NULL;
-    FT_BBox      cbox;
-    FT_UInt      width, height, height_org, width_org, pitch;
-    FT_Bitmap*   bitmap;
-    FT_Memory    memory;
-    FT_Int       hmul = mode == FT_RENDER_MODE_LCD;
-    FT_Int       vmul = mode == FT_RENDER_MODE_LCD_V;
-    FT_Pos       x_shift, y_shift, x_left, y_top;
-
-    FT_Raster_Params  params;
-
-
-    /* check glyph image format */
-    if ( slot->format != render->glyph_format )
-    {
-      error = Smooth_Err_Invalid_Argument;
-      goto Exit;
-    }
-
-    /* check mode */
-    if ( mode != required_mode )
-      return Smooth_Err_Cannot_Render_Glyph;
-
-    outline = &slot->outline;
-
-    /* translate the outline to the new origin if needed */
-    if ( origin )
-      FT_Outline_Translate( outline, origin->x, origin->y );
-
-    /* compute the control box, and grid fit it */
-    FT_Outline_Get_CBox( outline, &cbox );
-
-    cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
-    cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
-    cbox.xMax = FT_PIX_CEIL( cbox.xMax );
-    cbox.yMax = FT_PIX_CEIL( cbox.yMax );
-
-    width  = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
-    height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 );
-    bitmap = &slot->bitmap;
-    memory = render->root.memory;
-
-    width_org  = width;
-    height_org = height;
-
-    /* release old bitmap buffer */
-    if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
-    {
-      FT_FREE( bitmap->buffer );
-      slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
-    }
-
-    /* allocate new one, depends on pixel format */
-    pitch = width;
-    if ( hmul )
-    {
-      width = width * 3;
-      pitch = FT_PAD_CEIL( width, 4 );
-    }
-
-    if ( vmul )
-      height *= 3;
-
-    x_shift = (FT_Int) cbox.xMin;
-    y_shift = (FT_Int) cbox.yMin;
-    x_left  = (FT_Int)( cbox.xMin >> 6 );
-    y_top   = (FT_Int)( cbox.yMax >> 6 );
-
-#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
-
-    if ( slot->library->lcd_filter_func )
-    {
-      FT_Int  extra = slot->library->lcd_extra;
-
-
-      if ( hmul )
-      {
-        x_shift -= 64 * ( extra >> 1 );
-        width   += 3 * extra;
-        pitch    = FT_PAD_CEIL( width, 4 );
-        x_left  -= extra >> 1;
-      }
-
-      if ( vmul )
-      {
-        y_shift -= 64 * ( extra >> 1 );
-        height  += 3 * extra;
-        y_top   += extra >> 1;
-      }
-    }
-
-#endif
-
-    bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
-    bitmap->num_grays  = 256;
-    bitmap->width      = width;
-    bitmap->rows       = height;
-    bitmap->pitch      = pitch;
-
-    /* translate outline to render it into the bitmap */
-    FT_Outline_Translate( outline, -x_shift, -y_shift );
-
-    if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
-      goto Exit;
-
-    slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
-
-    /* set up parameters */
-    params.target = bitmap;
-    params.source = outline;
-    params.flags  = FT_RASTER_FLAG_AA;
-
-#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
-
-    /* implode outline if needed */
-    {
-      FT_Vector*  points     = outline->points;
-      FT_Vector*  points_end = points + outline->n_points;
-      FT_Vector*  vec;
-
-
-      if ( hmul )
-        for ( vec = points; vec < points_end; vec++ )
-          vec->x *= 3;
-
-      if ( vmul )
-        for ( vec = points; vec < points_end; vec++ )
-          vec->y *= 3;
-    }
-
-    /* render outline into the bitmap */
-    error = render->raster_render( render->raster, &params );
-
-    /* deflate outline if needed */
-    {
-      FT_Vector*  points     = outline->points;
-      FT_Vector*  points_end = points + outline->n_points;
-      FT_Vector*  vec;
-
-
-      if ( hmul )
-        for ( vec = points; vec < points_end; vec++ )
-          vec->x /= 3;
-
-      if ( vmul )
-        for ( vec = points; vec < points_end; vec++ )
-          vec->y /= 3;
-    }
-
-    if ( slot->library->lcd_filter_func )
-      slot->library->lcd_filter_func( bitmap, mode, slot->library );
-
-#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
-
-    /* render outline into bitmap */
-    error = render->raster_render( render->raster, &params );
-
-    /* expand it horizontally */
-    if ( hmul )
-    {
-      FT_Byte*  line = bitmap->buffer;
-      FT_UInt   hh;
-
-
-      for ( hh = height_org; hh > 0; hh--, line += pitch )
-      {
-        FT_UInt   xx;
-        FT_Byte*  end = line + width;
-
-
-        for ( xx = width_org; xx > 0; xx-- )
-        {
-          FT_UInt  pixel = line[xx-1];
-
-
-          end[-3] = (FT_Byte)pixel;
-          end[-2] = (FT_Byte)pixel;
-          end[-1] = (FT_Byte)pixel;
-          end    -= 3;
-        }
-      }
-    }
-
-    /* expand it vertically */
-    if ( vmul )
-    {
-      FT_Byte*  read  = bitmap->buffer + ( height - height_org ) * pitch;
-      FT_Byte*  write = bitmap->buffer;
-      FT_UInt   hh;
-
-
-      for ( hh = height_org; hh > 0; hh-- )
-      {
-        memcpy( write, read, pitch );
-        write += pitch;
-
-        memcpy( write, read, pitch );
-        write += pitch;
-
-        memcpy( write, read, pitch );
-        write += pitch;
-        read  += pitch;
-      }
-    }
-
-#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
-
-    FT_Outline_Translate( outline, x_shift, y_shift );
-
-    if ( error )
-      goto Exit;
-
-    slot->format      = FT_GLYPH_FORMAT_BITMAP;
-    slot->bitmap_left = x_left;
-    slot->bitmap_top  = y_top;
-
-  Exit:
-    if ( outline && origin )
-      FT_Outline_Translate( outline, -origin->x, -origin->y );
-
-    return error;
-  }
-
-
-  /* convert a slot's glyph image into a bitmap */
-  static FT_Error
-  ft_smooth_render( FT_Renderer       render,
-                    FT_GlyphSlot      slot,
-                    FT_Render_Mode    mode,
-                    const FT_Vector*  origin )
-  {
-    if ( mode == FT_RENDER_MODE_LIGHT )
-      mode = FT_RENDER_MODE_NORMAL;
-
-    return ft_smooth_render_generic( render, slot, mode, origin,
-                                     FT_RENDER_MODE_NORMAL );
-  }
-
-
-  /* convert a slot's glyph image into a horizontal LCD bitmap */
-  static FT_Error
-  ft_smooth_render_lcd( FT_Renderer       render,
-                        FT_GlyphSlot      slot,
-                        FT_Render_Mode    mode,
-                        const FT_Vector*  origin )
-  {
-    FT_Error  error;
-
-    error = ft_smooth_render_generic( render, slot, mode, origin,
-                                      FT_RENDER_MODE_LCD );
-    if ( !error )
-      slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD;
-
-    return error;
-  }
-
-
-  /* convert a slot's glyph image into a vertical LCD bitmap */
-  static FT_Error
-  ft_smooth_render_lcd_v( FT_Renderer       render,
-                          FT_GlyphSlot      slot,
-                          FT_Render_Mode    mode,
-                          const FT_Vector*  origin )
-  {
-    FT_Error  error;
-
-    error = ft_smooth_render_generic( render, slot, mode, origin,
-                                      FT_RENDER_MODE_LCD_V );
-    if ( !error )
-      slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD_V;
-
-    return error;
-  }
-
-
-  FT_CALLBACK_TABLE_DEF
-  const FT_Renderer_Class  ft_smooth_renderer_class =
-  {
-    {
-      FT_MODULE_RENDERER,
-      sizeof( FT_RendererRec ),
-
-      "smooth",
-      0x10000L,
-      0x20000L,
-
-      0,    /* module specific interface */
-
-      (FT_Module_Constructor)ft_smooth_init,
-      (FT_Module_Destructor) 0,
-      (FT_Module_Requester)  0
-    },
-
-    FT_GLYPH_FORMAT_OUTLINE,
-
-    (FT_Renderer_RenderFunc)   ft_smooth_render,
-    (FT_Renderer_TransformFunc)ft_smooth_transform,
-    (FT_Renderer_GetCBoxFunc)  ft_smooth_get_cbox,
-    (FT_Renderer_SetModeFunc)  ft_smooth_set_mode,
-
-    (FT_Raster_Funcs*)    &ft_grays_raster
-  };
-
-
-  FT_CALLBACK_TABLE_DEF
-  const FT_Renderer_Class  ft_smooth_lcd_renderer_class =
-  {
-    {
-      FT_MODULE_RENDERER,
-      sizeof( FT_RendererRec ),
-
-      "smooth-lcd",
-      0x10000L,
-      0x20000L,
-
-      0,    /* module specific interface */
-
-      (FT_Module_Constructor)ft_smooth_init,
-      (FT_Module_Destructor) 0,
-      (FT_Module_Requester)  0
-    },
-
-    FT_GLYPH_FORMAT_OUTLINE,
-
-    (FT_Renderer_RenderFunc)   ft_smooth_render_lcd,
-    (FT_Renderer_TransformFunc)ft_smooth_transform,
-    (FT_Renderer_GetCBoxFunc)  ft_smooth_get_cbox,
-    (FT_Renderer_SetModeFunc)  ft_smooth_set_mode,
-
-    (FT_Raster_Funcs*)    &ft_grays_raster
-  };
-
-
-
-  FT_CALLBACK_TABLE_DEF
-  const FT_Renderer_Class  ft_smooth_lcdv_renderer_class =
-  {
-    {
-      FT_MODULE_RENDERER,
-      sizeof( FT_RendererRec ),
-
-      "smooth-lcdv",
-      0x10000L,
-      0x20000L,
-
-      0,    /* module specific interface */
-
-      (FT_Module_Constructor)ft_smooth_init,
-      (FT_Module_Destructor) 0,
-      (FT_Module_Requester)  0
-    },
-
-    FT_GLYPH_FORMAT_OUTLINE,
-
-    (FT_Renderer_RenderFunc)   ft_smooth_render_lcd_v,
-    (FT_Renderer_TransformFunc)ft_smooth_transform,
-    (FT_Renderer_GetCBoxFunc)  ft_smooth_get_cbox,
-    (FT_Renderer_SetModeFunc)  ft_smooth_set_mode,
-
-    (FT_Raster_Funcs*)    &ft_grays_raster
-  };
-
-
-/* END */
+/***************************************************************************/\r
+/*                                                                         */\r
+/*  ftsmooth.c                                                             */\r
+/*                                                                         */\r
+/*    Anti-aliasing renderer interface (body).                             */\r
+/*                                                                         */\r
+/*  Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006 by                   */\r
+/*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */\r
+/*                                                                         */\r
+/*  This file is part of the FreeType project, and may only be used,       */\r
+/*  modified, and distributed under the terms of the FreeType project      */\r
+/*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */\r
+/*  this file you indicate that you have read the license and              */\r
+/*  understand and accept it fully.                                        */\r
+/*                                                                         */\r
+/***************************************************************************/\r
+\r
+\r
+#include <ft2build.h>\r
+#include FT_INTERNAL_OBJECTS_H\r
+#include FT_OUTLINE_H\r
+#include "ftsmooth.h"\r
+#include "ftgrays.h"\r
+\r
+#include "ftsmerrs.h"\r
+\r
+\r
+  /* initialize renderer -- init its raster */\r
+  static FT_Error\r
+  ft_smooth_init( FT_Renderer  render )\r
+  {\r
+    FT_Library  library = FT_MODULE_LIBRARY( render );\r
+\r
+\r
+    render->clazz->raster_class->raster_reset( render->raster,\r
+                                               library->raster_pool,\r
+                                               library->raster_pool_size );\r
+\r
+    return 0;\r
+  }\r
+\r
+\r
+  /* sets render-specific mode */\r
+  static FT_Error\r
+  ft_smooth_set_mode( FT_Renderer  render,\r
+                      FT_ULong     mode_tag,\r
+                      FT_Pointer   data )\r
+  {\r
+    /* we simply pass it to the raster */\r
+    return render->clazz->raster_class->raster_set_mode( render->raster,\r
+                                                         mode_tag,\r
+                                                         data );\r
+  }\r
+\r
+  /* transform a given glyph image */\r
+  static FT_Error\r
+  ft_smooth_transform( FT_Renderer       render,\r
+                       FT_GlyphSlot      slot,\r
+                       const FT_Matrix*  matrix,\r
+                       const FT_Vector*  delta )\r
+  {\r
+    FT_Error  error = Smooth_Err_Ok;\r
+\r
+\r
+    if ( slot->format != render->glyph_format )\r
+    {\r
+      error = Smooth_Err_Invalid_Argument;\r
+      goto Exit;\r
+    }\r
+\r
+    if ( matrix )\r
+      FT_Outline_Transform( &slot->outline, matrix );\r
+\r
+    if ( delta )\r
+      FT_Outline_Translate( &slot->outline, delta->x, delta->y );\r
+\r
+  Exit:\r
+    return error;\r
+  }\r
+\r
+\r
+  /* return the glyph's control box */\r
+  static void\r
+  ft_smooth_get_cbox( FT_Renderer   render,\r
+                      FT_GlyphSlot  slot,\r
+                      FT_BBox*      cbox )\r
+  {\r
+    FT_MEM_ZERO( cbox, sizeof ( *cbox ) );\r
+\r
+    if ( slot->format == render->glyph_format )\r
+      FT_Outline_Get_CBox( &slot->outline, cbox );\r
+  }\r
+\r
+\r
+  /* convert a slot's glyph image into a bitmap */\r
+  static FT_Error\r
+  ft_smooth_render_generic( FT_Renderer       render,\r
+                            FT_GlyphSlot      slot,\r
+                            FT_Render_Mode    mode,\r
+                            const FT_Vector*  origin,\r
+                            FT_Render_Mode    required_mode )\r
+  {\r
+    FT_Error     error;\r
+    FT_Outline*  outline = NULL;\r
+    FT_BBox      cbox;\r
+    FT_UInt      width, height, height_org, width_org, pitch;\r
+    FT_Bitmap*   bitmap;\r
+    FT_Memory    memory;\r
+    FT_Int       hmul = mode == FT_RENDER_MODE_LCD;\r
+    FT_Int       vmul = mode == FT_RENDER_MODE_LCD_V;\r
+    FT_Pos       x_shift, y_shift, x_left, y_top;\r
+\r
+    FT_Raster_Params  params;\r
+\r
+\r
+    /* check glyph image format */\r
+    if ( slot->format != render->glyph_format )\r
+    {\r
+      error = Smooth_Err_Invalid_Argument;\r
+      goto Exit;\r
+    }\r
+\r
+    /* check mode */\r
+    if ( mode != required_mode )\r
+      return Smooth_Err_Cannot_Render_Glyph;\r
+\r
+    outline = &slot->outline;\r
+\r
+    /* translate the outline to the new origin if needed */\r
+    if ( origin )\r
+      FT_Outline_Translate( outline, origin->x, origin->y );\r
+\r
+    /* compute the control box, and grid fit it */\r
+    FT_Outline_Get_CBox( outline, &cbox );\r
+\r
+    cbox.xMin = FT_PIX_FLOOR( cbox.xMin );\r
+    cbox.yMin = FT_PIX_FLOOR( cbox.yMin );\r
+    cbox.xMax = FT_PIX_CEIL( cbox.xMax );\r
+    cbox.yMax = FT_PIX_CEIL( cbox.yMax );\r
+\r
+    width  = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );\r
+    height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 );\r
+    bitmap = &slot->bitmap;\r
+    memory = render->root.memory;\r
+\r
+    width_org  = width;\r
+    height_org = height;\r
+\r
+    /* release old bitmap buffer */\r
+    if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )\r
+    {\r
+      FT_FREE( bitmap->buffer );\r
+      slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;\r
+    }\r
+\r
+    /* allocate new one, depends on pixel format */\r
+    pitch = width;\r
+    if ( hmul )\r
+    {\r
+      width = width * 3;\r
+      pitch = FT_PAD_CEIL( width, 4 );\r
+    }\r
+\r
+    if ( vmul )\r
+      height *= 3;\r
+\r
+    x_shift = (FT_Int) cbox.xMin;\r
+    y_shift = (FT_Int) cbox.yMin;\r
+    x_left  = (FT_Int)( cbox.xMin >> 6 );\r
+    y_top   = (FT_Int)( cbox.yMax >> 6 );\r
+\r
+#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING\r
+\r
+    if ( slot->library->lcd_filter_func )\r
+    {\r
+      FT_Int  extra = slot->library->lcd_extra;\r
+\r
+\r
+      if ( hmul )\r
+      {\r
+        x_shift -= 64 * ( extra >> 1 );\r
+        width   += 3 * extra;\r
+        pitch    = FT_PAD_CEIL( width, 4 );\r
+        x_left  -= extra >> 1;\r
+      }\r
+\r
+      if ( vmul )\r
+      {\r
+        y_shift -= 64 * ( extra >> 1 );\r
+        height  += 3 * extra;\r
+        y_top   += extra >> 1;\r
+      }\r
+    }\r
+\r
+#endif\r
+\r
+    bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;\r
+    bitmap->num_grays  = 256;\r
+    bitmap->width      = width;\r
+    bitmap->rows       = height;\r
+    bitmap->pitch      = pitch;\r
+\r
+    /* translate outline to render it into the bitmap */\r
+    FT_Outline_Translate( outline, -x_shift, -y_shift );\r
+\r
+    if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )\r
+      goto Exit;\r
+\r
+    slot->internal->flags |= FT_GLYPH_OWN_BITMAP;\r
+\r
+    /* set up parameters */\r
+    params.target = bitmap;\r
+    params.source = outline;\r
+    params.flags  = FT_RASTER_FLAG_AA;\r
+\r
+#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING\r
+\r
+    /* implode outline if needed */\r
+    {\r
+      FT_Vector*  points     = outline->points;\r
+      FT_Vector*  points_end = points + outline->n_points;\r
+      FT_Vector*  vec;\r
+\r
+\r
+      if ( hmul )\r
+        for ( vec = points; vec < points_end; vec++ )\r
+          vec->x *= 3;\r
+\r
+      if ( vmul )\r
+        for ( vec = points; vec < points_end; vec++ )\r
+          vec->y *= 3;\r
+    }\r
+\r
+    /* render outline into the bitmap */\r
+    error = render->raster_render( render->raster, &params );\r
+\r
+    /* deflate outline if needed */\r
+    {\r
+      FT_Vector*  points     = outline->points;\r
+      FT_Vector*  points_end = points + outline->n_points;\r
+      FT_Vector*  vec;\r
+\r
+\r
+      if ( hmul )\r
+        for ( vec = points; vec < points_end; vec++ )\r
+          vec->x /= 3;\r
+\r
+      if ( vmul )\r
+        for ( vec = points; vec < points_end; vec++ )\r
+          vec->y /= 3;\r
+    }\r
+\r
+    if ( slot->library->lcd_filter_func )\r
+      slot->library->lcd_filter_func( bitmap, mode, slot->library );\r
+\r
+#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */\r
+\r
+    /* render outline into bitmap */\r
+    error = render->raster_render( render->raster, &params );\r
+\r
+    /* expand it horizontally */\r
+    if ( hmul )\r
+    {\r
+      FT_Byte*  line = bitmap->buffer;\r
+      FT_UInt   hh;\r
+\r
+\r
+      for ( hh = height_org; hh > 0; hh--, line += pitch )\r
+      {\r
+        FT_UInt   xx;\r
+        FT_Byte*  end = line + width;\r
+\r
+\r
+        for ( xx = width_org; xx > 0; xx-- )\r
+        {\r
+          FT_UInt  pixel = line[xx-1];\r
+\r
+\r
+          end[-3] = (FT_Byte)pixel;\r
+          end[-2] = (FT_Byte)pixel;\r
+          end[-1] = (FT_Byte)pixel;\r
+          end    -= 3;\r
+        }\r
+      }\r
+    }\r
+\r
+    /* expand it vertically */\r
+    if ( vmul )\r
+    {\r
+      FT_Byte*  read  = bitmap->buffer + ( height - height_org ) * pitch;\r
+      FT_Byte*  write = bitmap->buffer;\r
+      FT_UInt   hh;\r
+\r
+\r
+      for ( hh = height_org; hh > 0; hh-- )\r
+      {\r
+        memcpy( write, read, pitch );\r
+        write += pitch;\r
+\r
+        memcpy( write, read, pitch );\r
+        write += pitch;\r
+\r
+        memcpy( write, read, pitch );\r
+        write += pitch;\r
+        read  += pitch;\r
+      }\r
+    }\r
+\r
+#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */\r
+\r
+    FT_Outline_Translate( outline, x_shift, y_shift );\r
+\r
+    if ( error )\r
+      goto Exit;\r
+\r
+    slot->format      = FT_GLYPH_FORMAT_BITMAP;\r
+    slot->bitmap_left = x_left;\r
+    slot->bitmap_top  = y_top;\r
+\r
+  Exit:\r
+    if ( outline && origin )\r
+      FT_Outline_Translate( outline, -origin->x, -origin->y );\r
+\r
+    return error;\r
+  }\r
+\r
+\r
+  /* convert a slot's glyph image into a bitmap */\r
+  static FT_Error\r
+  ft_smooth_render( FT_Renderer       render,\r
+                    FT_GlyphSlot      slot,\r
+                    FT_Render_Mode    mode,\r
+                    const FT_Vector*  origin )\r
+  {\r
+    if ( mode == FT_RENDER_MODE_LIGHT )\r
+      mode = FT_RENDER_MODE_NORMAL;\r
+\r
+    return ft_smooth_render_generic( render, slot, mode, origin,\r
+                                     FT_RENDER_MODE_NORMAL );\r
+  }\r
+\r
+\r
+  /* convert a slot's glyph image into a horizontal LCD bitmap */\r
+  static FT_Error\r
+  ft_smooth_render_lcd( FT_Renderer       render,\r
+                        FT_GlyphSlot      slot,\r
+                        FT_Render_Mode    mode,\r
+                        const FT_Vector*  origin )\r
+  {\r
+    FT_Error  error;\r
+\r
+    error = ft_smooth_render_generic( render, slot, mode, origin,\r
+                                      FT_RENDER_MODE_LCD );\r
+    if ( !error )\r
+      slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD;\r
+\r
+    return error;\r
+  }\r
+\r
+\r
+  /* convert a slot's glyph image into a vertical LCD bitmap */\r
+  static FT_Error\r
+  ft_smooth_render_lcd_v( FT_Renderer       render,\r
+                          FT_GlyphSlot      slot,\r
+                          FT_Render_Mode    mode,\r
+                          const FT_Vector*  origin )\r
+  {\r
+    FT_Error  error;\r
+\r
+    error = ft_smooth_render_generic( render, slot, mode, origin,\r
+                                      FT_RENDER_MODE_LCD_V );\r
+    if ( !error )\r
+      slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD_V;\r
+\r
+    return error;\r
+  }\r
+\r
+\r
+  FT_CALLBACK_TABLE_DEF\r
+  const FT_Renderer_Class  ft_smooth_renderer_class =\r
+  {\r
+    {\r
+      FT_MODULE_RENDERER,\r
+      sizeof( FT_RendererRec ),\r
+\r
+      "smooth",\r
+      0x10000L,\r
+      0x20000L,\r
+\r
+      0,    /* module specific interface */\r
+\r
+      (FT_Module_Constructor)ft_smooth_init,\r
+      (FT_Module_Destructor) 0,\r
+      (FT_Module_Requester)  0\r
+    },\r
+\r
+    FT_GLYPH_FORMAT_OUTLINE,\r
+\r
+    (FT_Renderer_RenderFunc)   ft_smooth_render,\r
+    (FT_Renderer_TransformFunc)ft_smooth_transform,\r
+    (FT_Renderer_GetCBoxFunc)  ft_smooth_get_cbox,\r
+    (FT_Renderer_SetModeFunc)  ft_smooth_set_mode,\r
+\r
+    (FT_Raster_Funcs*)    &ft_grays_raster\r
+  };\r
+\r
+\r
+  FT_CALLBACK_TABLE_DEF\r
+  const FT_Renderer_Class  ft_smooth_lcd_renderer_class =\r
+  {\r
+    {\r
+      FT_MODULE_RENDERER,\r
+      sizeof( FT_RendererRec ),\r
+\r
+      "smooth-lcd",\r
+      0x10000L,\r
+      0x20000L,\r
+\r
+      0,    /* module specific interface */\r
+\r
+      (FT_Module_Constructor)ft_smooth_init,\r
+      (FT_Module_Destructor) 0,\r
+      (FT_Module_Requester)  0\r
+    },\r
+\r
+    FT_GLYPH_FORMAT_OUTLINE,\r
+\r
+    (FT_Renderer_RenderFunc)   ft_smooth_render_lcd,\r
+    (FT_Renderer_TransformFunc)ft_smooth_transform,\r
+    (FT_Renderer_GetCBoxFunc)  ft_smooth_get_cbox,\r
+    (FT_Renderer_SetModeFunc)  ft_smooth_set_mode,\r
+\r
+    (FT_Raster_Funcs*)    &ft_grays_raster\r
+  };\r
+\r
+\r
+\r
+  FT_CALLBACK_TABLE_DEF\r
+  const FT_Renderer_Class  ft_smooth_lcdv_renderer_class =\r
+  {\r
+    {\r
+      FT_MODULE_RENDERER,\r
+      sizeof( FT_RendererRec ),\r
+\r
+      "smooth-lcdv",\r
+      0x10000L,\r
+      0x20000L,\r
+\r
+      0,    /* module specific interface */\r
+\r
+      (FT_Module_Constructor)ft_smooth_init,\r
+      (FT_Module_Destructor) 0,\r
+      (FT_Module_Requester)  0\r
+    },\r
+\r
+    FT_GLYPH_FORMAT_OUTLINE,\r
+\r
+    (FT_Renderer_RenderFunc)   ft_smooth_render_lcd_v,\r
+    (FT_Renderer_TransformFunc)ft_smooth_transform,\r
+    (FT_Renderer_GetCBoxFunc)  ft_smooth_get_cbox,\r
+    (FT_Renderer_SetModeFunc)  ft_smooth_set_mode,\r
+\r
+    (FT_Raster_Funcs*)    &ft_grays_raster\r
+  };\r
+\r
+\r
+/* END */\r