Logo Search packages:      
Sourcecode: inkscape version File versions

Inkscape::Text::Layout Class Reference

#include <Layout-TNG.h>

List of all members.

Detailed Description

Generates the layout for either wrapped or non-wrapped text and stores the result.

Use this class for all your text output needs. It takes text with formatting markup as input and turns that into the glyphs and their necessary positions. It stores the glyphs internally, but maintains enough information to both retrieve your own rendering information if you wish and to perform visual text editing where the output refers back to where it came from.


  1. Construct
  2. Set the text using appendText() and appendControlCode()
  3. If you want text wrapping, call appendWrapShape() a few times
  4. Call calculateFlow()
  5. You can go several directions from here, but the most interesting things start with creating a Layout::iterator with begin() or end().

Terminology, in descending order of size:

Other terminology:


Definition at line 140 of file Layout-TNG.h.

Public Types

enum  Alignment { LEFT, CENTER, RIGHT, FULL }

Public Member Functions

Methods for describing the text you want to flow, its style, and the shapes to flow in to.

void appendControlCode (TextControlCode code, void *source_cookie, double width=0.0, double ascent=0.0, double descent=0.0)
void appendText (Glib::ustring const &text, SPStyle *style, void *source_cookie, OptionalTextTagAttrs const *optional_attributes=NULL, unsigned optional_attributes_offset=0)
void appendText (Glib::ustring const &text, SPStyle *style, void *source_cookie, OptionalTextTagAttrs const *optional_attributes, unsigned optional_attributes_offset, Glib::ustring::const_iterator text_begin, Glib::ustring::const_iterator text_end)
void appendWrapShape (Shape const *shape, DisplayAlign display_align=DISPLAY_ALIGN_BEFORE)
void clear ()
bool inputExists () const
Output (Iterators)
Methods for operating with the Layout::iterator class. The method names ending with 'Index' return 0-based offsets of the number of items since the beginning of the flow.

iterator begin () const
NR::Point characterAnchorPoint (iterator const &it) const
int characterAt (iterator const &it) const
NR::Rect characterBoundingBox (iterator const &it, double *rotation=NULL) const
iterator charIndexToIterator (int char_index) const
NR::Point chunkAnchorPoint (iterator const &it) const
std::vector< NR::PointcreateSelectionShape (iterator const &it_start, iterator const &it_end, NR::Matrix const &transform) const
iterator end () const
iterator getLetterAt (NR::Point &point) const
iterator getLetterAt (double x, double y) const
iterator getNearestCursorPositionTo (NR::Point &point) const
iterator getNearestCursorPositionTo (double x, double y) const
void getSourceOfCharacter (iterator const &it, void **source_cookie, Glib::ustring::iterator *text_iterator=NULL) const
NR::Maybe< NR::RectglyphBoundingBox (iterator const &it, double *rotation) const
bool isCursorPosition (iterator const &it) const
bool isEndOfSentence (iterator const &it) const
bool isEndOfWord (iterator const &it) const
bool isStartOfSentence (iterator const &it) const
bool isStartOfWord (iterator const &it) const
bool isWhitespace (iterator const &it) const
int iteratorToCharIndex (iterator const &it) const
unsigned lineIndex (iterator const &it) const
Alignment paragraphAlignment (iterator const &it) const
unsigned paragraphIndex (iterator const &it) const
void queryCursorShape (iterator const &it, NR::Point *position, double *height, double *rotation) const
unsigned shapeIndex (iterator const &it) const
void simulateLayoutUsingKerning (iterator const &from, iterator const &to, OptionalTextTagAttrs *result) const
iterator sourceToIterator (void *source_cookie) const
iterator sourceToIterator (void *source_cookie, Glib::ustring::const_iterator text_iterator) const
void validateIterator (iterator *it) const
The method to do the actual work of converting text into glyphs.

bool calculateFlow ()
Methods for reading and interpreting the output glyphs. See also Layout::iterator.

SPCurveconvertToCurves () const
SPCurveconvertToCurves (iterator const &from_glyph, iterator const &to_glyph) const
Glib::ustring dumpAsText () const
void fitToPathAlign (SVGLength const &startOffset, Path const &path)
void getBoundingBox (NRRect *bounding_box, NR::Matrix const &transform, int start=-1, int length=-1) const
bool outputExists () const
void print (SPPrintContext *ctx, NRRect const *pbox, NRRect const *dbox, NRRect const *bbox, NRMatrix const &ctm) const
void show (NRArenaGroup *in_arena, NRRect const *paintbox) const
void transform (NR::Matrix const &transform)

Static Public Attributes

static const double LINE_HEIGHT_NORMAL = 1.25

Private Types

enum  InputStreamItemType { TEXT_SOURCE, CONTROL_CODE }

Private Member Functions

Direction _blockProgression () const
void _calculateCursorShapeForEmpty ()
void _clearInputObjects ()
void _clearOutputObjects ()
iterator _cursorXOnLineToIterator (unsigned line_index, double local_x) const
double _getChunkWidth (unsigned chunk_index) const
void _getGlyphTransformMatrix (int glyph_index, NRMatrix *matrix) const
unsigned _lineToCharacter (unsigned line_index) const
unsigned _lineToSpan (unsigned line_index) const
unsigned _sourceToCharacter (unsigned source_index) const
unsigned _spanToCharacter (unsigned span_index) const
 EMIT_PREDICATE (PredicateSourceToCharacter, Character, _flow->_spans[object.in_span].in_input_stream_item)
 EMIT_PREDICATE (PredicateSpanToCharacter, Character, object.in_span)
 EMIT_PREDICATE (PredicateLineToCharacter, Character, _flow->_chunks[_flow->_spans[object.in_span].in_chunk].in_line)
 EMIT_PREDICATE (PredicateLineToSpan, Span, _flow->_chunks[object.in_chunk].in_line)

Static Private Member Functions

static void _copyInputVector (std::vector< SVGLength > const &input_vector, unsigned input_offset, std::vector< SVGLength > *output_vector, size_t max_length)
static bool _directions_are_orthogonal (Direction d1, Direction d2)
static int _enum_converter (int input, EnumConversionItem const *conversion_table, unsigned conversion_table_size)

Private Attributes

std::vector< Character > _characters
std::vector< Chunk > _chunks
std::vector< Glyph > _glyphs
std::vector< InputStreamItem * > _input_stream
std::vector< InputWrapShape > _input_wrap_shapes
std::vector< Line > _lines
std::vector< Paragraph > _paragraphs
Path const * _path_fitted
std::vector< Span > _spans

Static Private Attributes

static const gunichar UNICODE_SOFT_HYPHEN = 0x00AD


class Calculator
class iterator


class  Calculator
 private to Layout. Does the real work of text flowing. More...
struct  Character
struct  Chunk
struct  CursorShape
struct  EnumConversionItem
 see _enum_converter() More...
struct  Glyph
class  InfiniteScanlineMaker
 private to Layout. Generates infinite scanlines for when you don't want wrapping More...
class  InputStreamControlCode
class  InputStreamItem
class  InputStreamTextSource
struct  InputWrapShape
class  iterator
 Holds a position within the glyph output of Layout. More...
struct  Line
struct  LineHeight
 it's useful for this to be public so that ScanlineMaker can use it More...
struct  OptionalTextTagAttrs
struct  Paragraph
class  ScanlineMaker
 private to Layout. Generates lists of chunks within a shape. More...
class  ShapeScanlineMaker
 private to Layout. Generates scanlines inside an arbitrary shape More...
struct  Span

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index