YSTest: TextBase.cpp 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

TextBase.cpp
浏览该文件的文档.
1 /*
2 © 2009-2016 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, const Padding& m)
44 : PenStyle(font),
45 Margin(m)
46 {}
47 TextState::TextState(FontCache& fc, const Padding& m)
48 : TextState(Drawing::Font(fc.GetDefaultTypefacePtr()->GetFontFamily()), m)
49 {}
50
51 void
52 TextState::PutNewline()
53 {
54 CarriageReturn(*this);
55 // XXX: Conversion to 'SPos' might be implementation-defined.
56 Pen.Y += SPos(GetTextLineHeightExOf(*this));
57 }
58
59 void
60 TextState::ResetPen()
61 {
62 // Pen.Y = Margin.Top + GetTextLineHeightExOf(*this);
63 // Pen.Y = Margin.Top + pCache->GetAscender();
64 CarriageReturn(*this),
65 Pen.Y = GetTextLineBaseOf(*this);
66 }
67 void
68 TextState::ResetPen(const Point& pt, const Padding& m)
69 {
70 Pen = Point(pt.X + m.Left, pt.Y + Font.GetAscender() + m.Top);
71 }
72
73
74 void
75 SetCurrentTextLineNOf(TextState& ts, std::uint16_t n)
76 {
77 // XXX: Conversion to 'SPos' might be implementation-defined.
78 ts.Pen.Y = GetTextLineBaseOf(ts) + SPos(GetTextLineHeightExOf(ts) * n);
79 }
80
81 void
82 MovePen(TextState& ts, char32_t c)
83 {
84 CharBitmap sbit(ts.Font.GetGlyph(c));
85
86 ts.Pen.X += ts.Font.GetAdvance(c, sbit);
87 }
88
89 } // namespace Drawing;
90
91 namespace Text
92 {
93
94
95 } // namespace Text;
96
97 } // namespace YSLib;
98
YSLib::Drawing::SetCurrentTextLineNOf
void SetCurrentTextLineNOf(TextState &ts, std::uint16_t n)
Definition: TextBase.cpp:75
YSLib::Drawing::PutCharResult::PutNewline
输出换行符。
Definition: TextBase.cpp:52
YSLib::Drawing::Font
字体：字模，包含字型、样式和大小。
Definition: Font.h:583
YSLib::Drawing::TextState::GetTextLineBaseOf
const TextState &ts const TextState &ts GetTextLineBaseOf
Definition: TextBase.h:183
YModules.h
YSLib::UI::fc
fc
Definition: Console.h:93
YSLib::Drawing::GBinaryGroup::Y
_type Y
分量。
Definition: YGDIBase.h:63
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
YSLib::Drawing::FontCache
字体缓存。
Definition: Font.h:460
YSLib::Drawing::MovePen
void MovePen(TextState &ts, char32_t c)
Definition: TextBase.cpp:82
YSLib::Drawing::PenStyle::Font
Drawing::Font Font
字体。
Definition: TextBase.h:57
Text
YSLib::Drawing::TextState::TextState
TextState(const Drawing::Font &={}, const Padding &=DefaultMargin)
构造：使用指定字体和边距。
Definition: TextBase.cpp:43
YSLib::Drawing::Point
GBinaryGroup< SPos > Point
屏幕二维点（直角坐标表示）。
Definition: YGDIBase.h:278
YSLib::Drawing::TextState::GetTextLineHeightExOf
GetTextLineHeightExOf
Definition: TextBase.h:169
YSLib::Drawing::TextState
文本状态。
Definition: TextBase.h:86
ystdex
特性测试宏。
Definition: ydef.h:822
Drawing
YSLib::Drawing::CharBitmap
字符位图。
Definition: Font.h:383
platform::SPos
std::int16_t SPos
屏幕坐标度量。
Definition: Video.h:43
YSLib::Drawing::TextState::ResetPen
PDefHOp(TextState &,=, const PenStyle &ps) ImplRet(PenStyle void ResetPen()
赋值：笔样式。
Definition: TextBase.h:145
YSLib::Drawing::PenStyle
笔样式：字体和笔颜色。
Definition: TextBase.h:54
YSLib::Drawing::Padding
空白样式。
Definition: YGDI.h:46
YSLib::Drawing::Font::GetAscender
bool(style &FontStyle::Strikeout)) std std::int8_t GetAscender() const
取跨距。
Definition: Font.h:632
YSLib::Drawing::GBinaryGroup::X
_type X
Definition: YGDIBase.h:63
YSLib::Drawing::char32_t
tr TextRegion &tr char32_t
Definition: TextLayout.h:92
YSLib::Drawing::TextState::Pen
Point Pen
笔坐标。
Definition: TextBase.h:98
YSLib::Drawing::c
The boundary is out of the const Graphics const Rect const Point const Point Color c const Rect const Rect Color c
Definition: YDraw.h:174