aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-11 23:39:10 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-05-11 23:39:10 +0800
commit08c898f79acd024718b071f0d08eb32f3f093cbd (patch)
tree650b848816d32bb35215f5dd5f1d4b46bd44c049
parentff69c72b15d00e80455d3122629840a55e464c86 (diff)
downloadSMELT-08c898f79acd024718b071f0d08eb32f3f093cbd.tar.xz
Allow truetype fonts to be rendered at arbitrary Z coordinates.
-rw-r--r--extensions/smttfont.cpp10
-rw-r--r--include/smttfont.hpp4
2 files changed, 7 insertions, 7 deletions
diff --git a/extensions/smttfont.cpp b/extensions/smttfont.cpp
index f3e8b1c..cf3ba68 100644
--- a/extensions/smttfont.cpp
+++ b/extensions/smttfont.cpp
@@ -43,9 +43,9 @@ bool smTTChar::setChar(wchar_t c,FT_Face ttface)
quad.v[2].tx=1;quad.v[2].ty=1;quad.v[3].tx=0;quad.v[3].ty=1;
return true;
}
-void smTTChar::render(float x,float y,DWORD col)
+void smTTChar::render(float x,float y,float z,DWORD col)
{
- for(int i=0;i<4;++i)quad.v[i].col=col,quad.v[i].z=.5;
+ for(int i=0;i<4;++i)quad.v[i].col=col,quad.v[i].z=z;
quad.v[0].x=x+xofs;quad.v[0].y=y-rh+yofs;
quad.v[1].x=x+rw+xofs;quad.v[1].y=y-rh+yofs;
quad.v[2].x=x+rw+xofs;quad.v[2].y=y+yofs;
@@ -97,7 +97,7 @@ void smTTFont::updateString(const wchar_t *format,...)
}
h+=lh;
}
-void smTTFont::render(float x,float y,DWORD col,int align)
+void smTTFont::render(float x,float y,float z,DWORD col,int align)
{
float curx,cury,lh;
if(align==ALIGN_LEFT)
@@ -109,7 +109,7 @@ void smTTFont::render(float x,float y,DWORD col,int align)
{
if(chars.find(buf[i])!=chars.end())
{
- chars[buf[i]].render(curx,cury,col);
+ chars[buf[i]].render(curx,cury,z,col);
curx+=chars[buf[i]].w();
lh=chars[buf[i]].h()>lh?chars[buf[i]].h():lh;
}
@@ -126,7 +126,7 @@ void smTTFont::render(float x,float y,DWORD col,int align)
{
if(chars.find(buf[i])!=chars.end())
{
- chars[buf[i]].render(curx,cury,col);
+ chars[buf[i]].render(curx,cury,z,col);
curx-=chars[buf[i]].w();
lh=chars[buf[i]].h()>lh?chars[buf[i]].h():lh;
}
diff --git a/include/smttfont.hpp b/include/smttfont.hpp
index 0f87b1c..0d90179 100644
--- a/include/smttfont.hpp
+++ b/include/smttfont.hpp
@@ -33,7 +33,7 @@ public:
float h(){return (float)_h;}
void free();
bool setChar(wchar_t c,FT_Face ttface);
- void render(float x,float y,DWORD col);
+ void render(float x,float y,float z,DWORD col);
};
class smTTFont
@@ -52,7 +52,7 @@ public:
float getWidth(){return w;}
float getHeight(){return h;}
void updateString(const wchar_t *format,...);
- void render(float x,float y,DWORD col,int align);
+ void render(float x,float y,float z,DWORD col,int align);
DWORD getCacheSize();
void clearCache();
};