LASi: LASi::PostscriptDocument Class Reference

LASi

Classes | Public Member Functions | Protected Types | Protected Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
LASi::PostscriptDocument Class Reference

Composes Postscript document as three separate and independant streams for header, body and footer. More...

`#include <LASi.h>`

## Classes
class | GlyphId
| For internal use only. More...
class | write_glyph_routine_to_stream
| For internal use only. More...

## Public Member Functions
| PostscriptDocument ()
| ~PostscriptDocument ()
void | setFont (const char *const family="sans", LASi::FontStyle=LASi::NORMAL_STYLE, LASi::FontWeight=LASi::NORMAL_WEIGHT, LASi::FontVariant=LASi::NORMAL_VARIANT, LASi::FontStretch=LASi::NORMAL_STRETCH)
| Sets the font that all subsequent text written to bodyStream() or footerStream() will be rendered with. More...
void | setFontSize (const double size)
| Sets the font size, in points, that all subsequent text written to bodyStream() or footerStream() will be rendered with. More...
std::ostringstream & | osHeader ()
| Returns stream for Postscript header. More...
oPostscriptStream & | osBody ()
| Returns stream for Postscript body. More...
oPostscriptStream & | osFooter ()
| Returns stream for Postscript footer. More...
void | write (std::ostream &os, double llx=0, double lly=0, double urx=0, double ury=0)
| Closes all streams and writes completed Postscript document to os. More...
void | get_dimensions (const char *s, double *lineSpacing, double *xAdvance=NULL, double *yMin=NULL, double *yMax=NULL)
| Return string dimensions: lineSpacing: inter-line spacing xAdvance: width of the string yMin: y-coordinate bounding the lowest descender, Indic under-consonantal vowel, etc. More...
void | get_dimensions (std::string s, double *lineSpacing, double *xAdvance=NULL, double *yMin=NULL, double *yMax=NULL)
| Returns the line spacing, x-advance, y-minimum and y-maximum based on the current font face and font size. More...

## Protected Types
typedef std::map< GlyphId, FreetypeGlyphMgr > | GlyphMap
| Maps glyph routine name to FT_Glyph instance. More...
typedef void(PostscriptDocument::* | GLYPH_FUNC) (const GlyphMap::value_type &, void *contextData)
| Pointer to a function that takes a reference to a glyph and to x and y coordinates. More...

## Protected Member Functions
void | invoke_glyph_routine (const GlyphMap::value_type &, void *contextData)
| Insert a Postscript glyph_routine call into output stream (contextData). More...
void | accrue_dimensions (const GlyphMap::value_type &, void *contextData)
| Add the next glyphs dimensions to the bounding box (contextData). More...
FT_Error | PangoItem_do (const char *s, PangoItem *const pItem, const GLYPH_FUNC func, void *contextData, bool applyOffset=false)
| For a decomposed PangoItem (that can be rendered with a single font face) that is generated by for_each_glyph_do, apply GLYPH_FUNC to each glyph in that PangoItem. More...
void | for_each_glyph_do (const std::string &s, const GLYPH_FUNC func, void *contextData, bool applyOffset=false)
| Decomposes string into glyphs and applies GLYPH_FUNC to each glyph. More...
PangoContext * | pangoContext () const
std::string | glyphProcName () const
double | getFontSize ()

## Private Attributes
GlyphMap | _glyphMap
ContextMgr * | _pContextMgr
double | _fontSize
std::ostringstream | _osHeader
oPostscriptStream | _osBody
oPostscriptStream | _osFooter

## Static Private Attributes
static const unsigned int | DRAWING_SCALE = PANGO_SCALE

## Friends
class | write_glyph_routine_to_stream
class | show

## Detailed Description

Composes Postscript document as three separate and independant streams for header, body and footer.

Body and footer streams respond to LASi::show applicator which generates Postscript commands to display a string by using glyph routines instead of a Postscript font.

## Member Typedef Documentation

## ◆ GLYPH_FUNC

typedef void(PostscriptDocument::* LASi::PostscriptDocument::GLYPH_FUNC) (const GlyphMap::value_type &, void *contextData)
| protected

Pointer to a function that takes a reference to a glyph and to x and y coordinates.

May return new x and y coordinates.

## ◆ GlyphMap

typedef std::map<GlyphId, FreetypeGlyphMgr> LASi::PostscriptDocument::GlyphMap
| protected

Maps glyph routine name to FT_Glyph instance.

## Constructor & Destructor Documentation

## ◆ PostscriptDocument()

