TessType objects describe a specific typeface, pointsize and resolution to a TessSurface object. TessStack the smallest resultant surface accounting for all surfaces in the stack. .. for arbitrary layering. Once constructed, the surfaces comprising a stack can continue to be modified and snapshot independently. Class TessSurface ----------------- Description: @@ alpha = 0; fully transparent. alpha = 255; fully opaque. Methods: TessSurface (int width, int height) Creates a surface of dimensions ``width'' and ``height''. All pixels are initialized black (0, 0, 0) and fully transparent (alpha = 0). TessSurface (TessReader * reader) Creates a surface of dimensions and data specificed by ``reader''. ``reader'' may be discarded immediately after calling this method. get_size (int& width, int& height) Sets ``width'' and ``height'' to the surface's current dimensions. set_alpha_pixel (int x, int y, ccomp alpha) Sets the pixel (x, y) to ``alpha'', with the current drawing color. This is a convenience function for routines that are specifying center fills and anti-aliased edges; all TessSurface drawing methods use it. Setting pixels outside the logical surface is a safe null operation. set_pixel (int x, int y, Pixel& pixel) Sets the pixel (x, y) to the color and alpha of ``pixel''. Setting pixels outside the logical surface is a safe null operation. get_pixel (int x, int y, Pixel& pixel) Sets ``pixel'' the color and alpha of pixel (x, y). Asking for a pixel outside the logical surface is not valid. get_pma_pixel (int x, int y, Pixel& pixel) Sets ``pixel'' the color and alpha of pixel (x, y), without converting from the internal representation, whose RGB components are pre-multiplied by the pixel's alpha value. Asking for a pixel outside the logical surface is not valid. set_type (TessType * type) Sets the surface's current type to ``type''. set_type_alignment (TessAlignment alignment) Sets the alignment Tess will use in drawing strings. ``alignment'' may be one of three following values: TessSurface::Left, TessSurface::Center or TessSurface::Right. set_type_inclination (int angle) Sets the current drawing angle for type. Positive ``angle'', in degrees, describes a counter-clockwise motion from 3 o'clock. Default is 0. Note: UNIMPLEMENTED. set_draw_width (int width) Sets the pixel width of the "pen" used in drawing curves. set_draw_color (ccomp red, ccomp green, ccomp blue) Sets this surface's drawing color to specified, irrespective of alpha. set_draw_style (TessDrawStyle style) ``style'' determines how pixels are applied to the surface. In Replace mode, @@ In Blend mode, a new foreground pixel obscures the background pixel by the color set and its transparency (alpha) setting. Specifically, a Porter-Duff "over" compositing operation is performed, a linear interpolation from the foreground to background pixel. ``style'' may be either TessSurface::Replace or TessSurface::Blend. Default is the latter. @@is this correct? draw_string (int x, int y, char * string) Draws a string at (x, y), in the current type and draw color. This is affected by inclination (not yet), spacing and alignment settings (see above). draw_uc_string (int x, int y, short * string) Same as above, but operates on 16-bit Unicode characters. draw_line (int x1, int y1, int x2, int y2) Draws a single-pixel width line from (x1, y1) to (x2, y2), inclusive, in the current drawing color. draw_bezier (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) Draws a Bezier curve from (x1, y1) to (x4, y4), in the current drawing color, determined by control points (x2, y2) and (x3, y3). draw_rect (int x, int y, int width, int height) Draws a rectangle from (x, y) with dimensions ``width'' and ``height'', in the current drawing color. draw_filled_rect (int x, int y, int width, int height) Draws an opaque, filled rectangle from (x, y) with dimensions ``width'' and ``height'' in the current drawing color. fade (int percent, int x, int y, int width, int height) Uniformly reduces the alpha component of a rectangle at (x, y) with dimensions ``width'' and ``height'', by ``percent''. This has the effect of "fading" the region. blur (int radius, int x, int y, int width, int height) Performs a simple neighborhood average, of ``radius'' distance, on every pixel in the rectangle at (x, y) with dimensions ``width'' and ``height''. This has the effect of "blurring" the region. ``radius'' must be greater than zero. flatten (ccomp red, ccomp green, ccomp blue) Composites every pixel, in-place, against an imaginary, opaque background, colored as specified. This is used to conveniently resolve alpha images to a format with no alpha support, without building a surface stack. int write (TessWriter * writer) Writes the current surface using a TessWriter descendent. Class TessStack --------------- Description: Methods: add_surface (TessSurface * surface, int x, int y) Adds a surface to the top (foremost to viewer) of the stack at (x, y) in logical space. TessSurface * make_composite () Returns a resultant surface that is a composite ... smallest that ... Class TessType -------------- Description: Its public methods are normally called indirectly with a TessSurface object. Methods: TessType (char * ttpath, int pointsize, int dpi_x, int dpi_y) Initializes a TessType object to the specified typeface, pointsize, and resolution. The font search using ``ttpath'' is as follows. a) The explicit path is tried. b) The string is appended to common fonts paths included at compile-time (usually "/usr/local/lib/ttfonts:."). c) The string is appended to paths in environment variable ``TTFONTS''. bool is_valid () Returns the status of the initialized object. This should be checked directly after object construction. int get_ascent () Returns the ascent, a horizontal measure from glyph top to baseline. int get_descent () Returns the descent, a horizontal measure from baseline down to next logical line. set_spacing (int spacing) Sets the track-level kerning (or intra-character spacing.) Default is 0. Positive and negative values are valid. int get_string_width (char * string) Returns the pixel width of ``string'', adjusted for track- and pair-kerning. int get_uc_string_width (short * string) Same as above, but operates on 16-bit Unicode characters. render_glyph (TessSurface * surface, int x, int y, int unicode) Renders a glyph, ``unicode'', at (x, y) on ``surface'', where ``x'' determines the left edge of the glyph's bounding box and, ``y'', the baseline. int get_glyph_width (int unicode) Returns the advance width of glyph ``unicode'', adjusted for track- kerning. int get_pair_advance (int unicode_left, int unicode_right); Returns the advance width of glyph ``unicode_left'', adjusted for track-kerning, and pair-kerning with ``unicode_right''. Class TessPPMReader ------------------- Description: Reads a raw-style (P6) PPM file, with an artificial, constant alpha channel. Except for construction, its public methods are not normally called directly. Methods: TessPPMReader (char * filepath, ccomp alpha = 255) Reads a PPM file from ``filepath'', with a artificial, constant ``alpha'' at each pixel. ``alpha'' defaults to opaque if unspecified. Class TessPPMWriter ------------------- Description: Writes a binary-style (P6) PPM file from a TessSurface, ignoring the alpha channel. Once initialized, a TessSurface may write through this writer repeatedly. Except for construction, its public methods are not normally called directly. Methods: TessPPMWriter (char * filepath) Directed by a TessSurface, writes a PPM file to ``filepath''. Class TessPAMReader ------------------- Description: Reads a raw-style (P7) PAM file. PAM files look like PPM files, but for their magic number and 32-bit rgba tuples. Except for construction, its public methods are not normally called directly. Methods: TessPAMReader (char * filepath) Reads a PAM file from ``filepath''. Class TessPPMWriter ------------------- Description: Writes a binary-style (P7) PAM file from a TessSurface. Once initialized, a TessSurface may write through this writer repeatedly. Except for construction, its public methods are not normally called directly. Methods: TessPAMWriter (char * filepath) Directed by a TessSurface, writes a PAM file to ``filepath''.