2018-06-03 09:01:17 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* ftlcdfil.c
|
|
|
|
*
|
|
|
|
* FreeType API for color filtering of subpixel bitmap glyphs (body).
|
|
|
|
*
|
2021-01-17 07:18:48 +01:00
|
|
|
* Copyright (C) 2006-2021 by
|
2018-06-03 09:01:17 +02:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
2006-09-29 23:31:53 +02:00
|
|
|
|
|
|
|
|
2020-06-08 13:31:55 +02:00
|
|
|
#include <freetype/internal/ftdebug.h>
|
2013-03-14 10:27:35 +01:00
|
|
|
|
2020-06-08 13:31:55 +02:00
|
|
|
#include <freetype/ftlcdfil.h>
|
|
|
|
#include <freetype/ftimage.h>
|
|
|
|
#include <freetype/internal/ftobjs.h>
|
2006-09-27 10:48:38 +02:00
|
|
|
|
2006-09-29 23:31:53 +02:00
|
|
|
|
2006-09-27 10:48:38 +02:00
|
|
|
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
|
|
|
|
|
2006-11-13 14:03:48 +01:00
|
|
|
/* define USE_LEGACY to implement the legacy filter */
|
2006-11-10 17:49:42 +01:00
|
|
|
#define USE_LEGACY
|
|
|
|
|
2017-07-04 04:49:07 +02:00
|
|
|
#define FT_SHIFTCLAMP( x ) ( x >>= 8, (FT_Byte)( x > 255 ? 255 : x ) )
|
|
|
|
|
2017-09-28 06:20:50 +02:00
|
|
|
|
|
|
|
/* add padding according to filter weights */
|
|
|
|
FT_BASE_DEF (void)
|
2018-05-25 04:38:24 +02:00
|
|
|
ft_lcd_padding( FT_BBox* cbox,
|
|
|
|
FT_GlyphSlot slot,
|
|
|
|
FT_Render_Mode mode )
|
2017-09-28 06:20:50 +02:00
|
|
|
{
|
|
|
|
FT_Byte* lcd_weights;
|
|
|
|
FT_Bitmap_LcdFilterFunc lcd_filter_func;
|
|
|
|
|
|
|
|
|
|
|
|
/* Per-face LCD filtering takes priority if set up. */
|
|
|
|
if ( slot->face && slot->face->internal->lcd_filter_func )
|
|
|
|
{
|
|
|
|
lcd_weights = slot->face->internal->lcd_weights;
|
|
|
|
lcd_filter_func = slot->face->internal->lcd_filter_func;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lcd_weights = slot->library->lcd_weights;
|
|
|
|
lcd_filter_func = slot->library->lcd_filter_func;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( lcd_filter_func == ft_lcd_filter_fir )
|
|
|
|
{
|
2018-05-25 04:38:24 +02:00
|
|
|
if ( mode == FT_RENDER_MODE_LCD )
|
|
|
|
{
|
|
|
|
cbox->xMin -= lcd_weights[0] ? 43 :
|
|
|
|
lcd_weights[1] ? 22 : 0;
|
|
|
|
cbox->xMax += lcd_weights[4] ? 43 :
|
|
|
|
lcd_weights[3] ? 22 : 0;
|
|
|
|
}
|
|
|
|
else if ( mode == FT_RENDER_MODE_LCD_V )
|
|
|
|
{
|
|
|
|
cbox->yMin -= lcd_weights[0] ? 43 :
|
|
|
|
lcd_weights[1] ? 22 : 0;
|
|
|
|
cbox->yMax += lcd_weights[4] ? 43 :
|
|
|
|
lcd_weights[3] ? 22 : 0;
|
|
|
|
}
|
2017-09-28 06:20:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-10 17:49:42 +01:00
|
|
|
/* FIR filter used by the default and light filters */
|
2017-09-25 04:18:34 +02:00
|
|
|
FT_BASE_DEF( void )
|
2017-02-16 20:45:45 +01:00
|
|
|
ft_lcd_filter_fir( FT_Bitmap* bitmap,
|
|
|
|
FT_LcdFiveTapFilter weights )
|
2006-09-27 10:48:38 +02:00
|
|
|
{
|
2017-06-18 05:28:14 +02:00
|
|
|
FT_UInt width = (FT_UInt)bitmap->width;
|
|
|
|
FT_UInt height = (FT_UInt)bitmap->rows;
|
|
|
|
FT_Int pitch = bitmap->pitch;
|
|
|
|
FT_Byte* origin = bitmap->buffer;
|
2019-05-03 05:06:55 +02:00
|
|
|
FT_Byte mode = bitmap->pixel_mode;
|
2006-09-29 23:31:53 +02:00
|
|
|
|
2006-09-27 10:48:38 +02:00
|
|
|
|
2017-06-18 05:28:14 +02:00
|
|
|
/* take care of bitmap flow */
|
2018-04-24 10:29:19 +02:00
|
|
|
if ( pitch > 0 && height > 0 )
|
2017-06-18 05:28:14 +02:00
|
|
|
origin += pitch * (FT_Int)( height - 1 );
|
|
|
|
|
2006-09-27 10:48:38 +02:00
|
|
|
/* horizontal in-place FIR filter */
|
2019-05-03 05:06:55 +02:00
|
|
|
if ( mode == FT_PIXEL_MODE_LCD && width >= 2 )
|
2006-09-27 10:48:38 +02:00
|
|
|
{
|
2017-06-18 05:28:14 +02:00
|
|
|
FT_Byte* line = origin;
|
2006-09-27 10:48:38 +02:00
|
|
|
|
2014-11-21 08:03:51 +01:00
|
|
|
|
2017-06-18 05:28:14 +02:00
|
|
|
/* `fir' must be at least 32 bit wide, since the sum of */
|
|
|
|
/* the values in `weights' can exceed 0xFF */
|
2014-06-13 09:28:00 +02:00
|
|
|
|
2017-06-18 05:28:14 +02:00
|
|
|
for ( ; height > 0; height--, line -= pitch )
|
2006-09-27 10:48:38 +02:00
|
|
|
{
|
2017-06-18 05:28:14 +02:00
|
|
|
FT_UInt fir[5];
|
|
|
|
FT_UInt val, xx;
|
2006-09-29 23:31:53 +02:00
|
|
|
|
2006-09-27 10:48:38 +02:00
|
|
|
|
2017-06-18 05:28:14 +02:00
|
|
|
val = line[0];
|
|
|
|
fir[2] = weights[2] * val;
|
|
|
|
fir[3] = weights[3] * val;
|
|
|
|
fir[4] = weights[4] * val;
|
2006-09-27 10:48:38 +02:00
|
|
|
|
2017-06-18 05:28:14 +02:00
|
|
|
val = line[1];
|
|
|
|
fir[1] = fir[2] + weights[1] * val;
|
|
|
|
fir[2] = fir[3] + weights[2] * val;
|
|
|
|
fir[3] = fir[4] + weights[3] * val;
|
|
|
|
fir[4] = weights[4] * val;
|
2006-09-27 10:48:38 +02:00
|
|
|
|
|
|
|
for ( xx = 2; xx < width; xx++ )
|
|
|
|
{
|
|
|
|
val = line[xx];
|
2017-06-18 05:28:14 +02:00
|
|
|
fir[0] = fir[1] + weights[0] * val;
|
|
|
|
fir[1] = fir[2] + weights[1] * val;
|
|
|
|
fir[2] = fir[3] + weights[2] * val;
|
|
|
|
fir[3] = fir[4] + weights[3] * val;
|
|
|
|
fir[4] = weights[4] * val;
|
|
|
|
|
2017-07-04 04:49:07 +02:00
|
|
|
line[xx - 2] = FT_SHIFTCLAMP( fir[0] );
|
2006-09-27 10:48:38 +02:00
|
|
|
}
|
|
|
|
|
2017-07-04 04:49:07 +02:00
|
|
|
line[xx - 2] = FT_SHIFTCLAMP( fir[1] );
|
|
|
|
line[xx - 1] = FT_SHIFTCLAMP( fir[2] );
|
2006-09-27 10:48:38 +02:00
|
|
|
}
|
|
|
|
}
|
2006-09-29 23:31:53 +02:00
|
|
|
|
2006-09-27 10:48:38 +02:00
|
|
|
/* vertical in-place FIR filter */
|
2019-05-03 05:06:55 +02:00
|
|
|
else if ( mode == FT_PIXEL_MODE_LCD_V && height >= 2 )
|
2006-09-27 10:48:38 +02:00
|
|
|
{
|
2017-06-18 05:28:14 +02:00
|
|
|
FT_Byte* column = origin;
|
2006-09-27 10:48:38 +02:00
|
|
|
|
2014-11-21 08:03:51 +01:00
|
|
|
|
2006-09-27 10:48:38 +02:00
|
|
|
for ( ; width > 0; width--, column++ )
|
|
|
|
{
|
|
|
|
FT_Byte* col = column;
|
2017-06-18 05:28:14 +02:00
|
|
|
FT_UInt fir[5];
|
|
|
|
FT_UInt val, yy;
|
2006-09-27 10:48:38 +02:00
|
|
|
|
2006-09-29 23:31:53 +02:00
|
|
|
|
2017-06-18 05:28:14 +02:00
|
|
|
val = col[0];
|
|
|
|
fir[2] = weights[2] * val;
|
|
|
|
fir[3] = weights[3] * val;
|
|
|
|
fir[4] = weights[4] * val;
|
|
|
|
col -= pitch;
|
2006-09-27 10:48:38 +02:00
|
|
|
|
2017-06-18 05:28:14 +02:00
|
|
|
val = col[0];
|
|
|
|
fir[1] = fir[2] + weights[1] * val;
|
|
|
|
fir[2] = fir[3] + weights[2] * val;
|
|
|
|
fir[3] = fir[4] + weights[3] * val;
|
|
|
|
fir[4] = weights[4] * val;
|
|
|
|
col -= pitch;
|
2006-09-27 10:48:38 +02:00
|
|
|
|
2017-06-18 05:28:14 +02:00
|
|
|
for ( yy = 2; yy < height; yy++, col -= pitch )
|
2006-09-27 10:48:38 +02:00
|
|
|
{
|
|
|
|
val = col[0];
|
2017-06-18 05:28:14 +02:00
|
|
|
fir[0] = fir[1] + weights[0] * val;
|
|
|
|
fir[1] = fir[2] + weights[1] * val;
|
|
|
|
fir[2] = fir[3] + weights[2] * val;
|
|
|
|
fir[3] = fir[4] + weights[3] * val;
|
|
|
|
fir[4] = weights[4] * val;
|
|
|
|
|
2017-07-04 04:49:07 +02:00
|
|
|
col[pitch * 2] = FT_SHIFTCLAMP( fir[0] );
|
2006-09-27 10:48:38 +02:00
|
|
|
}
|
|
|
|
|
2017-07-04 04:49:07 +02:00
|
|
|
col[pitch * 2] = FT_SHIFTCLAMP( fir[1] );
|
|
|
|
col[pitch] = FT_SHIFTCLAMP( fir[2] );
|
2006-09-27 10:48:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-10 17:49:42 +01:00
|
|
|
#ifdef USE_LEGACY
|
2006-11-14 11:37:10 +01:00
|
|
|
|
2008-01-18 06:32:55 +01:00
|
|
|
/* intra-pixel filter used by the legacy filter */
|
2006-11-10 17:49:42 +01:00
|
|
|
static void
|
|
|
|
_ft_lcd_filter_legacy( FT_Bitmap* bitmap,
|
2017-02-16 20:45:45 +01:00
|
|
|
FT_Byte* weights )
|
2006-11-10 17:49:42 +01:00
|
|
|
{
|
2017-06-18 05:28:14 +02:00
|
|
|
FT_UInt width = (FT_UInt)bitmap->width;
|
|
|
|
FT_UInt height = (FT_UInt)bitmap->rows;
|
|
|
|
FT_Int pitch = bitmap->pitch;
|
|
|
|
FT_Byte* origin = bitmap->buffer;
|
2019-05-03 05:06:55 +02:00
|
|
|
FT_Byte mode = bitmap->pixel_mode;
|
2006-11-10 17:49:42 +01:00
|
|
|
|
2015-02-16 22:00:27 +01:00
|
|
|
static const unsigned int filters[3][3] =
|
2006-11-10 17:49:42 +01:00
|
|
|
{
|
2006-11-14 11:37:10 +01:00
|
|
|
{ 65538 * 9/13, 65538 * 1/6, 65538 * 1/13 },
|
|
|
|
{ 65538 * 3/13, 65538 * 4/6, 65538 * 3/13 },
|
|
|
|
{ 65538 * 1/13, 65538 * 1/6, 65538 * 9/13 }
|
2006-11-10 17:49:42 +01:00
|
|
|
};
|
|
|
|
|
2017-02-16 20:45:45 +01:00
|
|
|
FT_UNUSED( weights );
|
2006-11-14 11:37:10 +01:00
|
|
|
|
2006-11-10 17:49:42 +01:00
|
|
|
|
2017-06-18 05:28:14 +02:00
|
|
|
/* take care of bitmap flow */
|
2018-04-24 10:29:19 +02:00
|
|
|
if ( pitch > 0 && height > 0 )
|
2017-06-18 05:28:14 +02:00
|
|
|
origin += pitch * (FT_Int)( height - 1 );
|
|
|
|
|
2008-01-18 06:32:55 +01:00
|
|
|
/* horizontal in-place intra-pixel filter */
|
2019-05-03 05:06:55 +02:00
|
|
|
if ( mode == FT_PIXEL_MODE_LCD && width >= 3 )
|
2006-11-10 17:49:42 +01:00
|
|
|
{
|
2017-06-18 05:28:14 +02:00
|
|
|
FT_Byte* line = origin;
|
2006-11-10 17:49:42 +01:00
|
|
|
|
|
|
|
|
2017-06-18 05:28:14 +02:00
|
|
|
for ( ; height > 0; height--, line -= pitch )
|
2006-11-10 17:49:42 +01:00
|
|
|
{
|
|
|
|
FT_UInt xx;
|
|
|
|
|
2006-11-14 11:37:10 +01:00
|
|
|
|
2006-11-10 17:49:42 +01:00
|
|
|
for ( xx = 0; xx < width; xx += 3 )
|
|
|
|
{
|
2017-06-18 05:28:14 +02:00
|
|
|
FT_UInt r, g, b;
|
2006-11-10 17:49:42 +01:00
|
|
|
FT_UInt p;
|
|
|
|
|
2006-11-14 11:37:10 +01:00
|
|
|
|
2006-11-10 17:49:42 +01:00
|
|
|
p = line[xx];
|
2017-06-18 05:28:14 +02:00
|
|
|
r = filters[0][0] * p;
|
|
|
|
g = filters[0][1] * p;
|
|
|
|
b = filters[0][2] * p;
|
2006-11-14 11:37:10 +01:00
|
|
|
|
|
|
|
p = line[xx + 1];
|
|
|
|
r += filters[1][0] * p;
|
|
|
|
g += filters[1][1] * p;
|
|
|
|
b += filters[1][2] * p;
|
|
|
|
|
|
|
|
p = line[xx + 2];
|
|
|
|
r += filters[2][0] * p;
|
|
|
|
g += filters[2][1] * p;
|
|
|
|
b += filters[2][2] * p;
|
|
|
|
|
|
|
|
line[xx] = (FT_Byte)( r / 65536 );
|
|
|
|
line[xx + 1] = (FT_Byte)( g / 65536 );
|
|
|
|
line[xx + 2] = (FT_Byte)( b / 65536 );
|
2006-11-10 17:49:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-03 05:06:55 +02:00
|
|
|
else if ( mode == FT_PIXEL_MODE_LCD_V && height >= 3 )
|
2006-11-10 17:49:42 +01:00
|
|
|
{
|
2017-06-18 05:28:14 +02:00
|
|
|
FT_Byte* column = origin;
|
2006-11-10 17:49:42 +01:00
|
|
|
|
2014-11-21 08:03:51 +01:00
|
|
|
|
2006-11-10 17:49:42 +01:00
|
|
|
for ( ; width > 0; width--, column++ )
|
|
|
|
{
|
2017-06-18 05:28:14 +02:00
|
|
|
FT_Byte* col = column - 2 * pitch;
|
2006-11-14 11:37:10 +01:00
|
|
|
|
2006-11-10 17:49:42 +01:00
|
|
|
|
2017-06-18 05:28:14 +02:00
|
|
|
for ( ; height > 0; height -= 3, col -= 3 * pitch )
|
2006-11-10 17:49:42 +01:00
|
|
|
{
|
2017-06-18 05:28:14 +02:00
|
|
|
FT_UInt r, g, b;
|
2006-11-10 17:49:42 +01:00
|
|
|
FT_UInt p;
|
|
|
|
|
2006-11-14 11:37:10 +01:00
|
|
|
|
2006-11-10 17:49:42 +01:00
|
|
|
p = col[0];
|
2017-06-18 05:28:14 +02:00
|
|
|
r = filters[0][0] * p;
|
|
|
|
g = filters[0][1] * p;
|
|
|
|
b = filters[0][2] * p;
|
2006-11-14 11:37:10 +01:00
|
|
|
|
|
|
|
p = col[pitch];
|
|
|
|
r += filters[1][0] * p;
|
|
|
|
g += filters[1][1] * p;
|
|
|
|
b += filters[1][2] * p;
|
|
|
|
|
|
|
|
p = col[pitch * 2];
|
|
|
|
r += filters[2][0] * p;
|
|
|
|
g += filters[2][1] * p;
|
|
|
|
b += filters[2][2] * p;
|
|
|
|
|
|
|
|
col[0] = (FT_Byte)( r / 65536 );
|
|
|
|
col[pitch] = (FT_Byte)( g / 65536 );
|
2017-06-18 05:28:14 +02:00
|
|
|
col[pitch * 2] = (FT_Byte)( b / 65536 );
|
2006-11-10 17:49:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-11-14 11:37:10 +01:00
|
|
|
|
2006-11-10 17:49:42 +01:00
|
|
|
#endif /* USE_LEGACY */
|
|
|
|
|
2006-11-14 11:37:10 +01:00
|
|
|
|
2018-06-07 08:48:48 +02:00
|
|
|
/* documentation in ftlcdfil.h */
|
|
|
|
|
2008-11-24 09:15:05 +01:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2010-04-05 08:46:26 +02:00
|
|
|
FT_Library_SetLcdFilterWeights( FT_Library library,
|
|
|
|
unsigned char *weights )
|
|
|
|
{
|
2014-11-25 11:11:55 +01:00
|
|
|
if ( !library )
|
|
|
|
return FT_THROW( Invalid_Library_Handle );
|
|
|
|
|
|
|
|
if ( !weights )
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_Argument );
|
2010-04-05 08:46:26 +02:00
|
|
|
|
2017-02-16 20:45:45 +01:00
|
|
|
ft_memcpy( library->lcd_weights, weights, FT_LCD_FILTER_FIVE_TAPS );
|
|
|
|
library->lcd_filter_func = ft_lcd_filter_fir;
|
2010-04-05 08:46:26 +02:00
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-07 08:48:48 +02:00
|
|
|
/* documentation in ftlcdfil.h */
|
|
|
|
|
2010-04-05 08:46:26 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Library_SetLcdFilter( FT_Library library,
|
|
|
|
FT_LcdFilter filter )
|
2006-09-27 10:48:38 +02:00
|
|
|
{
|
2017-02-16 20:45:45 +01:00
|
|
|
static const FT_LcdFiveTapFilter default_weights =
|
|
|
|
{ 0x08, 0x4d, 0x56, 0x4d, 0x08 };
|
|
|
|
static const FT_LcdFiveTapFilter light_weights =
|
|
|
|
{ 0x00, 0x55, 0x56, 0x55, 0x00 };
|
2006-11-14 11:37:10 +01:00
|
|
|
|
2006-09-27 10:48:38 +02:00
|
|
|
|
2010-04-05 08:46:26 +02:00
|
|
|
if ( !library )
|
2014-11-25 11:11:55 +01:00
|
|
|
return FT_THROW( Invalid_Library_Handle );
|
2006-09-27 10:48:38 +02:00
|
|
|
|
2006-11-10 17:49:42 +01:00
|
|
|
switch ( filter )
|
2006-09-27 10:48:38 +02:00
|
|
|
{
|
2006-11-14 11:37:10 +01:00
|
|
|
case FT_LCD_FILTER_NONE:
|
|
|
|
library->lcd_filter_func = NULL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FT_LCD_FILTER_DEFAULT:
|
2017-02-16 20:45:45 +01:00
|
|
|
ft_memcpy( library->lcd_weights,
|
|
|
|
default_weights,
|
|
|
|
FT_LCD_FILTER_FIVE_TAPS );
|
|
|
|
library->lcd_filter_func = ft_lcd_filter_fir;
|
2006-11-14 11:37:10 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FT_LCD_FILTER_LIGHT:
|
2017-02-16 20:45:45 +01:00
|
|
|
ft_memcpy( library->lcd_weights,
|
|
|
|
light_weights,
|
|
|
|
FT_LCD_FILTER_FIVE_TAPS );
|
|
|
|
library->lcd_filter_func = ft_lcd_filter_fir;
|
2006-11-14 11:37:10 +01:00
|
|
|
break;
|
2006-11-10 17:49:42 +01:00
|
|
|
|
|
|
|
#ifdef USE_LEGACY
|
2006-11-14 11:37:10 +01:00
|
|
|
|
|
|
|
case FT_LCD_FILTER_LEGACY:
|
2015-11-20 16:03:09 +01:00
|
|
|
case FT_LCD_FILTER_LEGACY1:
|
2006-11-14 11:37:10 +01:00
|
|
|
library->lcd_filter_func = _ft_lcd_filter_legacy;
|
|
|
|
break;
|
|
|
|
|
2006-11-10 17:49:42 +01:00
|
|
|
#endif
|
2006-11-14 11:37:10 +01:00
|
|
|
|
|
|
|
default:
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Invalid_Argument );
|
2006-09-27 10:48:38 +02:00
|
|
|
}
|
|
|
|
|
2010-04-05 08:46:26 +02:00
|
|
|
return FT_Err_Ok;
|
2006-09-27 10:48:38 +02:00
|
|
|
}
|
|
|
|
|
2018-06-07 08:48:48 +02:00
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Library_SetLcdGeometry( FT_Library library,
|
|
|
|
FT_Vector* sub )
|
|
|
|
{
|
|
|
|
FT_UNUSED( library );
|
|
|
|
FT_UNUSED( sub );
|
|
|
|
|
|
|
|
return FT_THROW( Unimplemented_Feature );
|
|
|
|
}
|
|
|
|
|
2006-09-29 23:31:53 +02:00
|
|
|
#else /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
|
2006-09-27 10:48:38 +02:00
|
|
|
|
2018-05-25 04:38:24 +02:00
|
|
|
/* add padding to accommodate outline shifts */
|
2017-09-28 06:20:50 +02:00
|
|
|
FT_BASE_DEF (void)
|
2018-05-25 04:38:24 +02:00
|
|
|
ft_lcd_padding( FT_BBox* cbox,
|
|
|
|
FT_GlyphSlot slot,
|
|
|
|
FT_Render_Mode mode )
|
2017-02-16 20:45:45 +01:00
|
|
|
{
|
2018-05-25 04:38:24 +02:00
|
|
|
FT_Vector* sub = slot->library->lcd_geometry;
|
2017-09-28 06:20:50 +02:00
|
|
|
|
2018-05-25 04:38:24 +02:00
|
|
|
if ( mode == FT_RENDER_MODE_LCD )
|
|
|
|
{
|
|
|
|
cbox->xMin -= FT_MAX( FT_MAX( sub[0].x, sub[1].x ), sub[2].x );
|
|
|
|
cbox->xMax -= FT_MIN( FT_MIN( sub[0].x, sub[1].x ), sub[2].x );
|
|
|
|
cbox->yMin -= FT_MAX( FT_MAX( sub[0].y, sub[1].y ), sub[2].y );
|
|
|
|
cbox->yMax -= FT_MIN( FT_MIN( sub[0].y, sub[1].y ), sub[2].y );
|
|
|
|
}
|
|
|
|
else if ( mode == FT_RENDER_MODE_LCD_V )
|
|
|
|
{
|
|
|
|
cbox->xMin -= FT_MAX( FT_MAX( sub[0].y, sub[1].y ), sub[2].y );
|
|
|
|
cbox->xMax -= FT_MIN( FT_MIN( sub[0].y, sub[1].y ), sub[2].y );
|
|
|
|
cbox->yMin += FT_MIN( FT_MIN( sub[0].x, sub[1].x ), sub[2].x );
|
|
|
|
cbox->yMax += FT_MAX( FT_MAX( sub[0].x, sub[1].x ), sub[2].x );
|
|
|
|
}
|
2017-02-16 20:45:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-05 08:46:26 +02:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Library_SetLcdFilterWeights( FT_Library library,
|
|
|
|
unsigned char *weights )
|
|
|
|
{
|
|
|
|
FT_UNUSED( library );
|
|
|
|
FT_UNUSED( weights );
|
|
|
|
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Unimplemented_Feature );
|
2010-04-05 08:46:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-11-24 09:15:05 +01:00
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2006-11-10 17:49:42 +01:00
|
|
|
FT_Library_SetLcdFilter( FT_Library library,
|
|
|
|
FT_LcdFilter filter )
|
2006-09-27 10:48:38 +02:00
|
|
|
{
|
2006-09-29 23:31:53 +02:00
|
|
|
FT_UNUSED( library );
|
2006-11-10 17:49:42 +01:00
|
|
|
FT_UNUSED( filter );
|
2006-09-27 10:48:38 +02:00
|
|
|
|
2013-03-14 10:27:35 +01:00
|
|
|
return FT_THROW( Unimplemented_Feature );
|
2006-09-27 10:48:38 +02:00
|
|
|
}
|
|
|
|
|
2018-06-07 08:48:48 +02:00
|
|
|
|
|
|
|
/* documentation in ftlcdfil.h */
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Library_SetLcdGeometry( FT_Library library,
|
|
|
|
FT_Vector sub[3] )
|
|
|
|
{
|
|
|
|
if ( !library )
|
|
|
|
return FT_THROW( Invalid_Library_Handle );
|
|
|
|
|
|
|
|
if ( !sub )
|
|
|
|
return FT_THROW( Invalid_Argument );
|
|
|
|
|
|
|
|
ft_memcpy( library->lcd_geometry, sub, 3 * sizeof( FT_Vector ) );
|
|
|
|
|
|
|
|
return FT_THROW( Unimplemented_Feature );
|
|
|
|
}
|
|
|
|
|
2006-09-29 23:31:53 +02:00
|
|
|
#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
|
|
|
|
|
2006-09-27 10:48:38 +02:00
|
|
|
|
2006-09-29 23:31:53 +02:00
|
|
|
/* END */
|