diff --git a/include/freetype/ftimage.h b/include/freetype/ftimage.h index 6baa81256..0c29c76fb 100644 --- a/include/freetype/ftimage.h +++ b/include/freetype/ftimage.h @@ -1059,6 +1059,7 @@ FT_BEGIN_HEADER FT_Raster_BitSet_Func bit_set; /* unused */ void* user; FT_BBox clip_box; + void* prelines; } FT_Raster_Params; diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 7acde344e..7426449ed 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -2570,9 +2570,12 @@ if ( !outline ) return FT_THROW( Invalid_Outline ); - for ( n = 0; n < outline->n_contours; n++ ) + last = -1; + FT_PreLine ptr = (*slot)->prelines; + + for ( n = 0; n < outline->n_contours; n++ ) { - FT_TRACE5(( "FT_Outline_Decompose: Contour %d\n", n )); + FT_TRACE5(( "ft_decompose_outline: Contour %d\n", n )); first = last + 1; last = outline->contours[n]; @@ -2629,6 +2632,22 @@ // if ( error ) // goto Exit; + + FT_PreLine pl = malloc(sizeof(FT_PreLineRec)); + pl->x1 = v_start.x/64; + pl->y1 = v_start.y/64; + pl->x2 = v_start.x/64; + pl->y2 = v_start.y/64; + pl->next = NULL; + + if((*slot)->prelines == NULL){ + ptr = (*slot)->prelines = pl; + }else{ + ptr->next = pl; + + } + + while ( point < limit ) { point++; @@ -2642,19 +2661,20 @@ FT_Vector vec; - vec.x = SCALED( point->x ); - vec.y = SCALED( point->y ); + vec.x = point->x; + vec.y = point->y; FT_TRACE5(( " line to (%.2f, %.2f)\n", (double)vec.x / 64, (double)vec.y / 64 )); //error = func_interface->line_to( &vec, user ); FT_PreLine pl = malloc(sizeof(FT_PreLineRec)); - pl->x1 = v_last.x; - pl->y1 = v_last.y; - pl->x2 = vec.x; - pl->y2 = vec.y; + pl->x1 = v_last.x/64; + pl->y1 = v_last.y/64; + pl->x2 = vec.x/64; + pl->y2 = vec.y/64; pl->next = NULL; - (*slot)->prelines->next = pl; + ptr->next = pl; + ptr = ptr->next; continue; } @@ -2947,14 +2967,15 @@ FT_Load_Glyph(face, gindex, FT_LOAD_NO_HINTING); // *face->garray[gindex]->prelines = (FT_PreLineRec){1,2,3,4, NULL}; // need to revise structs and pointers. - FT_PreLine pl = face->garray[gindex]->prelines = malloc(sizeof(FT_PreLineRec)); - pl->x1 = 0; - pl->x2 = 1; - pl->y1 = 2; - pl->y2 = 3; - pl->next = NULL; - - ft_decompose_outline(face->garray[gindex]); + // FT_PreLine pl = face->garray[gindex]->prelines = malloc(sizeof(FT_PreLineRec)); + // pl->x1 = 0; + // pl->x2 = 1; + // pl->y1 = 2; + // pl->y2 = 3; + // pl->next = NULL; + + + ft_decompose_outline(&face->garray[gindex]); } diff --git a/src/dense/ftdense.c b/src/dense/ftdense.c index f0f3e59f9..4e91d439c 100644 --- a/src/dense/ftdense.c +++ b/src/dense/ftdense.c @@ -9,6 +9,8 @@ #include #include + +#include #include "ftdense.h" #include "ftdenseerrs.h" @@ -416,10 +418,23 @@ FT_DEFINE_OUTLINE_FUNCS( dense_decompose_funcs, ) static int -dense_render_glyph( dense_worker* worker, const FT_Bitmap* target ) +dense_render_glyph( dense_worker* worker, const FT_Bitmap* target, FT_PreLine pl ) { - FT_Error error = FT_Outline_Decompose( &( worker->outline ), - &dense_decompose_funcs, worker ); + // FT_Error error = FT_Outline_Decompose( &( worker->outline ), + // &dense_decompose_funcs, worker ); + FT_Vector point = {100, 100}; + FT_Error error = dense_move_to(&point, worker); + while (pl!=NULL) + { + point.x = pl->x2/64; + point.y = pl->y2/64; + dense_line_to(&point, worker); + pl= pl->next; + } + point.x = 100; + point.y = 100; + dense_move_to(&point, worker); + // Render into bitmap const FT20D12* source = worker->m_a; unsigned char* dest = target->buffer; @@ -495,6 +510,8 @@ dense_raster_render( FT_Raster raster, const FT_Raster_Params* params ) { const FT_Outline* outline = (const FT_Outline*)params->source; FT_Bitmap* target_map = params->target; + FT_PreLine pl = params->prelines; + printf("%d\n", pl->next->x1); dense_worker worker[1]; @@ -536,7 +553,7 @@ dense_raster_render( FT_Raster raster, const FT_Raster_Params* params ) // Invert the pitch to account for different +ve y-axis direction in dense array // (maybe temporary solution) target_map->pitch *= -1; - return dense_render_glyph( worker, target_map ); + return dense_render_glyph( worker, target_map, pl ); } FT_DEFINE_RASTER_FUNCS( diff --git a/src/dense/ftdenserend.c b/src/dense/ftdenserend.c index 3aa98cde6..2b3cafd91 100644 --- a/src/dense/ftdenserend.c +++ b/src/dense/ftdenserend.c @@ -90,7 +90,7 @@ FT_Render_Mode mode, const FT_Vector* origin ) { - printf("%d %d %d %d \n", slot->prelines->x1, slot->prelines->x2, slot->prelines->y1, slot->prelines->y2); + // printf("%d %d %d %d \n", slot->prelines->x1, slot->prelines->x2, slot->prelines->y1, slot->prelines->y2); FT_Error error = FT_Err_Ok; FT_Outline* outline = &slot->outline; FT_Bitmap* bitmap = &slot->bitmap; @@ -168,6 +168,7 @@ /* set up parameters */ params.target = bitmap; params.source = outline; + params.prelines = slot->prelines; /* render the outline */ error =