ftrend1.c revision bff90fb5ec88ad7fdfb6d1d2f5a5719c20a2c5dc
1049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/***************************************************************************/ 2049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* */ 3049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* ftrend1.c */ 4049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* */ 5049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* The FreeType glyph rasterizer interface (body). */ 6049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* */ 7bff90fb5ec88ad7fdfb6d1d2f5a5719c20a2c5dcOlivier Bailly/* Copyright 1996-2003, 2005, 2006, 2011 by */ 8049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* David Turner, Robert Wilhelm, and Werner Lemberg. */ 9049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* */ 10049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* This file is part of the FreeType project, and may only be used, */ 11049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* modified, and distributed under the terms of the FreeType project */ 12049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 13049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* this file you indicate that you have read the license and */ 14049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* understand and accept it fully. */ 15049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* */ 16049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/***************************************************************************/ 17049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 18049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 19049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include <ft2build.h> 20049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include FT_INTERNAL_OBJECTS_H 21049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include FT_OUTLINE_H 22049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include "ftrend1.h" 23049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include "ftraster.h" 24295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#include "rastpic.h" 25049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 26049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project#include "rasterrs.h" 27049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 28049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 29049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* initialize renderer -- init its raster */ 30049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project static FT_Error 31049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_raster1_init( FT_Renderer render ) 32049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { 33049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Library library = FT_MODULE_LIBRARY( render ); 34049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 35049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 36049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project render->clazz->raster_class->raster_reset( render->raster, 37049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project library->raster_pool, 38049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project library->raster_pool_size ); 39049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 40049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project return Raster_Err_Ok; 41049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } 42049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 43049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 44049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* set render-specific mode */ 45049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project static FT_Error 46049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_raster1_set_mode( FT_Renderer render, 47049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_ULong mode_tag, 48049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Pointer data ) 49049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { 50049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* we simply pass it to the raster */ 51049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project return render->clazz->raster_class->raster_set_mode( render->raster, 52049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project mode_tag, 53049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project data ); 54049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } 55049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 56049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 57049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* transform a given glyph image */ 58049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project static FT_Error 59049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_raster1_transform( FT_Renderer render, 60049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_GlyphSlot slot, 61049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project const FT_Matrix* matrix, 62049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project const FT_Vector* delta ) 63049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { 64049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Error error = Raster_Err_Ok; 65049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 66049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 67049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project if ( slot->format != render->glyph_format ) 68049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { 69049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project error = Raster_Err_Invalid_Argument; 70049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project goto Exit; 71049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } 72049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 73049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project if ( matrix ) 74049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Outline_Transform( &slot->outline, matrix ); 75049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 76049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project if ( delta ) 77049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Outline_Translate( &slot->outline, delta->x, delta->y ); 78049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 79049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project Exit: 80049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project return error; 81049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } 82049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 83049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 84049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* return the glyph's control box */ 85049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project static void 86049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_raster1_get_cbox( FT_Renderer render, 87049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_GlyphSlot slot, 88049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BBox* cbox ) 89049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { 90049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_MEM_ZERO( cbox, sizeof ( *cbox ) ); 91049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 92049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project if ( slot->format == render->glyph_format ) 93049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Outline_Get_CBox( &slot->outline, cbox ); 94049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } 95049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 96049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 97049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* convert a slot's glyph image into a bitmap */ 98049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project static FT_Error 99049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project ft_raster1_render( FT_Renderer render, 100049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_GlyphSlot slot, 101049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Render_Mode mode, 102049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project const FT_Vector* origin ) 103049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { 104049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Error error; 105049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Outline* outline; 106049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_BBox cbox; 107049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_UInt width, height, pitch; 108049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Bitmap* bitmap; 109049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Memory memory; 110049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 111049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Raster_Params params; 112049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 113049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 114049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* check glyph image format */ 115049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project if ( slot->format != render->glyph_format ) 116049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { 117049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project error = Raster_Err_Invalid_Argument; 118049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project goto Exit; 119049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } 120049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 121049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* check rendering mode */ 122295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#ifndef FT_CONFIG_OPTION_PIC 123049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project if ( mode != FT_RENDER_MODE_MONO ) 124049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { 125049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* raster1 is only capable of producing monochrome bitmaps */ 126049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project if ( render->clazz == &ft_raster1_renderer_class ) 127049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project return Raster_Err_Cannot_Render_Glyph; 128049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } 129049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project else 130049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { 131049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* raster5 is only capable of producing 5-gray-levels bitmaps */ 132049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project if ( render->clazz == &ft_raster5_renderer_class ) 133049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project return Raster_Err_Cannot_Render_Glyph; 134049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } 135295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#else /* FT_CONFIG_OPTION_PIC */ 136295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner /* When PIC is enabled, we cannot get to the class object */ 137295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner /* so instead we check the final character in the class name */ 138295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner /* ("raster5" or "raster1"). Yes this is a hack. */ 139295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner /* The "correct" thing to do is have different render function */ 140295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner /* for each of the classes. */ 141295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner if ( mode != FT_RENDER_MODE_MONO ) 142295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner { 143295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner /* raster1 is only capable of producing monochrome bitmaps */ 144295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner if ( render->clazz->root.module_name[6] == '1' ) 145295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner return Raster_Err_Cannot_Render_Glyph; 146295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner } 147295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner else 148295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner { 149295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner /* raster5 is only capable of producing 5-gray-levels bitmaps */ 150295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner if ( render->clazz->root.module_name[6] == '5' ) 151295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner return Raster_Err_Cannot_Render_Glyph; 152295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner } 153295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner#endif /* FT_CONFIG_OPTION_PIC */ 154049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 155049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project outline = &slot->outline; 156049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 157049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* translate the outline to the new origin if needed */ 158049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project if ( origin ) 159049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Outline_Translate( outline, origin->x, origin->y ); 160049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 161049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* compute the control box, and grid fit it */ 162049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Outline_Get_CBox( outline, &cbox ); 163049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 164aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner /* undocumented but confirmed: bbox values get rounded */ 165aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#if 1 166aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner cbox.xMin = FT_PIX_ROUND( cbox.xMin ); 167aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner cbox.yMin = FT_PIX_ROUND( cbox.yMin ); 168aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner cbox.xMax = FT_PIX_ROUND( cbox.xMax ); 169aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner cbox.yMax = FT_PIX_ROUND( cbox.yMax ); 170aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#else 171049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); 172049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); 173049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project cbox.xMax = FT_PIX_CEIL( cbox.xMax ); 174049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project cbox.yMax = FT_PIX_CEIL( cbox.yMax ); 175aeb407daf3711a10a27f3bc2223c5eb05158076eDavid 'Digit' Turner#endif 176049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 177049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); 178049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); 179bff90fb5ec88ad7fdfb6d1d2f5a5719c20a2c5dcOlivier Bailly 180bff90fb5ec88ad7fdfb6d1d2f5a5719c20a2c5dcOlivier Bailly if ( width > FT_USHORT_MAX || height > FT_USHORT_MAX ) 181bff90fb5ec88ad7fdfb6d1d2f5a5719c20a2c5dcOlivier Bailly { 182bff90fb5ec88ad7fdfb6d1d2f5a5719c20a2c5dcOlivier Bailly error = Raster_Err_Invalid_Argument; 183bff90fb5ec88ad7fdfb6d1d2f5a5719c20a2c5dcOlivier Bailly goto Exit; 184bff90fb5ec88ad7fdfb6d1d2f5a5719c20a2c5dcOlivier Bailly } 185bff90fb5ec88ad7fdfb6d1d2f5a5719c20a2c5dcOlivier Bailly 186049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project bitmap = &slot->bitmap; 187049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project memory = render->root.memory; 188049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 189049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* release old bitmap buffer */ 190049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) 191049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { 192049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_FREE( bitmap->buffer ); 193049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; 194049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } 195049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 196049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* allocate new one, depends on pixel format */ 197049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project if ( !( mode & FT_RENDER_MODE_MONO ) ) 198049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { 199049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* we pad to 32 bits, only for backwards compatibility with FT 1.x */ 200049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project pitch = FT_PAD_CEIL( width, 4 ); 201049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project bitmap->pixel_mode = FT_PIXEL_MODE_GRAY; 202049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project bitmap->num_grays = 256; 203049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } 204049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project else 205049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project { 206049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project pitch = ( ( width + 15 ) >> 4 ) << 1; 207049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project bitmap->pixel_mode = FT_PIXEL_MODE_MONO; 208049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } 209049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 210049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project bitmap->width = width; 211049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project bitmap->rows = height; 212049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project bitmap->pitch = pitch; 213049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 214049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project if ( FT_ALLOC_MULT( bitmap->buffer, pitch, height ) ) 215049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project goto Exit; 216049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 217049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project slot->internal->flags |= FT_GLYPH_OWN_BITMAP; 218049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 219049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* translate outline to render it into the bitmap */ 220049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Outline_Translate( outline, -cbox.xMin, -cbox.yMin ); 221049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 222049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* set up parameters */ 223049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project params.target = bitmap; 224049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project params.source = outline; 225049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project params.flags = 0; 226049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 227049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project if ( bitmap->pixel_mode == FT_PIXEL_MODE_GRAY ) 228049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project params.flags |= FT_RASTER_FLAG_AA; 229049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 230049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* render outline into the bitmap */ 231049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project error = render->raster_render( render->raster, ¶ms ); 232049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 233049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_Outline_Translate( outline, cbox.xMin, cbox.yMin ); 234049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 235049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project if ( error ) 236049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project goto Exit; 237049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 238049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project slot->format = FT_GLYPH_FORMAT_BITMAP; 239049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project slot->bitmap_left = (FT_Int)( cbox.xMin >> 6 ); 240049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project slot->bitmap_top = (FT_Int)( cbox.yMax >> 6 ); 241049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 242049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project Exit: 243049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project return error; 244049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project } 245049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 246049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 247295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner FT_DEFINE_RENDERER(ft_raster1_renderer_class, 248295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 249049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_MODULE_RENDERER, 250049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project sizeof( FT_RendererRec ), 251049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 252049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project "raster1", 253049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 0x10000L, 254049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 0x20000L, 255049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 256049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 0, /* module specific interface */ 257049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 258049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Module_Constructor)ft_raster1_init, 259049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Module_Destructor) 0, 260049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Module_Requester) 0 261295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner , 262049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 263049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_GLYPH_FORMAT_OUTLINE, 264049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 265049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Renderer_RenderFunc) ft_raster1_render, 266049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Renderer_TransformFunc)ft_raster1_transform, 267049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox, 268049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Renderer_SetModeFunc) ft_raster1_set_mode, 269049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 270295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner (FT_Raster_Funcs*) &FT_STANDARD_RASTER_GET 271295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner ) 272049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 273049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 274049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* This renderer is _NOT_ part of the default modules; you will need */ 275049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* to register it by hand in your application. It should only be */ 276049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* used for backwards-compatibility with FT 1.x anyway. */ 277049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project /* */ 278295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner FT_DEFINE_RENDERER(ft_raster5_renderer_class, 279295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 280295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner 281049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_MODULE_RENDERER, 282049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project sizeof( FT_RendererRec ), 283049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 284049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project "raster5", 285049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 0x10000L, 286049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 0x20000L, 287049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 288049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 0, /* module specific interface */ 289049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 290049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Module_Constructor)ft_raster1_init, 291049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Module_Destructor) 0, 292049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Module_Requester) 0 293295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner , 294049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 295049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project FT_GLYPH_FORMAT_OUTLINE, 296049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 297049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Renderer_RenderFunc) ft_raster1_render, 298049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Renderer_TransformFunc)ft_raster1_transform, 299049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox, 300049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project (FT_Renderer_SetModeFunc) ft_raster1_set_mode, 301049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 302295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner (FT_Raster_Funcs*) &FT_STANDARD_RASTER_GET 303295ffce55e0198e7a9f7d46b33f5c2b4147bf821David 'Digit' Turner ) 304049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 305049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project 306049d6fea481044fcc000e7782e5bc7046fc70844The Android Open Source Project/* END */ 307