YSTest  PreAlpha_b400_20130424
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
TextLayout.cpp
浏览该文件的文档.
1 /*
2  Copyright (C) by Franksoft 2009 - 2012.
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 
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 SDst
41 FetchResizedBottomMargin(const TextState& ts, SDst h)
42 {
43  YAssert(GetTextLineHeightExOf(ts) != 0, "Zero line height found.");
44 
45  return ts.Margin.Bottom + (h + ts.LineGap - GetVerticalOf(ts.Margin))
47 }
48 
49 u16
50 FetchResizedLineN(const TextState& ts, SDst h)
51 {
52  YAssert(GetTextLineHeightExOf(ts) != 0, "Zero line height found.");
53 
54  return (h + ts.LineGap - GetVerticalOf(ts.Margin))
56 }
57 
58 SPos
59 FetchLastLineBasePosition(const TextState& ts, SDst h)
60 {
61  const u16 n(FetchResizedLineN(ts, h));
62 
63  return ts.Margin.Top + ts.Font.GetAscender()
64  + GetTextLineHeightExOf(ts) * (n > 0 ? n - 1 : n);
65 // return h - ts.Margin.Bottom + ts.GetCache().GetDescender() + 1;
66 }
67 
68 
69 SDst
70 FetchCharWidth(const Font& font, ucs4_t c)
71 {
72  return font.GetAdvance(c, font.GetGlyph(c));
73 }
74 
75 YSL_END_NAMESPACE(Drawing)
76 
77 YSL_END
78