2 * Kimikage NScripter Plugins Project
\r
4 * This software is distributed under a BSD-style license.
\r
5 * See license.txt for more information.
\r
8 #include "Typesetter.h"
\r
12 Typesetter::Typesetter( void )
\r
16 Typesetter::~Typesetter( void )
\r
20 void Typesetter::setSpace( int horizontal, int vertical )
\r
22 hSpace = horizontal;
\r
26 void Typesetter::calculateRect( int &width, int &height,
\r
27 UnicodeString &str, const Decorator &decorator ) const
\r
34 int lineHeight = 0; //
\8c»
\8dÝ
\91Î
\8fÛ
\82Æ
\82µ
\82Ä
\82¢
\82é
\8ds
\82Ì
\8d\82\82³
\r
35 while( const unsigned int unicode = str.peek() )
\r
37 const Glyph &glyph = *Glyph::get( unicode );
\r
38 if ( '\n' == unicode ) //
\89ü
\8ds
\r
40 if ( x > hSpace ) x -= hSpace;
\r
41 if ( x > width ) width = x;
\r
43 y += glyph.getAscent() + glyph.getDescent(); //1
\95¶
\8e\9a\82Ì
\8d\82\82³
\95ª
\89º
\82É
\88Ú
\93®
\r
44 y += vSpace; //
\8ds
\8aÔ
\95ª
\88Ú
\93®
\r
48 const int bottom = glyph.getAscent() - glyph.getY() + glyph.getHeight();
\r
49 if ( bottom > lineHeight ) lineHeight = bottom;
\r
50 x += glyph.getCellWidth();
\r
53 if ( x > hSpace ) x -= hSpace;
\r
54 if ( x > width ) width = x;
\r
55 height = y + lineHeight;
\r
57 int exTop,exLeft,exBottom,exRight;
\r
58 decorator.getExtensionSize( exLeft, exTop, exRight, exBottom );
\r
59 width += exLeft + exRight;
\r
60 height+= exTop + exBottom;
\r
63 void Typesetter::draw( ArgbBitmap &bmp, UnicodeString &str, const Decorator &decorator ) const
\r
68 while( const unsigned int unicode = str.peek() )
\r
70 const Glyph &glyph = *Glyph::get( unicode );
\r
71 if ( '\n' == unicode )
\r
74 y += glyph.getAscent() + glyph.getDescent();
\r
78 const int gx = glyph.getX();
\r
79 const int gy = glyph.getAscent()-glyph.getY();
\r
81 decorator.drawEdge( x + gx, y + gy, bmp, glyph );
\r
82 decorator.drawFace( x + gx, y + gy, bmp, glyph );
\r
84 x += glyph.getCellWidth();
\r