YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
TextBase.cpp
浏览该文件的文档.
1 /*
2  Copyright by FrankHB 2009 - 2013.
3 
4  This file is part of the YSLib project, and may only be used,
5  modified, and distributed under the terms of the YSLib project
6  license, LICENSE.TXT. By continuing to use, modify, or distribute
7  this file you indicate that you have read the license and
8  understand and accept it fully.
9 */
10 
28 #include "YSLib/Service/TextBase.h"
29 #include "YSLib/Service/yblit.h"
30 
31 using namespace ystdex;
32 
34 
35 using namespace Drawing;
36 using namespace Text;
37 
38 YSL_BEGIN_NAMESPACE(Drawing)
39 
40 TextState::TextState(const Drawing::Font& font)
41  : PenStyle(font),
42  Margin(DefaultMargin), Pen(), LineGap(0)
43 {}
44 TextState::TextState(FontCache& fc)
45  : TextState(Drawing::Font(fc.GetDefaultTypefacePtr()->GetFontFamily()))
46 {}
47 
48 void
50 {
51  CarriageReturn(*this);
52  Pen.Y += GetTextLineHeightExOf(*this);
53 }
54 
55 void
57 {
58  // Pen.Y = Margin.Top + GetTextLineHeightExOf(*this);
59  // Pen.Y = Margin.Top + pCache->GetAscender();
60  CarriageReturn(*this),
61  Pen.Y = GetTextLineBaseOf(*this);
62 }
63 void
64 TextState::ResetPen(const Point& pt, const Padding& m)
65 {
66  Pen = Point(pt.X + m.Left, pt.Y + Font.GetAscender() + m.Top);
67 }
68 
69 
70 void
71 SetCurrentTextLineNOf(TextState& ts, u16 n)
72 {
73  ts.Pen.Y = GetTextLineBaseOf(ts) + GetTextLineHeightExOf(ts) * n;
74 }
75 
76 void
77 MovePen(TextState& ts, ucs4_t c)
78 {
79  CharBitmap sbit(ts.Font.GetGlyph(c));
80 
81  ts.Pen.X += ts.Font.GetAdvance(c, sbit);
82 }
83 
84 YSL_END_NAMESPACE(Drawing)
85 
87 
88 
90 
91 YSL_END
92