PostscriptDocument::PostscriptDocument | ( |  | ) |

## ◆ ~PostscriptDocument()

PostscriptDocument::~PostscriptDocument | ( |  | ) |

References _pContextMgr.

## Member Function Documentation

## ◆ accrue_dimensions()

void PostscriptDocument::accrue_dimensions | ( | const GlyphMap::value_type & | ,
|  | void * | contextData
| ) |  |
| protected

Add the next glyphs dimensions to the bounding box (contextData).

If the advance is in the x direction (the usual case), the box grows in the x direction, yMax becomes the height of the tallest character, and yMin the descent of the most descending character.

Parameters

  mapval | std::pair<GlyphId, FreetypeGlyphMgr>
  contextData | std::pair<double, double>, the x and y dimensions

References StringDimensions::accrueXAdvance(), StringDimensions::setYMax(), and StringDimensions::setYMin().

Referenced by get_dimensions().

## ◆ for_each_glyph_do()

void PostscriptDocument::for_each_glyph_do | ( | const std::string & | s,
|  | const GLYPH_FUNC | func,
|  | void * | contextData,
|  | bool | applyOffset = `false`
| ) |  |
| protected

Decomposes string into glyphs and applies GLYPH_FUNC to each glyph.

References evalReturnCode(), pangoContext(), and PangoItem_do().

Referenced by LASi::show::apply(), and get_dimensions().

## ◆ get_dimensions() [1/2]

void PostscriptDocument::get_dimensions | ( | const char * | s,
|  | double * | lineSpacing,
|  | double * | xAdvance = `NULL`,
|  | double * | yMin = `NULL`,
|  | double * | yMax = `NULL`
| ) |  |

Return string dimensions: lineSpacing: inter-line spacing xAdvance: width of the string yMin: y-coordinate bounding the lowest descender, Indic under-consonantal vowel, etc.

Returns the line spacing, x-advance, y-minimum and y-maximum based on the current font face and font size.

yMax: y-coordinate bounding the highest ascender, diacritic, Indic over-letter vowel, etc.

A bounding box around the text string, s, can be constructed from the xAdvance, yMinimum, and yMaximum. yMinimum tells you the descent from the baseline. yMaximum tells you the ascent from the baseline. The line spacing provides an inter-line spacing for multi-line text layout.

This version accepts a const C-style character string.

References _fontSize, accrue_dimensions(), DRAWING_SCALE, for_each_glyph_do(), StringDimensions::getLineSpacing(), StringDimensions::getXAdvance(), StringDimensions::getYMax(), and StringDimensions::getYMin().

Referenced by get_dimensions().

## ◆ get_dimensions() [2/2]

void PostscriptDocument::get_dimensions | ( | std::string | s,
|  | double * | lineSpacing,
|  | double * | xAdvance = `NULL`,
|  | double * | yMin = `NULL`,
|  | double * | yMax = `NULL`
| ) |  |

Returns the line spacing, x-advance, y-minimum and y-maximum based on the current font face and font size.

A bounding box around the text string, s, can be constructed from the xAdvance, yMinimum, and yMaximum. yMinimum tells you the descent from the baseline. yMaximum tells you the ascent from the baseline. The line spacing provides an inter-line spacing for multi-line text layout.

This version accepts an STL standard string class string.

References get_dimensions().

## ◆ getFontSize()

double LASi::PostscriptDocument::getFontSize | ( |  | ) |
| inlineprotected

Returns
  font size in points (1/72 in.)

Referenced by invoke_glyph_routine().

## ◆ glyphProcName()

std::string LASi::PostscriptDocument::glyphProcName | ( |  | ) | const
| protected

Returns
  name of Postscript glyph routine

## ◆ invoke_glyph_routine()

void PostscriptDocument::invoke_glyph_routine | ( | const GlyphMap::value_type & | ,
|  | void * | contextData
| ) |  |
| protected

Insert a Postscript glyph_routine call into output stream (contextData).

References getFontSize(), and LASi::PostscriptDocument::GlyphId::str().

Referenced by LASi::show::apply().

## ◆ osBody()

oPostscriptStream& LASi::PostscriptDocument::osBody | ( |  | ) |
| inline

Returns stream for Postscript body.

## ◆ osFooter()

oPostscriptStream& LASi::PostscriptDocument::osFooter | ( |  | ) |
| inline

Returns stream for Postscript footer.

## ◆ osHeader()

std::ostringstream& LASi::PostscriptDocument::osHeader | ( |  | ) |
| inline

