1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008, 2010 Henrik Tidefelt
21 #include "Shapes_Ast_decls.h"
22 #include "Shapes_Kernel_decls.h"
23 #include "Shapes_Lang_decls.h"
24 #include "Shapes_Lang_decls.h"
28 #include "environment.h"
29 #include "statetypes.h"
30 #include "elementarylength.h"
31 #include "concretecolors.h"
32 #include "elementarycoords.h"
33 #include "fontmetrics.h"
34 #include "pdfstructure.h"
47 class PDF_ToUnicode
: public PDF_Stream_out
50 typedef std::set
< Shapes::Kernel::UnicodeCodePoint
> CharSet
;
52 RefCountPtr
< CharSet
> charSet_
;
53 RefCountPtr
< const Shapes::Lang::Font
> font_
; /* Used to determine the encoding. */
55 PDF_ToUnicode( RefCountPtr
< CharSet
> charSet
, const RefCountPtr
< const Shapes::Lang::Font
> & font
);
56 virtual ~PDF_ToUnicode( );
58 virtual void writeTo( std::ostream
& os
, SimplePDF::PDF_xref
* xref
, const RefCountPtr
< const PDF_Object
> & self
) const;
61 class PDF_Widths
: public PDF_Vector
64 typedef std::set
< Shapes::Kernel::UnicodeCodePoint
> CharSet
;
66 RefCountPtr
< CharSet
> charSet_
;
67 RefCountPtr
< const Shapes::Lang::Font
> font_
; /* Used to determine the encoding as well as the metrics. */
69 PDF_Widths( RefCountPtr
< CharSet
> charSet
, const RefCountPtr
< const Shapes::Lang::Font
> & font
);
70 virtual ~PDF_Widths( );
72 virtual void writeTo( std::ostream
& os
, SimplePDF::PDF_xref
* xref
, const RefCountPtr
< const PDF_Object
> & self
) const;
81 class FontMethod_glyph
;
83 class Font
: public Lang::NoOperatorOverloadValue
86 static std::map
< RefCountPtr
< const char >, RefCountPtr
< SimplePDF::PDF_Object
>, charRefPtrLess
> theFontResourceMap_
;
87 static std::map
< RefCountPtr
< const char >, RefCountPtr
< const FontMetrics::FontMetric
>, charRefPtrLess
> theFontMetricsMap_
;
88 static std::list
< std::string
> theFontMetricsSearchPath_
;
91 static void push_backFontMetricsPath( const std::string
& path
);
92 static std::string
searchGlyphList( );
93 static std::string
searchCharacterEncoding( const char * encodingName
);
95 static std::string
searchFontMetrics( RefCountPtr
< const char > fontName
);
97 RefCountPtr
< const char > fontName_
;
100 mutable RefCountPtr
< SimplePDF::PDF_Object
> resource_
;
101 mutable RefCountPtr
< const FontMetrics::FontMetric
> metrics_
;
103 Font( const RefCountPtr
< const char > fontName
, bool outline
, RefCountPtr
< SimplePDF::PDF_Object
> & resource
, RefCountPtr
< const FontMetrics::FontMetric
> metrics
= NullPtr
< const FontMetrics::FontMetric
>( ) );
104 Font( const RefCountPtr
< const char > builtInFontName
); // It is important that this is not used with fonts that aren't built in.
106 virtual Kernel::VariableHandle
getField( const char * fieldID
, const RefCountPtr
< const Lang::Value
> & selfRef
) const;
107 virtual void show( std::ostream
& os
) const;
108 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
109 const RefCountPtr
< SimplePDF::PDF_Object
> & resource( ) const;
110 RefCountPtr
< const char > fontName( ) const;
111 bool outline( ) const;
112 RefCountPtr
< const FontMetrics::FontMetric
> metrics( ) const;
113 virtual void encode( const char ** text_UTF8
, size_t * in_avail
, char ** dst_PDF
, size_t * out_avail
) const = 0;
114 virtual void encode( Kernel::UnicodeCodePoint c
, char ** dst_PDF
, size_t * out_avail
) const = 0;
118 /* These member functions are only here to support getField. */
119 virtual RefCountPtr
< const Lang::String
> family_name( ) const;
120 virtual RefCountPtr
< const Lang::String
> style_name( ) const;
121 virtual RefCountPtr
< const Lang::Symbol
> PostScript_name( ) const;
122 virtual RefCountPtr
< const Lang::Value
> getGlyph( Kernel::UnicodeCodePoint c
, Concrete::Length size
) const;
123 friend class Lang::FontMethod_glyph
;
126 class PDFStandardFont
: public Lang::Font
129 // It is important that this is not used with fonts that aren't built in.
130 PDFStandardFont( const RefCountPtr
< const char > builtInFontName
);
131 virtual ~PDFStandardFont( );
132 virtual void encode( const char ** text_UTF8
, size_t * in_avail
, char ** dst_PDF
, size_t * out_avail
) const;
133 virtual void encode( Kernel::UnicodeCodePoint c
, char ** dst_PDF
, size_t * out_avail
) const;
135 /* This is the implementation of the encode method. By providing it as a static member function, it may be used by Type3Font as well. */
136 static void encode_MacRoman( const char ** text_UTF8
, size_t * in_avail
, char ** dst_PDF
, size_t * out_avail
);
137 static void encode_MacRoman( Kernel::UnicodeCodePoint c
, char ** dst_PDF
, size_t * out_avail
);
140 class Type3Font
: public Lang::Font
143 Type3Font( const RefCountPtr
< const char > fontName
, RefCountPtr
< SimplePDF::PDF_Object
> & resource
, RefCountPtr
< const FontMetrics::FontMetric
> metrics
);
144 virtual ~Type3Font( );
145 virtual void encode( const char ** text_UTF8
, size_t * in_avail
, char ** dst_PDF
, size_t * out_avail
) const;
146 virtual void encode( Kernel::UnicodeCodePoint c
, char ** dst_PDF
, size_t * out_avail
) const;
150 class FreeTypeFont
: public Lang::Font
153 mutable RefCountPtr
< SimplePDF::PDF_ToUnicode::CharSet
> usedChars_
;
155 FreeTypeFont( FT_Face face
, const RefCountPtr
< const char > fontName
, bool outline
, RefCountPtr
< SimplePDF::PDF_Object
> & resource
, RefCountPtr
< const FontMetrics::FontMetric
> metrics
, RefCountPtr
< SimplePDF::PDF_ToUnicode::CharSet
> & usedChars
);
156 virtual ~FreeTypeFont( );
157 virtual void encode( const char ** text_UTF8
, size_t * in_avail
, char ** dst_PDF
, size_t * out_avail
) const;
158 virtual void encode( Kernel::UnicodeCodePoint c
, char ** dst_PDF
, size_t * out_avail
) const;
160 void shipout_glyph( Kernel::UnicodeCodePoint c
, Concrete::Length size
, const Lang::Transform2D
& tf
, std::ostream
& os
, bool * dstIsOdd
, Concrete::Length
* dstAdvance
) const; /* The value stored in *dstAdvance accounts for <size>, but not for <tf>. Hence, it typically needs to be scaled by the current horizontal scaling. */
163 virtual RefCountPtr
< const Lang::String
> family_name( ) const;
164 virtual RefCountPtr
< const Lang::String
> style_name( ) const;
165 virtual RefCountPtr
< const Lang::Symbol
> PostScript_name( ) const;
166 virtual RefCountPtr
< const Lang::Value
> getGlyph( Kernel::UnicodeCodePoint c
, Concrete::Length size
) const;
168 const FT_Outline
& getGlyphOutline( Kernel::UnicodeCodePoint c
) const; /* Note! Result is only valid until a different glyph is loaded in the glyph slot. */
172 class TextRenderingMode
: public Lang::NoOperatorOverloadValue
175 typedef enum { FILL
= 0, STROKE
, FILLSTROKE
, INVISIBLE
, FILLCLIP
, STROKECLIP
, FILLSTROKECLIP
, CLIP
, UNDEFINED
} ValueType
;
177 TextRenderingMode( const ValueType
& mode
);
178 TextRenderingMode( bool fill
, bool stroke
, bool clip
);
179 virtual ~TextRenderingMode( );
180 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
183 static ValueType
clipMode( ValueType mode
);
186 class TextOperation
: public Lang::NoOperatorOverloadValue
190 virtual ~TextOperation( );
192 virtual void shipout( std::ostream
& os
, Kernel::PageContentStates
* pdfState
, const Lang::Transform2D
& tf
, bool clip
= false ) const = 0;
193 virtual void shipout_outlined( std::ostream
& os
, Kernel::PageContentStates
* pdfState
, const Lang::Transform2D
& tf
, Lang::Transform2D
* textMatrix
, Lang::Transform2D
* lineMatrix
, const SimplePDF::PDF_Name
* clipContent
= 0 ) const = 0; /* clipContent == 0 means that the text shall be used for painting, not clipping. */
194 virtual void measure( Lang::Transform2D
* textMatrix
, Lang::Transform2D
* textLineMatrix
, Concrete::Length
* xmin
, Concrete::Length
* ymin
, Concrete::Length
* xmax
, Concrete::Length
* ymax
) const = 0;
199 class KernedText
: public Lang::TextOperation
201 RefCountPtr
< const Kernel::TextState
> textState_
;
202 RefCountPtr
< const Kernel::GraphicsState
> metaState_
;
204 // The representation is a bit artificial to be efficient: NullPtr objects in
205 // strings_ mark where kerning values are to be taken from kernings_. Hence,
206 // The number of NullPtr objects in strings_ must match the length of kernings_.
207 std::list
< RefCountPtr
< const Lang::String
> > strings_
;
208 std::list
< double > kernings_
;
211 KernedText( const RefCountPtr
< const Kernel::TextState
> & textState
, const RefCountPtr
< const Kernel::GraphicsState
> & metaState
);
212 KernedText( const RefCountPtr
< const Kernel::TextState
> & textState
, const RefCountPtr
< const Kernel::GraphicsState
> & metaState
, const RefCountPtr
< const Lang::String
> & str
);
213 virtual ~KernedText( );
214 virtual Kernel::VariableHandle
getField( const char * fieldID
, const RefCountPtr
< const Lang::Value
> & selfRef
) const;
215 void pushString( const RefCountPtr
< const Lang::String
> & str
);
216 void pushKerning( double kerning
);
218 virtual void show( std::ostream
& os
) const;
219 virtual void shipout( std::ostream
& os
, Kernel::PageContentStates
* pdfState
, const Lang::Transform2D
& tf
, bool clip
) const;
220 virtual void shipout_outlined( std::ostream
& os
, Kernel::PageContentStates
* pdfState
, const Lang::Transform2D
& tf
, Lang::Transform2D
* textMatrix
, Lang::Transform2D
* lineMatrix
, const SimplePDF::PDF_Name
* clipContent
) const;
221 virtual void measure( Lang::Transform2D
* textMatrix
, Lang::Transform2D
* textLineMatrix
, Concrete::Length
* xmin
, Concrete::Length
* ymin
, Concrete::Length
* xmax
, Concrete::Length
* ymax
) const;
223 void push( Lang::KernedText
* dst
) const;
225 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
228 RefCountPtr
< const Lang::SingleList
> makeList( ) const;
229 static RefCountPtr
< const Lang::String
> oneUCS4ToUTF8( const char * c
);
232 class TextNewline
: public Lang::TextOperation
234 Concrete::Coords2D t_
;
236 TextNewline( const Concrete::Length tx
, const Concrete::Length ty
);
237 virtual ~TextNewline( );
239 virtual void show( std::ostream
& os
) const;
240 virtual void shipout( std::ostream
& os
, Kernel::PageContentStates
* pdfState
, const Lang::Transform2D
& tf
, bool clip
) const;
241 virtual void shipout_outlined( std::ostream
& os
, Kernel::PageContentStates
* pdfState
, const Lang::Transform2D
& tf
, Lang::Transform2D
* textMatrix
, Lang::Transform2D
* lineMatrix
, const SimplePDF::PDF_Name
* clipContent
) const;
242 virtual void measure( Lang::Transform2D
* textMatrix
, Lang::Transform2D
* textLineMatrix
, Concrete::Length
* xmin
, Concrete::Length
* ymin
, Concrete::Length
* xmax
, Concrete::Length
* ymax
) const;
244 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
247 class TextMoveto
: public Lang::TextOperation
249 RefCountPtr
< const Lang::Transform2D
> tf_
;
251 TextMoveto( const RefCountPtr
< const Lang::Transform2D
> & tf
);
252 virtual ~TextMoveto( );
254 virtual void show( std::ostream
& os
) const;
255 virtual void shipout( std::ostream
& os
, Kernel::PageContentStates
* pdfState
, const Lang::Transform2D
& tf
, bool clip
) const;
256 virtual void shipout_outlined( std::ostream
& os
, Kernel::PageContentStates
* pdfState
, const Lang::Transform2D
& tf
, Lang::Transform2D
* textMatrix
, Lang::Transform2D
* lineMatrix
, const SimplePDF::PDF_Name
* clipContent
) const;
257 virtual void measure( Lang::Transform2D
* textMatrix
, Lang::Transform2D
* textLineMatrix
, Concrete::Length
* xmin
, Concrete::Length
* ymin
, Concrete::Length
* xmax
, Concrete::Length
* ymax
) const;
259 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
267 class CharacterSpacingBinding
: public DynamicBindings
269 const Ast::DynamicBindingExpression
* bindingExpr_
;
270 Concrete::Length spacing_
;
272 const Ast::PlacedIdentifier
* id_
;
274 CharacterSpacingBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Concrete::Length spacing
);
275 CharacterSpacingBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const double r
);
276 virtual ~CharacterSpacingBinding( );
277 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
278 virtual void show( std::ostream
& os
) const;
279 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
282 class WordSpacingBinding
: public DynamicBindings
284 const Ast::DynamicBindingExpression
* bindingExpr_
;
285 Concrete::Length spacing_
;
287 const Ast::PlacedIdentifier
* id_
;
289 WordSpacingBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Concrete::Length spacing
);
290 WordSpacingBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const double r
);
291 virtual ~WordSpacingBinding( );
292 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
293 virtual void show( std::ostream
& os
) const;
294 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
297 class HorizontalScalingBinding
: public DynamicBindings
299 const Ast::DynamicBindingExpression
* bindingExpr_
;
301 const Ast::PlacedIdentifier
* id_
;
303 HorizontalScalingBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const double scaling
);
304 virtual ~HorizontalScalingBinding( );
305 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
306 virtual void show( std::ostream
& os
) const;
307 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
310 class LeadingBinding
: public DynamicBindings
312 const Ast::DynamicBindingExpression
* bindingExpr_
;
313 Concrete::Length ty_
;
315 const Ast::PlacedIdentifier
* id_
;
317 LeadingBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Concrete::Length ty
);
318 LeadingBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const double r
);
319 virtual ~LeadingBinding( );
320 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
321 virtual void show( std::ostream
& os
) const;
322 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
325 class FontBinding
: public DynamicBindings
327 const Ast::DynamicBindingExpression
* bindingExpr_
;
328 RefCountPtr
< const Lang::Font
> font_
;
329 const Ast::PlacedIdentifier
* id_
;
331 FontBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const RefCountPtr
< const Lang::Font
> & font
);
332 virtual ~FontBinding( );
333 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
334 virtual void show( std::ostream
& os
) const;
335 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
338 class TextSizeBinding
: public DynamicBindings
340 const Ast::DynamicBindingExpression
* bindingExpr_
;
341 Concrete::Length size_
;
342 const Ast::PlacedIdentifier
* id_
;
344 TextSizeBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Concrete::Length size
);
345 virtual ~TextSizeBinding( );
346 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
347 virtual void show( std::ostream
& os
) const;
348 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
351 class TextRenderingModeBinding
: public DynamicBindings
353 const Ast::DynamicBindingExpression
* bindingExpr_
;
354 Lang::TextRenderingMode::ValueType mode_
;
355 const Ast::PlacedIdentifier
* id_
;
357 TextRenderingModeBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Lang::TextRenderingMode::ValueType mode
);
358 virtual ~TextRenderingModeBinding( );
359 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
360 virtual void show( std::ostream
& os
) const;
361 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
364 class TextRiseBinding
: public DynamicBindings
366 const Ast::DynamicBindingExpression
* bindingExpr_
;
367 Concrete::Length ty_
;
369 const Ast::PlacedIdentifier
* id_
;
371 TextRiseBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Concrete::Length ty
);
372 TextRiseBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const double r
);
373 virtual ~TextRiseBinding( );
374 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
375 virtual void show( std::ostream
& os
) const;
376 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
379 class TextKnockoutBinding
: public DynamicBindings
381 const Ast::DynamicBindingExpression
* bindingExpr_
;
383 const Ast::PlacedIdentifier
* id_
;
385 TextKnockoutBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const bool knockout
);
386 virtual ~TextKnockoutBinding( );
387 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
388 virtual void show( std::ostream
& os
) const;
389 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
397 class CharacterSpacingDynamicVariableProperties
: public Kernel::DynamicVariableProperties
400 CharacterSpacingDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
401 virtual ~CharacterSpacingDynamicVariableProperties( );
402 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
403 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
406 class WordSpacingDynamicVariableProperties
: public Kernel::DynamicVariableProperties
409 WordSpacingDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
410 virtual ~WordSpacingDynamicVariableProperties( );
411 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
412 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
415 class HorizontalScalingDynamicVariableProperties
: public Kernel::DynamicVariableProperties
418 HorizontalScalingDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
419 virtual ~HorizontalScalingDynamicVariableProperties( );
420 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
421 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
424 class LeadingDynamicVariableProperties
: public Kernel::DynamicVariableProperties
427 LeadingDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
428 virtual ~LeadingDynamicVariableProperties( );
429 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
430 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
433 class FontDynamicVariableProperties
: public Kernel::DynamicVariableProperties
436 FontDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
437 virtual ~FontDynamicVariableProperties( );
438 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
439 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
442 class TextSizeDynamicVariableProperties
: public Kernel::DynamicVariableProperties
445 TextSizeDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
446 virtual ~TextSizeDynamicVariableProperties( );
447 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
448 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
451 class TextRenderingModeDynamicVariableProperties
: public Kernel::DynamicVariableProperties
454 TextRenderingModeDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
455 virtual ~TextRenderingModeDynamicVariableProperties( );
456 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
457 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
460 class TextRiseDynamicVariableProperties
: public Kernel::DynamicVariableProperties
463 TextRiseDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
464 virtual ~TextRiseDynamicVariableProperties( );
465 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
466 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
469 class TextKnockoutDynamicVariableProperties
: public Kernel::DynamicVariableProperties
472 TextKnockoutDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
473 virtual ~TextKnockoutDynamicVariableProperties( );
474 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
475 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
481 static const char RELATIVE_LEADING
= 0x01;
482 static const char RELATIVE_RISE
= 0x02;
483 static const char RELATIVE_CHARACTER_SPACING
= 0x04;
484 static const char RELATIVE_WORD_SPACING
= 0x08;
486 unsigned char relativeFlags_
;
489 static const char KNOCKOUT_FLAG_BIT
= 0x01;
490 static const char KNOCKOUT_UNDEFINED_BIT
= 0x02;
492 Concrete::Length characterSpacing_
; // Use NaN for undefined.
493 Concrete::Length wordSpacing_
; // Use NaN for undefined.
495 double horizontalScaling_
; // Use NaN for undefined.
497 Concrete::Length leading_
; // Use NaN for undefined. Offtype in case leadingIsRelative_.
498 Concrete::Length rise_
; // Use NaN for undefined. Offtype in case riseIsRelative_.
500 RefCountPtr
< const Lang::Font
> font_
; // Use NullPtr for undefined.
501 Concrete::Length size_
; // Use NaN for undefined.
502 Lang::TextRenderingMode::ValueType mode_
; // Use UNDEFINED for undefined.
503 char knockout_
; // Set the bit KNOCKOUT_UNDEFINED for undefined.
506 explicit TextState( const Kernel::TextState
& orig
); // explicit, since reference counting shall be used in most cases
507 TextState( const Kernel::TextState
& newValues
, const Kernel::TextState
& oldValues
);
508 TextState( bool setDefaults
);
511 void setLeading( const Concrete::Length leading
);
512 void setLeading( const double relativeLeading
);
513 bool hasLeading( ) const;
514 inline bool leadingIsRelative( ) const;
515 Concrete::Length
leadingConcrete( ) const;
516 RefCountPtr
< const Lang::Value
> leading( ) const;
518 void setRise( const Concrete::Length rise
);
519 void setRise( const double relativeRise
);
520 bool hasRise( ) const;
521 bool riseIsRelative( ) const;
522 Concrete::Length
riseConcrete( ) const;
523 RefCountPtr
< const Lang::Value
> rise( ) const;
525 void setCharacterSpacing( const Concrete::Length spacing
);
526 void setCharacterSpacing( const double relativeSpacing
);
527 bool hasCharacterSpacing( ) const;
528 bool characterSpacingIsRelative( ) const;
529 Concrete::Length
characterSpacingConcrete( ) const;
530 RefCountPtr
< const Lang::Value
> characterSpacing( ) const;
532 void setWordSpacing( const Concrete::Length spacing
);
533 void setWordSpacing( const double relativeSpacing
);
534 bool hasWordSpacing( ) const;
535 bool wordSpacingIsRelative( ) const;
536 Concrete::Length
wordSpacingConcrete( ) const;
537 RefCountPtr
< const Lang::Value
> wordSpacing( ) const;
539 bool synchKnockout( std::ostream
& os
, const Kernel::TextState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
540 bool synchAssertKnockout( std::ostream
& os
, const Kernel::TextState
* ref
, SimplePDF::PDF_Resources
* resources
, bool clip
, bool force
= false );
542 void print( std::ostream
& os
, const std::string
& indentation
) const;
545 static std::map
< bool, RefCountPtr
< SimplePDF::PDF_Object
> > knockoutNameMap_
;
547 bool synchCharacterSpacing( std::ostream
& os
, const Kernel::TextState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
548 bool synchWordSpacing( std::ostream
& os
, const Kernel::TextState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
549 bool synchHorizontalScaling( std::ostream
& os
, const Kernel::TextState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
550 bool synchLeading( std::ostream
& os
, const Kernel::TextState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
551 bool synchFontAndSize( std::ostream
& os
, const Kernel::TextState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
552 bool synchMode( std::ostream
& os
, const Kernel::TextState
* ref
, SimplePDF::PDF_Resources
* resources
, bool clip
, bool force
= false );
553 bool synchRise( std::ostream
& os
, const Kernel::TextState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
555 void assertKnockout( const Kernel::TextState
* ref
);
557 bool synchButKnockout( std::ostream
& os
, const Kernel::TextState
* ref
, SimplePDF::PDF_Resources
* resources
, bool clip
, bool force
= false );