Path: blob/master/src/java.desktop/share/native/libfreetype/include/freetype/ftoutln.h
42588 views
/****************************************************************************1*2* ftoutln.h3*4* Support for the FT_Outline type used to store glyph shapes of5* most scalable font formats (specification).6*7* Copyright (C) 1996-2020 by8* David Turner, Robert Wilhelm, and Werner Lemberg.9*10* This file is part of the FreeType project, and may only be used,11* modified, and distributed under the terms of the FreeType project12* license, LICENSE.TXT. By continuing to use, modify, or distribute13* this file you indicate that you have read the license and14* understand and accept it fully.15*16*/171819#ifndef FTOUTLN_H_20#define FTOUTLN_H_212223#include <freetype/freetype.h>2425#ifdef FREETYPE_H26#error "freetype.h of FreeType 1 has been loaded!"27#error "Please fix the directory search order for header files"28#error "so that freetype.h of FreeType 2 is found first."29#endif303132FT_BEGIN_HEADER333435/**************************************************************************36*37* @section:38* outline_processing39*40* @title:41* Outline Processing42*43* @abstract:44* Functions to create, transform, and render vectorial glyph images.45*46* @description:47* This section contains routines used to create and destroy scalable48* glyph images known as 'outlines'. These can also be measured,49* transformed, and converted into bitmaps and pixmaps.50*51* @order:52* FT_Outline53* FT_Outline_New54* FT_Outline_Done55* FT_Outline_Copy56* FT_Outline_Translate57* FT_Outline_Transform58* FT_Outline_Embolden59* FT_Outline_EmboldenXY60* FT_Outline_Reverse61* FT_Outline_Check62*63* FT_Outline_Get_CBox64* FT_Outline_Get_BBox65*66* FT_Outline_Get_Bitmap67* FT_Outline_Render68* FT_Outline_Decompose69* FT_Outline_Funcs70* FT_Outline_MoveToFunc71* FT_Outline_LineToFunc72* FT_Outline_ConicToFunc73* FT_Outline_CubicToFunc74*75* FT_Orientation76* FT_Outline_Get_Orientation77*78* FT_OUTLINE_XXX79*80*/818283/**************************************************************************84*85* @function:86* FT_Outline_Decompose87*88* @description:89* Walk over an outline's structure to decompose it into individual90* segments and Bezier arcs. This function also emits 'move to'91* operations to indicate the start of new contours in the outline.92*93* @input:94* outline ::95* A pointer to the source target.96*97* func_interface ::98* A table of 'emitters', i.e., function pointers called during99* decomposition to indicate path operations.100*101* @inout:102* user ::103* A typeless pointer that is passed to each emitter during the104* decomposition. It can be used to store the state during the105* decomposition.106*107* @return:108* FreeType error code. 0~means success.109*110* @note:111* A contour that contains a single point only is represented by a 'move112* to' operation followed by 'line to' to the same point. In most cases,113* it is best to filter this out before using the outline for stroking114* purposes (otherwise it would result in a visible dot when round caps115* are used).116*117* Similarly, the function returns success for an empty outline also118* (doing nothing, this is, not calling any emitter); if necessary, you119* should filter this out, too.120*/121FT_EXPORT( FT_Error )122FT_Outline_Decompose( FT_Outline* outline,123const FT_Outline_Funcs* func_interface,124void* user );125126127/**************************************************************************128*129* @function:130* FT_Outline_New131*132* @description:133* Create a new outline of a given size.134*135* @input:136* library ::137* A handle to the library object from where the outline is allocated.138* Note however that the new outline will **not** necessarily be139* **freed**, when destroying the library, by @FT_Done_FreeType.140*141* numPoints ::142* The maximum number of points within the outline. Must be smaller143* than or equal to 0xFFFF (65535).144*145* numContours ::146* The maximum number of contours within the outline. This value must147* be in the range 0 to `numPoints`.148*149* @output:150* anoutline ::151* A handle to the new outline.152*153* @return:154* FreeType error code. 0~means success.155*156* @note:157* The reason why this function takes a `library` parameter is simply to158* use the library's memory allocator.159*/160FT_EXPORT( FT_Error )161FT_Outline_New( FT_Library library,162FT_UInt numPoints,163FT_Int numContours,164FT_Outline *anoutline );165166167/**************************************************************************168*169* @function:170* FT_Outline_Done171*172* @description:173* Destroy an outline created with @FT_Outline_New.174*175* @input:176* library ::177* A handle of the library object used to allocate the outline.178*179* outline ::180* A pointer to the outline object to be discarded.181*182* @return:183* FreeType error code. 0~means success.184*185* @note:186* If the outline's 'owner' field is not set, only the outline descriptor187* will be released.188*/189FT_EXPORT( FT_Error )190FT_Outline_Done( FT_Library library,191FT_Outline* outline );192193194/**************************************************************************195*196* @function:197* FT_Outline_Check198*199* @description:200* Check the contents of an outline descriptor.201*202* @input:203* outline ::204* A handle to a source outline.205*206* @return:207* FreeType error code. 0~means success.208*209* @note:210* An empty outline, or an outline with a single point only is also211* valid.212*/213FT_EXPORT( FT_Error )214FT_Outline_Check( FT_Outline* outline );215216217/**************************************************************************218*219* @function:220* FT_Outline_Get_CBox221*222* @description:223* Return an outline's 'control box'. The control box encloses all the224* outline's points, including Bezier control points. Though it225* coincides with the exact bounding box for most glyphs, it can be226* slightly larger in some situations (like when rotating an outline that227* contains Bezier outside arcs).228*229* Computing the control box is very fast, while getting the bounding box230* can take much more time as it needs to walk over all segments and arcs231* in the outline. To get the latter, you can use the 'ftbbox'232* component, which is dedicated to this single task.233*234* @input:235* outline ::236* A pointer to the source outline descriptor.237*238* @output:239* acbox ::240* The outline's control box.241*242* @note:243* See @FT_Glyph_Get_CBox for a discussion of tricky fonts.244*/245FT_EXPORT( void )246FT_Outline_Get_CBox( const FT_Outline* outline,247FT_BBox *acbox );248249250/**************************************************************************251*252* @function:253* FT_Outline_Translate254*255* @description:256* Apply a simple translation to the points of an outline.257*258* @inout:259* outline ::260* A pointer to the target outline descriptor.261*262* @input:263* xOffset ::264* The horizontal offset.265*266* yOffset ::267* The vertical offset.268*/269FT_EXPORT( void )270FT_Outline_Translate( const FT_Outline* outline,271FT_Pos xOffset,272FT_Pos yOffset );273274275/**************************************************************************276*277* @function:278* FT_Outline_Copy279*280* @description:281* Copy an outline into another one. Both objects must have the same282* sizes (number of points & number of contours) when this function is283* called.284*285* @input:286* source ::287* A handle to the source outline.288*289* @output:290* target ::291* A handle to the target outline.292*293* @return:294* FreeType error code. 0~means success.295*/296FT_EXPORT( FT_Error )297FT_Outline_Copy( const FT_Outline* source,298FT_Outline *target );299300301/**************************************************************************302*303* @function:304* FT_Outline_Transform305*306* @description:307* Apply a simple 2x2 matrix to all of an outline's points. Useful for308* applying rotations, slanting, flipping, etc.309*310* @inout:311* outline ::312* A pointer to the target outline descriptor.313*314* @input:315* matrix ::316* A pointer to the transformation matrix.317*318* @note:319* You can use @FT_Outline_Translate if you need to translate the320* outline's points.321*/322FT_EXPORT( void )323FT_Outline_Transform( const FT_Outline* outline,324const FT_Matrix* matrix );325326327/**************************************************************************328*329* @function:330* FT_Outline_Embolden331*332* @description:333* Embolden an outline. The new outline will be at most 4~times334* `strength` pixels wider and higher. You may think of the left and335* bottom borders as unchanged.336*337* Negative `strength` values to reduce the outline thickness are338* possible also.339*340* @inout:341* outline ::342* A handle to the target outline.343*344* @input:345* strength ::346* How strong the glyph is emboldened. Expressed in 26.6 pixel format.347*348* @return:349* FreeType error code. 0~means success.350*351* @note:352* The used algorithm to increase or decrease the thickness of the glyph353* doesn't change the number of points; this means that certain354* situations like acute angles or intersections are sometimes handled355* incorrectly.356*357* If you need 'better' metrics values you should call358* @FT_Outline_Get_CBox or @FT_Outline_Get_BBox.359*360* To get meaningful results, font scaling values must be set with361* functions like @FT_Set_Char_Size before calling FT_Render_Glyph.362*363* @example:364* ```365* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT );366*367* if ( face->glyph->format == FT_GLYPH_FORMAT_OUTLINE )368* FT_Outline_Embolden( &face->glyph->outline, strength );369* ```370*371*/372FT_EXPORT( FT_Error )373FT_Outline_Embolden( FT_Outline* outline,374FT_Pos strength );375376377/**************************************************************************378*379* @function:380* FT_Outline_EmboldenXY381*382* @description:383* Embolden an outline. The new outline will be `xstrength` pixels wider384* and `ystrength` pixels higher. Otherwise, it is similar to385* @FT_Outline_Embolden, which uses the same strength in both directions.386*387* @since:388* 2.4.10389*/390FT_EXPORT( FT_Error )391FT_Outline_EmboldenXY( FT_Outline* outline,392FT_Pos xstrength,393FT_Pos ystrength );394395396/**************************************************************************397*398* @function:399* FT_Outline_Reverse400*401* @description:402* Reverse the drawing direction of an outline. This is used to ensure403* consistent fill conventions for mirrored glyphs.404*405* @inout:406* outline ::407* A pointer to the target outline descriptor.408*409* @note:410* This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in the411* outline's `flags` field.412*413* It shouldn't be used by a normal client application, unless it knows414* what it is doing.415*/416FT_EXPORT( void )417FT_Outline_Reverse( FT_Outline* outline );418419420/**************************************************************************421*422* @function:423* FT_Outline_Get_Bitmap424*425* @description:426* Render an outline within a bitmap. The outline's image is simply427* OR-ed to the target bitmap.428*429* @input:430* library ::431* A handle to a FreeType library object.432*433* outline ::434* A pointer to the source outline descriptor.435*436* @inout:437* abitmap ::438* A pointer to the target bitmap descriptor.439*440* @return:441* FreeType error code. 0~means success.442*443* @note:444* This function does **not create** the bitmap, it only renders an445* outline image within the one you pass to it! Consequently, the446* various fields in `abitmap` should be set accordingly.447*448* It will use the raster corresponding to the default glyph format.449*450* The value of the `num_grays` field in `abitmap` is ignored. If you451* select the gray-level rasterizer, and you want less than 256 gray452* levels, you have to use @FT_Outline_Render directly.453*/454FT_EXPORT( FT_Error )455FT_Outline_Get_Bitmap( FT_Library library,456FT_Outline* outline,457const FT_Bitmap *abitmap );458459460/**************************************************************************461*462* @function:463* FT_Outline_Render464*465* @description:466* Render an outline within a bitmap using the current scan-convert.467*468* @input:469* library ::470* A handle to a FreeType library object.471*472* outline ::473* A pointer to the source outline descriptor.474*475* @inout:476* params ::477* A pointer to an @FT_Raster_Params structure used to describe the478* rendering operation.479*480* @return:481* FreeType error code. 0~means success.482*483* @note:484* This advanced function uses @FT_Raster_Params as an argument.485* The field `params.source` will be set to `outline` before the scan486* converter is called, which means that the value you give to it is487* actually ignored. Either `params.target` must point to preallocated488* bitmap, or @FT_RASTER_FLAG_DIRECT must be set in `params.flags`489* allowing FreeType rasterizer to be used for direct composition,490* translucency, etc. See @FT_Raster_Params for more details.491*/492FT_EXPORT( FT_Error )493FT_Outline_Render( FT_Library library,494FT_Outline* outline,495FT_Raster_Params* params );496497498/**************************************************************************499*500* @enum:501* FT_Orientation502*503* @description:504* A list of values used to describe an outline's contour orientation.505*506* The TrueType and PostScript specifications use different conventions507* to determine whether outline contours should be filled or unfilled.508*509* @values:510* FT_ORIENTATION_TRUETYPE ::511* According to the TrueType specification, clockwise contours must be512* filled, and counter-clockwise ones must be unfilled.513*514* FT_ORIENTATION_POSTSCRIPT ::515* According to the PostScript specification, counter-clockwise516* contours must be filled, and clockwise ones must be unfilled.517*518* FT_ORIENTATION_FILL_RIGHT ::519* This is identical to @FT_ORIENTATION_TRUETYPE, but is used to520* remember that in TrueType, everything that is to the right of the521* drawing direction of a contour must be filled.522*523* FT_ORIENTATION_FILL_LEFT ::524* This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to525* remember that in PostScript, everything that is to the left of the526* drawing direction of a contour must be filled.527*528* FT_ORIENTATION_NONE ::529* The orientation cannot be determined. That is, different parts of530* the glyph have different orientation.531*532*/533typedef enum FT_Orientation_534{535FT_ORIENTATION_TRUETYPE = 0,536FT_ORIENTATION_POSTSCRIPT = 1,537FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE,538FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT,539FT_ORIENTATION_NONE540541} FT_Orientation;542543544/**************************************************************************545*546* @function:547* FT_Outline_Get_Orientation548*549* @description:550* This function analyzes a glyph outline and tries to compute its fill551* orientation (see @FT_Orientation). This is done by integrating the552* total area covered by the outline. The positive integral corresponds553* to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT is554* returned. The negative integral corresponds to the counter-clockwise555* orientation and @FT_ORIENTATION_TRUETYPE is returned.556*557* Note that this will return @FT_ORIENTATION_TRUETYPE for empty558* outlines.559*560* @input:561* outline ::562* A handle to the source outline.563*564* @return:565* The orientation.566*567*/568FT_EXPORT( FT_Orientation )569FT_Outline_Get_Orientation( FT_Outline* outline );570571572/* */573574575FT_END_HEADER576577#endif /* FTOUTLN_H_ */578579580/* END */581582583/* Local Variables: */584/* coding: utf-8 */585/* End: */586587588