13#include <pango/pango.h>
17class FreetypeGlyphMgr;
28 #if defined ( __VISUALC__ ) || defined ( _MSC_VER ) || defined ( __BORLANDC__ ) || defined ( __GNUC__ ) || defined ( __WATCOMC__ )
29 #define LASIDLLEXPORT __declspec( dllexport )
30 #define LASIDLLIMPORT __declspec( dllimport )
35#elif defined ( __CYGWIN__ )
36 #define LASIDLLEXPORT __declspec( dllexport )
37 #define LASIDLLIMPORT __declspec( dllimport )
38#elif defined ( __GNUC__ ) && __GNUC__ > 3
42 #define LASIDLLEXPORT __attribute__ ( ( visibility( "default" ) ) )
52#if defined(LASi_EXPORTS)
53 #define LASIDLLIMPEXP LASIDLLEXPORT
54 #define LASIDLLIMPEXP_DATA(type) LASIDLLEXPORT type
55#elif defined(LASi_DLL)
56 #define LASIDLLIMPEXP LASIDLLIMPORT
57 #define LASIDLLIMPEXP_DATA(type) LASIDLLIMPORT type
60 #define LASIDLLIMPEXP_DATA(type) type
97 class PostscriptDocument;
98 class write_glyph_routine_to_stream;
121 static_cast<std::ostream&
>(os) << t;
142 const char*
const family =
"sans",
175 void write(std::ostream& os,
double llx=0,
double lly=0,
double urx=0,
double ury=0);
183 void get_dimensions(
const char* s,
double *lineSpacing,
double *xAdvance=NULL,
double *yMin=NULL,
double *yMax=NULL);
184 void get_dimensions(std::string s,
double *lineSpacing,
double *xAdvance=NULL,
double *yMin=NULL,
double *yMax=NULL);
194 return id1._str == id2._str;
198 return id1._str < id2._str;
202 GlyphId(FT_Face,
const FT_UInt, uint32_t unichar);
205 std::string
str()
const {
return _str;}
214 typedef std::map<GlyphId, FreetypeGlyphMgr>
GlyphMap;
221 const GlyphMap::value_type&,
void* contextData);
233 bool applyOffset =
false);
238 bool applyOffset =
false);
255 PangoContext* pangoCtx;
259 : os(os), pangoCtx(pangoCtx) {}
266 static const unsigned int DRAWING_SCALE;
270 ContextMgr* _pContextMgr;
272 std::ostringstream _osHeader;
292 const char*
const family =
"sans",
297 : _family(family), _style(style), _weight(weight), _variant(variant), _stretch(stretch)
302 os.
doc().
setFont(_family, _style,_weight, _variant, _stretch);
306 const char*
const _family;
354 show(
const char* c_str ) : _str(c_str ) {}
355 show(std::string stl_str ) : _str(stl_str) {}
#define LASIDLLIMPEXP
Definition LASi.h:59
GlyphId()
Definition LASi.h:201
friend bool operator==(const GlyphId id1, const GlyphId id2)
Definition LASi.h:193
friend bool operator<(const GlyphId id1, const GlyphId id2)
Definition LASi.h:197
std::string str() const
Definition LASi.h:205
GlyphId(FT_Face, const FT_UInt, uint32_t unichar)
For internal use only.
Definition LASi.h:252
void operator()(PostscriptDocument::GlyphMap::value_type v)
write_glyph_routine_to_stream(std::ostream &os, PangoContext *pangoCtx)
Definition LASi.h:258
Composes Postscript document as three separate and independant streams for header,...
Definition LASi.h:130
void invoke_glyph_routine(const GlyphMap::value_type &, void *contextData)
oPostscriptStream & osFooter()
Returns stream for Postscript footer.
Definition LASi.h:164
double getFontSize()
Definition LASi.h:248
void get_dimensions(std::string s, double *lineSpacing, double *xAdvance=NULL, double *yMin=NULL, double *yMax=NULL)
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.
void setFontSize(const double size)
Sets the font size, in points, that all subsequent text written to bodyStream() or footerStream() wil...
Definition LASi.h:152
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_ea...
oPostscriptStream & osBody()
Returns stream for Postscript body.
Definition LASi.h:160
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.
Definition LASi.h:220
void accrue_dimensions(const GlyphMap::value_type &, void *contextData)
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-coord...
friend class show
Definition LASi.h:133
std::string glyphProcName() const
std::ostringstream & osHeader()
Returns stream for Postscript header.
Definition LASi.h:156
std::map< GlyphId, FreetypeGlyphMgr > GlyphMap
Maps glyph routine name to FT_Glyph instance.
Definition LASi.h:214
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.
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 wit...
PangoContext * pangoContext() const
Just like any ordinary ostringstream, but maintains a reference to the PostscriptDocument.
Definition LASi.h:103
friend class PostscriptDocument
Definition LASi.h:105
friend class setFontSize
Definition LASi.h:108
oPostscriptStream(PostscriptDocument &psDoc)
Definition LASi.h:110
friend class show
Definition LASi.h:106
PostscriptDocument & doc()
Definition LASi.h:113
friend class setFont
Definition LASi.h:107
void apply(oPostscriptStream &os) const
Definition LASi.h:332
friend oPostscriptStream & operator<<(oPostscriptStream &os, const setFontSize &x)
Stream inserter for 'setFontSize' stream manipulator.
Definition LASi.h:320
setFontSize(double size)
Usage: os << setFontSize(12) << ...
Definition LASi.h:329
setFont(const char *const family="sans", const LASi::FontStyle style=LASi::NORMAL_STYLE, const LASi::FontWeight weight=LASi::NORMAL_WEIGHT, const LASi::FontVariant variant=LASi::NORMAL_VARIANT, const LASi::FontStretch stretch=LASi::NORMAL_STRETCH)
Usage: os << setFont("Vera Sans",LASi::ITALIC,LASi::BOLD) << ...
Definition LASi.h:291
void apply(oPostscriptStream &os) const
Definition LASi.h:301
friend oPostscriptStream & operator<<(oPostscriptStream &os, const setFont &x)
Stream inserter for 'setFont' stream manipulator.
Definition LASi.h:283
show(std::string stl_str)
Definition LASi.h:355
friend oPostscriptStream & operator<<(oPostscriptStream &os, const show &x)
stream inserter for 'show' stream applicator
Definition LASi.h:346
void apply(oPostscriptStream &os) const
show(const char *c_str)
Usage: os << show("some UTF-8 text") << ...
Definition LASi.h:354
FontVariant
Definition LASi.h:80
@ SMALLCAPS
Definition LASi.h:82
@ NORMAL_VARIANT
Definition LASi.h:81
FontStretch
Definition LASi.h:85
@ EXTRACONDENSED
Definition LASi.h:87
@ ULTRAEXPANDED
Definition LASi.h:94
@ SEMIEXPANDED
Definition LASi.h:91
@ ULTRACONDENSED
Definition LASi.h:86
@ NORMAL_STRETCH
Definition LASi.h:90
@ EXTRAEXPANDED
Definition LASi.h:93
@ SEMICONDENSED
Definition LASi.h:89
@ EXPANDED
Definition LASi.h:92
@ CONDENSED
Definition LASi.h:88
FontStyle
Definition LASi.h:65
@ NORMAL_STYLE
Definition LASi.h:66
@ OBLIQUE
Definition LASi.h:67
@ ITALIC
Definition LASi.h:68
FontWeight
Definition LASi.h:71
@ HEAVY
Definition LASi.h:77
@ BOLD
Definition LASi.h:75
@ ULTRABOLD
Definition LASi.h:76
@ LIGHT
Definition LASi.h:73
@ ULTRALIGHT
Definition LASi.h:72
@ NORMAL_WEIGHT
Definition LASi.h:74
oPostscriptStream & operator<<(oPostscriptStream &os, T t)
Definition LASi.h:120