5 #include "FontCharacter.h"
6 #include "VectorMath.h"
12 namespace TextMeshHelpers
14 inline void CalcLocalQuadPointsSceenSpace(
const Fonts::FontCharacter& fontCharacter,
float x,
float y,
float z,
float fontBaselineOffset,
float sizeFactor, v3 out_points[4])
19 const float left = x + fontCharacter.offsetX * sizeFactor;
20 const float right = left + fontCharacter.width * sizeFactor;
21 const float top = y + (fontCharacter.offsetY - fontBaselineOffset)*sizeFactor;
22 const float bottom = top + fontCharacter.height * sizeFactor;
24 out_points[0].Set(left, top, z);
25 out_points[1].Set(right, top, z);
26 out_points[2].Set(left, bottom, z);
27 out_points[3].Set(right, bottom, z);
30 inline void CalcLocalQuadPoints(
const Fonts::FontCharacter& fontCharacter,
float x,
float y,
float z,
float fontLineHeight,
float sizeFactor, v3 out_points[4],
bool anchoredBottom=
false)
34 const float w = fontCharacter.width * sizeFactor;
35 const float h = fontCharacter.height * sizeFactor;
36 const float ox = fontCharacter.offsetX * sizeFactor;
38 const float left = x + ox;
39 const float right = left + w;
45 bottom = y + (fontLineHeight*sizeFactor);
50 top = y + (fontLineHeight - fontCharacter.offsetY)*sizeFactor;
54 out_points[0].Set(left, top, z);
55 out_points[1].Set(right, top, z);
56 out_points[2].Set(left, bottom, z);
57 out_points[3].Set(right, bottom, z);
60 inline void CalcQuadTexCoords(
const Fonts::FontCharacter& fontCharacter,
float oneOverScaleW,
float oneOverScaleH, v2& out_leftBottom, v2& out_rightTop)
62 const float left = fontCharacter.x * oneOverScaleW;
63 const float right = (fontCharacter.x + fontCharacter.width) * oneOverScaleW;
66 const float top = 1.0f - fontCharacter.y * oneOverScaleH;
67 const float bottom = 1.0f - (fontCharacter.y + fontCharacter.height) * oneOverScaleH;
68 out_leftBottom.Set(left, bottom);
69 out_rightTop.Set(right, top);