/***************************************************************************/ /* */ /* ftdriver.h */ /* */ /* FreeType driver interface (specification). */ /* */ /* Copyright 1996-2000 by */ /* 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. */ /* */ /***************************************************************************/ #ifndef FTDRIVER_H #define FTDRIVER_H #include /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /**** ****/ /**** ****/ /**** D R I V E R S ****/ /**** ****/ /**** ****/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /* */ /* */ /* FTDriver_initDriver */ /* */ /* */ /* A driver method used to create a new driver object for a given */ /* format. */ /* */ /* */ /* driver :: A handle to the `new' driver object. The fields */ /* `library', `system', and `lock' are already set when the */ /* base layer calls this method. */ /* */ /* */ /* FreeType error code. 0 means success. */ /* */ typedef FT_Error (*FTDriver_initDriver)( FT_Driver driver ); /*************************************************************************/ /* */ /* */ /* FTDriver_doneDriver */ /* */ /* */ /* A driver method used to finalize a given driver object. Note that */ /* all faces and resources for this driver have been released before */ /* this call, and that this function should NOT destroy the driver */ /* object. */ /* */ /* */ /* driver :: A handle to target driver object. */ /* */ /* */ /* FreeType error code. 0 means success. */ /* */ typedef FT_Error (*FTDriver_doneDriver)( FT_Driver driver ); typedef void (*FTDriver_Interface)( void ); /*************************************************************************/ /* */ /* */ /* FTDriver_getInterface */ /* */ /* */ /* Each driver can provide one or more extensions to the base */ /* FreeType API. These can be used to access format specific */ /* features (e.g., all TrueType/OpenType resources share a common */ /* file structure and common tables which can be accessed through the */ /* `sfnt' interface), or more simply generic ones (e.g., the */ /* `postscript names' interface which can be used to retrieve the */ /* PostScript name of a given glyph index). */ /* */ /* */ /* driver :: A handle to a driver object. */ /* */ /* */ /* interface :: A string designing the interface. Examples are */ /* `sfnt', `post_names', `charmaps', etc. */ /* */ /* */ /* A typeless pointer to the extension's interface (normally a table */ /* of function pointers). Returns NULL if the requested extension */ /* isn't available (i.e., wasn't compiled in the driver at build */ /* time). */ /* */ typedef FTDriver_Interface (*FTDriver_getInterface) ( FT_Driver driver, const FT_String* interface ); /*************************************************************************/ /* */ /* */ /* FT_FormatInterface */ /* */ /* */ /* A driver interface field whose value is a driver-specific */ /* interface method table. This table contains entry points to */ /* various functions that are strictly related to the driver's */ /* format. */ /* */ typedef void* FT_FormatInterface; /*************************************************************************/ /* */ /* */ /* FT_Attach_Reader */ /* */ /* */ /* This function is associated to the `attach_file' driver-specific */ /* interface. It is used to read additional data for a given face */ /* from another input stream/file. For example, it is used to */ /* attach a Type 1 AFM file to a given Type 1 face. */ /* */ typedef FT_Error (*FT_Attach_Reader)( FT_Face face, FT_Stream stream ); /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /**** ****/ /**** ****/ /**** F A C E S ****/ /**** ****/ /**** ****/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /* */ /* */ /* FTDriver_initFace */ /* */ /* */ /* A driver method used to initialize a new face object. The object */ /* must be created by the caller. */ /* */ /* */ /* stream :: The input stream. */ /* face :: A handle to the new target face. */ /* */ /* */ /* typeface_index :: The face index in the font resource. Used to */ /* access individual faces in collections. */ /* */ /* num_params :: number of optional generic parameters */ /* parameters :: table of generic parameters */ /* */ /* */ /* FreeType error code. 0 means success. */ /* */ /* */ /* The `typeface_index' parameter field will be set to -1 if the */ /* engine only wants to test the format of the resource. This means */ /* that font drivers should simply check the font format, then return */ /* immediately with an error code of 0 (meaning success). The field */ /* `num_faces' should be set. */ /* */ /* The generic parameters are a way to pass additional data to a */ /* given font driver when creating a new face object. In most cases */ /* they will be simply ignored.. */ /* */ /* FTDriver_doneFace() will be called subsequently, whatever the */ /* result was. */ /* */ typedef FT_Error (*FTDriver_initFace)( FT_Stream stream, FT_Face face, FT_Int typeface_index, FT_Int num_params, FT_Parameter* parameters ); /*************************************************************************/ /* */ /* */ /* FTDriver_doneFace */ /* */ /* */ /* A driver method used to finalize a given face object. This */ /* function does NOT destroy the object, that is the responsibility */ /* of the caller. */ /* */ /* */ /* face :: A handle to the target face object. */ /* */ /* */ /* FreeType error code. 0 means success. */ /* */ typedef void (*FTDriver_doneFace)( FT_Face face ); /*************************************************************************/ /* */ /* */ /* FTDriver_getKerning */ /* */ /* */ /* A driver method used to return the kerning vector between two */ /* glyphs of the same face. */ /* */ /* */ /* face :: A handle to the source face object. */ /* left_glyph :: The index of the left glyph in the kern pair. */ /* right_glyph :: The index of the right glyph in the kern pair. */ /* */ /* */ /* kerning :: A pointer to the kerning vector. This is in font */ /* units for scalable formats, and in pixels for */ /* fixed-sizes formats. */ /* */ /* */ /* FreeType error code. 0 means success. */ /* */ /* */ /* Only horizontal layouts (left-to-right & right-to-left) are */ /* supported by this method. Other layouts, or more sophisticated */ /* kernings are out of the scope of this method (the basic driver */ /* interface is meant to be simple). */ /* */ /* They can be implemented by format-specific interfaces. */ /* */ typedef FT_Error (*FTDriver_getKerning)( FT_Face face, FT_UInt left_glyph, FT_UInt right_glyph, FT_Vector* kerning ); /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /**** ****/ /**** ****/ /**** S I Z E S ****/ /**** ****/ /**** ****/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /* */ /* */ /* FTDriver_initSize */ /* */ /* */ /* A driver method used to initialize a new size object. The object */ /* must be created by the caller. */ /* */ /* */ /* size :: A handle to the new size object. */ /* */ /* */ /* FreeType error code. 0 means success. */ /* */ /* */ /* This function should return an error if the face's format isn't */ /* scalable. */ /* */ typedef FT_Error (*FTDriver_initSize)( FT_Size size ); /*************************************************************************/ /* */ /* */ /* FTDriver_setCharSizes */ /* */ /* */ /* A driver method used to reset a size's character sizes (horizontal */ /* and vertical) expressed in fractional points. */ /* */ /* */ /* size :: A handle to the target size object. */ /* */ /* */ /* char_width :: The character width expressed in 26.6 */ /* fractional points. */ /* char_height :: The character height expressed in 26.6 */ /* fractional points. */ /* horz_resolution :: The horizontal resolution. */ /* vert_resolution :: The vertical resolution. */ /* */ /* */ /* FreeType error code. 0 means success. */ /* */ /* */ /* This function should always FAIL if the face format isn't */ /* scalable! */ /* */ typedef FT_Error (*FTDriver_setCharSizes)( FT_Size size, FT_F26Dot6 char_width, FT_F26Dot6 char_height, FT_UInt horz_resolution, FT_UInt vert_resolution ); /*************************************************************************/ /* */ /* */ /* FTDriver_setPixelSizes */ /* */ /* */ /* A driver method used to reset a size's character sizes (horizontal */ /* and vertical) expressed in integer pixels. */ /* */ /* */ /* size :: A handle to the target size object. */ /* */ /* */ /* pixel_width :: The character width expressed in 26.6 fractional */ /* pixels. */ /* pixel_height :: The character height expressed in 26.6 fractional */ /* pixels. */ /* */ /* */ /* FreeType error code. 0 means success. */ /* */ /* */ /* This function should work with all kinds of `size' objects, either */ /* fixed or scalable ones. */ /* */ typedef FT_Error (*FTDriver_setPixelSizes)( FT_Size size, FT_UInt pixel_width, FT_UInt pixel_height ); /*************************************************************************/ /* */ /* */ /* FTDriver_doneSize */ /* */ /* */ /* A driver method used to finalize a given size object. This method */ /* does NOT destroy the object; this is the responsibility of the */ /* caller. */ /* */ /* */ /* size :: A handle to the target size object. */ /* */ typedef void (*FTDriver_doneSize)( FT_Size size ); /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /**** ****/ /**** ****/ /**** G L Y P H S L O T S ****/ /**** ****/ /**** ****/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /* */ /* */ /* FTDriver_initGlyphSlot */ /* */ /* */ /* A driver method used to initialize a new glyph slot object. The */ /* object must be created by the caller. The glyph slot is a */ /* container where a single glyph can be loaded, either in outline or */ /* bitmap format. */ /* */ /* */ /* slot :: A handle to the new glyph slot object. */ /* */ /* */ /* FreeType error code. 0 means success. */ /* */ typedef FT_Error (*FTDriver_initGlyphSlot)( FT_GlyphSlot slot ); /*************************************************************************/ /* */ /* */ /* FTDriver_doneGlyphSlot */ /* */ /* */ /* A driver method used to finalize a given glyph slot. The object */ /* is not destroyed by this function. */ /* */ /* */ /* slot :: A handle to the new glyph slot object. */ /* */ typedef void (*FTDriver_doneGlyphSlot)( FT_GlyphSlot slot ); /*************************************************************************/ /* */ /* */ /* FTDriver_loadGlyph */ /* */ /* */ /* A driver method used to load a glyph within a given glyph slot. */ /* */ /* */ /* slot :: A handle to target slot object where the glyph will */ /* be loaded. */ /* size :: A handle to the source face size at which the glyph */ /* must be scaled/loaded. */ /* */ /* */ /* glyph_index :: The index of the glyph in the font file. */ /* load_flags :: A flag indicating what to load for this glyph. The */ /* FTLOAD_??? constants can be used to control the */ /* glyph loading process (e.g., whether the outline */ /* should be scaled, whether to load bitmaps or not, */ /* whether to hint the outline, etc). */ /* */ /* */ /* FreeType error code. 0 means success. */ /* */ typedef FT_Error (*FTDriver_loadGlyph)( FT_GlyphSlot slot, FT_Size size, FT_UInt glyph_index, FT_Int load_flags ); /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /**** ****/ /**** ****/ /**** C H A R A C T E R M A P S ****/ /**** ****/ /**** ****/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /* */ /* */ /* FTDriver_getCharIndex */ /* */ /* */ /* Uses a charmap to return a given character code's glyph index. */ /* */ /* */ /* charmap :: A handle to the source charmap object. */ /* charcode :: The character code. */ /* */ /* */ /* The glyph index. 0 means `undefined character code'. */ /* */ typedef FT_UInt (*FTDriver_getCharIndex)( FT_CharMap charmap, FT_Long charcode ); /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /**** ****/ /**** ****/ /**** I N T E R F A C E ****/ /**** ****/ /**** ****/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /* */ /* */ /* FT_DriverInterface */ /* */ /* */ /* A structure which holds a font driver's basic interface used by */ /* the high-level parts of FreeType (or other applications). */ /* */ /* Most scalable drivers provide a specialized interface to access */ /* format specific features. It can be retrieved with a call to */ /* `get_format_interface()', and should be defined in each font */ /* driver header (e.g., ttdriver.h, t1driver.h, etc). */ /* */ /* All fields are function pointers. */ /* */ /* */ /* driver_object_size :: The size in bytes of a single driver */ /* object. */ /* face_object_size :: The size in bytes of a single face object. */ /* size_object_size :: The size in bytes of a single size object. */ /* slot_object_size :: The size in bytes of a single glyph slot */ /* object. */ /* */ /* driver_name :: A string to describe the driver to the */ /* system. It doesn't necessarily describe */ /* in detail all the font formats the driver */ /* may support. */ /* driver_version :: The driver version number. Starts at 1. */ /* driver_requires :: The FreeType major version this driver is */ /* written for. This number should be equal */ /* to or greater than 2! */ /* */ /* format_interface :: A pointer to the driver's format-specific */ /* interface. */ /* */ /* init_driver :: Used to initialize a given driver object. */ /* done_driver :: Used to finalize and destroy a given */ /* driver object. */ /* get_interface :: Returns an interface for a given driver */ /* extension. */ /* */ /* init_face :: Initializes a given face object. */ /* done_face :: Discards a face object, as well as all */ /* child objects (sizes, charmaps, glyph */ /* slots). */ /* get_kerning :: Returns the kerning vector corresponding */ /* to a pair of glyphs, expressed in unscaled */ /* font units. */ /* */ /* init_size :: Initializes a given size object. */ /* done_size :: Finalizes a given size object. */ /* set_size_char_sizes :: Resets a scalable size object's character */ /* size. */ /* set_pixel_sizes :: Resets a face size object's pixel */ /* dimensions. Applies to both scalable and */ /* fixed faces. */ /* */ /* init_glyph_slot :: Initializes a given glyph slot object. */ /* done_glyph_slot :: Finalizes a given glyph slot. */ /* load_glyph :: Loads a given glyph into a given slot. */ /* */ /* get_char_index :: Returns the glyph index for a given */ /* charmap. */ /* */ typedef struct FT_DriverInterface_ { FT_Int driver_object_size; FT_Int face_object_size; FT_Int size_object_size; FT_Int slot_object_size; FT_String* driver_name; FT_Int driver_version; FT_Int driver_requires; void* format_interface; FTDriver_initDriver init_driver; FTDriver_doneDriver done_driver; FTDriver_getInterface get_interface; FTDriver_initFace init_face; FTDriver_doneFace done_face; FTDriver_getKerning get_kerning; FTDriver_initSize init_size; FTDriver_doneSize done_size; FTDriver_setCharSizes set_char_sizes; FTDriver_setPixelSizes set_pixel_sizes; FTDriver_initGlyphSlot init_glyph_slot; FTDriver_doneGlyphSlot done_glyph_slot; FTDriver_loadGlyph load_glyph; FTDriver_getCharIndex get_char_index; } FT_DriverInterface; #endif /* FTDRIVER_H */ /* END */