Returns stream for Postscript header.

## ◆ pangoContext()

PangoContext * PostscriptDocument::pangoContext | ( |  | ) | const
| inlineprotected

Referenced by for_each_glyph_do().

## ◆ PangoItem_do()

FT_Error PostscriptDocument::PangoItem_do | ( | const char * | s,
|  | PangoItem *const | pItem,
|  | const GLYPH_FUNC | func,
|  | void * | contextData,
|  | bool | applyOffset = `false`
| ) |  |
| protected

For a decomposed PangoItem (that can be rendered with a single font face) that is generated by for_each_glyph_do, apply GLYPH_FUNC to each glyph in that PangoItem.

References _fontSize, _glyphMap, FreetypeGlyphMgr::assign(), DRAWING_SCALE, and utf8_to_ucs4().

Referenced by for_each_glyph_do().

## ◆ setFont()

void PostscriptDocument::setFont | ( | const char *const | family = `"sans"`,
|  | LASi::FontStyle | style = `LASi::NORMAL_STYLE`,
|  | LASi::FontWeight | weight = `LASi::NORMAL_WEIGHT`,
|  | LASi::FontVariant | variant = `LASi::NORMAL_VARIANT`,
|  | LASi::FontStretch | stretch = `LASi::NORMAL_STRETCH`
| ) |  |

Sets the font that all subsequent text written to bodyStream() or footerStream() will be rendered with.

References _pContextMgr, LASi::BOLD, LASi::CONDENSED, DRAWING_SCALE, LASi::EXPANDED, LASi::EXTRACONDENSED, LASi::EXTRAEXPANDED, LASi::HEAVY, LASi::ITALIC, LASi::LIGHT, LASi::NORMAL_STRETCH, LASi::NORMAL_STYLE, LASi::NORMAL_VARIANT, LASi::NORMAL_WEIGHT, LASi::OBLIQUE, LASi::SEMICONDENSED, LASi::SEMIEXPANDED, LASi::SMALLCAPS, LASi::ULTRABOLD, LASi::ULTRACONDENSED, LASi::ULTRAEXPANDED, and LASi::ULTRALIGHT.

Referenced by LASi::setFont::apply().

## ◆ setFontSize()

void LASi::PostscriptDocument::setFontSize | ( | const double | size | ) |
| inline

Sets the font size, in points, that all subsequent text written to bodyStream() or footerStream() will be rendered with.

Referenced by LASi::setFontSize::apply().

## ◆ write()

void PostscriptDocument::write | ( | std::ostream & | os,
|  | double | llx = `0`,
|  | double | lly = `0`,
|  | double | urx = `0`,
|  | double | ury = `0`
| ) |  |

Closes all streams and writes completed Postscript document to os.

Writes out the document.

Header will include glyph routines for all text glyphs in body and footer.

2006.05.01.ET Addendum: To create an EPS document, just include the the four BoundingBox coordinates llx, lly, urx, ury (dimensions in points). These are optional parameters – When not included, you'll get a regular PS document. When included, you'll get an EPS document.

References _glyphMap, _osBody, _osFooter, _osHeader, _pContextMgr, and write_glyph_routine_to_stream.

## Friends And Related Function Documentation

## ◆ show

friend class show
| friend

## ◆ write_glyph_routine_to_stream

friend class write_glyph_routine_to_stream
| friend

Referenced by write().

## Member Data Documentation

## ◆ _fontSize

double LASi::PostscriptDocument::_fontSize
| private

Referenced by get_dimensions(), and PangoItem_do().

## ◆ _glyphMap

GlyphMap LASi::PostscriptDocument::_glyphMap
| private

Referenced by PangoItem_do(), and write().

## ◆ _osBody

oPostscriptStream LASi::PostscriptDocument::_osBody
| private

Referenced by write().

## ◆ _osFooter

oPostscriptStream LASi::PostscriptDocument::_osFooter
| private

Referenced by write().

## ◆ _osHeader

std::ostringstream LASi::PostscriptDocument::_osHeader
| private

Referenced by write().

## ◆ _pContextMgr

ContextMgr* LASi::PostscriptDocument::_pContextMgr
| private

Referenced by setFont(), write(), and ~PostscriptDocument().

## ◆ DRAWING_SCALE

const unsigned int PostscriptDocument::DRAWING_SCALE = PANGO_SCALE
| staticprivate

Referenced by LASi::show::apply(), get_dimensions(), PangoItem_do(), and setFont().

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

- LASi.h
- psDoc.cpp