ft_outline_glyph_init( FT_Glyph outline_glyph, FT_GlyphSlot slot ) { FT_OutlineGlyph glyph = (FT_OutlineGlyph)outline_glyph; FT_Error error = FT_Err_Ok; FT_Library library = FT_GLYPH( glyph )->library; FT_Outline* source = &slot->outline; FT_Outline* target = &glyph->outline; /* check format in glyph slot */ if ( slot->format != FT_GLYPH_FORMAT_OUTLINE ) { error = FT_Err_Invalid_Glyph_Format; goto Exit; } /* allocate new outline */ error = FT_Outline_New( library, source->n_points, source->n_contours, &glyph->outline ); if ( error ) goto Exit; FT_Outline_Copy( source, target ); Exit: return error; }
PyObject * Py_Outline_cnew(FT_Outline *outline) { Py_Outline *self; self = (Py_Outline *)(&Py_Outline_Type)->tp_alloc(&Py_Outline_Type, 0); if (self == NULL) { return NULL; } self->points = NULL; self->codes = NULL; self->inited = 0; if (ftpy_exc( FT_Outline_New(get_ft_library(), outline->n_points, outline->n_contours, &self->x))) { Py_DECREF(self); return NULL; } self->inited = 1; if (ftpy_exc( FT_Outline_Copy(outline, &self->x))) { Py_DECREF(self); return NULL; } self->base.owner = NULL; return (PyObject *)self; }
static FT_Error ft_outline_glyph_copy( FT_OutlineGlyph source, FT_OutlineGlyph target ) { FT_Error error; FT_Library library = FT_GLYPH( source )->library; error = FT_Outline_New( library, source->outline.n_points, source->outline.n_contours, &target->outline ); if ( !error ) FT_Outline_Copy( &source->outline, &target->outline ); return error; }
FT_Error ft_OutlineStroke( FT_Library library, FT_Outline *Outline, int Thickness ) { FT_Error err = 0; FT_Outline OutlineReversed; FT_Outline OutlineFattened; FT_Outline OutlineStroke; if ( Outline == NULL ) { goto failure; } err = FT_Outline_New( library, Outline->n_points, Outline->n_contours, &OutlineReversed ); if ( err != 0 ) { goto failure; } err = FT_Outline_New( library, Outline->n_points, Outline->n_contours, &OutlineFattened ); if ( err != 0 ) { goto failure; } err = FT_Outline_Copy( Outline, &OutlineReversed ); if ( err != 0 ) { goto failure; } err = FT_Outline_Copy( Outline, &OutlineFattened ); if ( err != 0 ) { goto failure; } err = FT_Outline_New( library, Outline->n_points * 2, Outline->n_contours * 2, &OutlineStroke ); if ( err != 0 ) { goto failure; } /* Perform fattening operation */ err = FT_Outline_Embolden( &OutlineFattened, Thickness << 1 ); if ( err != 0 ) { goto failure; } /* Perform reversal operation */ ft_OutlineReverse( Outline, &OutlineReversed ); FT_Outline_Translate( &OutlineReversed, Thickness, Thickness ); /* Merge outlines */ ft_OutlineMerge( &OutlineFattened, &OutlineReversed, &OutlineStroke ); /* delete temporary and input outline */ err = FT_Outline_Done( library, &OutlineReversed ); if ( err != 0 ) { goto failure; } err = FT_Outline_Done( library, &OutlineFattened ); if ( err != 0 ) { goto failure; } err = FT_Outline_Done( library, Outline ); if ( err != 0 ) { goto failure; } /* finally copy the outline - its not clear from ft docs if this does the right thing but i _think_ its correct */ memcpy( Outline, &OutlineStroke, sizeof( FT_Outline ) ); return 0; failure: return err; }