YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
TextBase.cpp
浏览该文件的文档.
1 /*
2  © 2009-2013 FrankHB.
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/YModules.h"
29 #include YFM_YSLib_Service_TextBase
30 #include YFM_YSLib_Service_YBlit
31 
32 using namespace ystdex;
33 
34 namespace YSLib
35 {
36 
37 using namespace Drawing;
38 using namespace Text;
39 
40 namespace Drawing
41 {
42 
43 TextState::TextState(const Drawing::Font& font)
44  : PenStyle(font),
45  Margin(DefaultMargin), Pen(), LineGap(0)
46 {}
48  : TextState(Drawing::Font(fc.GetDefaultTypefacePtr()->GetFontFamily()))
49 {}
50 
51 void
52 TextState::PutNewline()
53 {
54  CarriageReturn(*this);
55  Pen.Y += GetTextLineHeightExOf(*this);
56 }
57 
58 void
60 {
61  // Pen.Y = Margin.Top + GetTextLineHeightExOf(*this);
62  // Pen.Y = Margin.Top + pCache->GetAscender();
63  CarriageReturn(*this),
64  Pen.Y = GetTextLineBaseOf(*this);
65 }
66 void
67 TextState::ResetPen(const Point& pt, const Padding& m)
68 {
69  Pen = Point(pt.X + m.Left, pt.Y + Font.GetAscender() + m.Top);
70 }
71 
72 
73 void
75 {
76  ts.Pen.Y = GetTextLineBaseOf(ts) + GetTextLineHeightExOf(ts) * n;
77 }
78 
79 void
81 {
82  CharBitmap sbit(ts.Font.GetGlyph(c));
83 
84  ts.Pen.X += ts.Font.GetAdvance(c, sbit);
85 }
86 
87 } // namespace Drawing;
88 
89 namespace Text
90 {
91 
92 
93 } // namespace Text;
94 
95 } // namespace YSLib;
96 
s8 GetAscender() const
取升部。
Definition: Font.cpp:509
TextState(const Drawing::Font &={})
构造:使用指定字体。
Definition: TextBase.cpp:43
Point Pen
笔坐标。
Definition: TextBase.h:99
yconstexpr Padding DefaultMargin(2, 2, 2, 2)
默认边距。
笔样式:字体和笔颜色。
Definition: TextBase.h:54
void MovePen(TextState &ts, ucs4_t c)
Definition: TextBase.cpp:80
字符位图。
Definition: Font.h:357
GBinaryGroup< SPos > Point
屏幕二维点(直角坐标表示)。
Definition: ygdibase.h:235
字体缓存。
Definition: Font.h:415
文本状态。
Definition: TextBase.h:87
Drawing::Font Font
字体。
Definition: TextBase.h:57
void SetCurrentTextLineNOf(TextState &ts, u16 n)
Definition: TextBase.cpp:74
SPos GetTextLineBaseOf(const TextState &ts)
取第一行的基线位置(纵坐标)。
Definition: TextBase.h:193
void CarriageReturn(TextState &ts)
回车。
Definition: TextBase.h:236
char32_t ucs4_t
UCS-4 字符类型。
Definition: chrdef.h:45
字体:字模,包含字型、样式和大小。
Definition: Font.h:546
std::uint16_t u16
Definition: yadaptor.h:68
SDst GetTextLineHeightExOf(const TextState &ts)
取当前指定文本状态的字体设置对应的行高与行距之和。
Definition: TextBase.h:173
PDefHOp(TextState &,=, const PenStyle &ps) ImplRet(PenStyle void ResetPen()
赋值:笔样式。
Definition: TextBase.h:145