YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
TextLayout.cpp
浏览该文件的文档.
1 /*
2  © 2009-2014 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_TextLayout
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 SDst
45 {
46  YAssert(GetTextLineHeightExOf(ts) != 0, "Zero line height found.");
47  return ts.Margin.Bottom + (h + ts.LineGap - GetVerticalOf(ts.Margin))
48  % GetTextLineHeightExOf(ts);
49 }
50 
51 u16
53 {
54  YAssert(GetTextLineHeightExOf(ts) != 0, "Zero line height found.");
55  return (h + ts.LineGap - GetVerticalOf(ts.Margin))
56  / GetTextLineHeightExOf(ts);
57 }
58 
59 SPos
61 {
62  const u16 n(FetchResizedLineN(ts, h));
63 
64  return ts.Margin.Top + ts.Font.GetAscender()
65  + GetTextLineHeightExOf(ts) * (n > 0 ? n - 1 : n);
66 // return h - ts.Margin.Bottom + ts.GetCache().GetDescender() + 1;
67 }
68 
69 
70 SDst
71 FetchCharWidth(const Font& font, ucs4_t c)
72 {
73  return font.GetAdvance(c, font.GetGlyph(c));
74 }
75 
76 } // namespace Drawing;
77 
78 } // namespace YSLib;
79 
s8 GetAscender() const
取升部。
Definition: Font.cpp:509
u8 LineGap
行距。
Definition: TextBase.h:100
SDst GetVerticalOf(const Padding &m)
取竖直边距和。
Definition: ygdi.h:116
std::uint16_t SDst
屏幕坐标距离。
Definition: Video.h:39
std::int16_t SPos
屏幕坐标度量。
Definition: Video.h:38
YF_API SDst FetchResizedBottomMargin(const TextState &, SDst)
取指定文本状态和文本区域高调整的底边距。
Definition: TextLayout.cpp:44
YF_API SPos FetchLastLineBasePosition(const TextState &, SDst)
取指定文本状态在指定高的区域中表示的最底行的基线位置(纵坐标)。
Definition: TextLayout.cpp:60
Padding Margin
边距:文本区域到显示区域的距离。
Definition: TextBase.h:94
YF_API SDst FetchCharWidth(const Font &, ucs4_t)
取指定的字符使用指定字体的显示宽度。
Definition: TextLayout.cpp:71
YF_API u16 FetchResizedLineN(const TextState &ts, SDst)
取指定文本状态和文本区域高所能显示的最大文本行数。
Definition: TextLayout.cpp:52
文本状态。
Definition: TextBase.h:87
Drawing::Font Font
字体。
Definition: TextBase.h:57
char32_t ucs4_t
UCS-4 字符类型。
Definition: chrdef.h:45
字体:字模,包含字型、样式和大小。
Definition: Font.h:546
std::uint16_t u16
Definition: yadaptor.h:68
#define YAssert(_expr, _msg)
Definition: cassert.h:73