[DEV] display font with clipping availlable
This commit is contained in:
parent
ace466b7bd
commit
ba0b1256d6
@ -222,12 +222,14 @@ bool ewol::TexturedFont::HasName(etk::UString& fileName)
|
|||||||
int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
||||||
const etk::UString& unicodeString,
|
const etk::UString& unicodeString,
|
||||||
etk::Vector<Vector2D<float> > & coord,
|
etk::Vector<Vector2D<float> > & coord,
|
||||||
etk::Vector<texCoord_ts> & coordTex)
|
etk::Vector<texCoord_ts> & coordTex,
|
||||||
|
bool hasClipping,
|
||||||
|
clipping_ts& clipping)
|
||||||
{
|
{
|
||||||
float totalSize = 0;
|
float totalSize = 0;
|
||||||
Vector2D<float> tmpPos = textPos;
|
Vector2D<float> tmpPos = textPos;
|
||||||
for(int32_t iii=0; iii<unicodeString.Size(); iii++) {
|
for(int32_t iii=0; iii<unicodeString.Size(); iii++) {
|
||||||
int32_t ret = Draw(tmpPos, unicodeString[iii], coord, coordTex);
|
int32_t ret = Draw(tmpPos, unicodeString[iii], coord, coordTex, hasClipping, clipping);
|
||||||
tmpPos.x += ret;
|
tmpPos.x += ret;
|
||||||
totalSize += ret;
|
totalSize += ret;
|
||||||
}
|
}
|
||||||
@ -308,7 +310,9 @@ int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
|||||||
int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
||||||
const uniChar_t unicodeChar,
|
const uniChar_t unicodeChar,
|
||||||
etk::Vector<Vector2D<float> > & coord,
|
etk::Vector<Vector2D<float> > & coord,
|
||||||
etk::Vector<texCoord_ts> & coordTex)
|
etk::Vector<texCoord_ts> & coordTex,
|
||||||
|
bool hasClipping,
|
||||||
|
clipping_ts& clipping)
|
||||||
{
|
{
|
||||||
float posDrawX = textPos.x;
|
float posDrawX = textPos.x;
|
||||||
|
|
||||||
@ -347,76 +351,123 @@ int32_t ewol::TexturedFont::Draw(Vector2D<float> textPos,
|
|||||||
|
|
||||||
|
|
||||||
// Clipping and drawing area
|
// Clipping and drawing area
|
||||||
if( dxB <= dxA
|
|
||||||
|| dyD >= dyC) {
|
if( dxB < clipping.x
|
||||||
// nothing to do ...
|
|| dxA > clipping.x + clipping.w)
|
||||||
|
{
|
||||||
|
// Nothing to diplay ...
|
||||||
} else {
|
} else {
|
||||||
/* Bitmap position
|
if (true == hasClipping) {
|
||||||
* 0------1
|
// generata positions...
|
||||||
* | |
|
float TexSizeX = tuB - tuA;
|
||||||
* | |
|
if (dxA < clipping.x) {
|
||||||
* 3------2
|
// clip display
|
||||||
*/
|
float drawSize = clipping.x - dxA;
|
||||||
Vector2D<int32_t> bitmapDrawPos[4];
|
// Update element start display
|
||||||
bitmapDrawPos[0].x = (int32_t)dxA;
|
dxA = clipping.x;
|
||||||
bitmapDrawPos[1].x = (int32_t)dxB;
|
float addElement = TexSizeX * drawSize / (float)m_listElement[charIndex].property.m_sizeTexture.x;
|
||||||
bitmapDrawPos[2].x = (int32_t)dxB;
|
// update texture start X Pos
|
||||||
bitmapDrawPos[3].x = (int32_t)dxA;
|
tuA += addElement;
|
||||||
|
}
|
||||||
bitmapDrawPos[0].y = (int32_t)dyC;
|
if (dxB > clipping.x + clipping.w) {
|
||||||
bitmapDrawPos[1].y = (int32_t)dyC;
|
// clip display
|
||||||
bitmapDrawPos[2].y = (int32_t)dyD;
|
float drawSize = dxB - (clipping.x + clipping.w);
|
||||||
bitmapDrawPos[3].y = (int32_t)dyD;
|
// Update element start display
|
||||||
/* texture Position :
|
dxB = clipping.x + clipping.w;
|
||||||
* 0------1
|
float addElement = TexSizeX * drawSize / (float)m_listElement[charIndex].property.m_sizeTexture.x;
|
||||||
* | |
|
// update texture start X Pos
|
||||||
* | |
|
tuB -= addElement;
|
||||||
* 3------2
|
}
|
||||||
*/
|
float TexSizeY = tvD - tvC;
|
||||||
texCoord_ts texturePos[4];
|
if (dyC < clipping.y) {
|
||||||
texturePos[0].u = tuA;
|
// clip display
|
||||||
texturePos[1].u = tuB;
|
float drawSize = clipping.y - dyC;
|
||||||
texturePos[2].u = tuB;
|
// Update element start display
|
||||||
texturePos[3].u = tuA;
|
dyC = clipping.y;
|
||||||
|
float addElement = TexSizeY * drawSize / (float)m_listElement[charIndex].property.m_sizeTexture.x;
|
||||||
texturePos[0].v = tvC;
|
// update texture start X Pos
|
||||||
texturePos[1].v = tvC;
|
tvC += addElement;
|
||||||
texturePos[2].v = tvD;
|
}
|
||||||
texturePos[3].v = tvD;
|
if (dyD > clipping.y + clipping.h) {
|
||||||
|
// clip display
|
||||||
// NOTE : Android does not support the Quads elements ...
|
float drawSize = dyD - (clipping.y + clipping.h);
|
||||||
/* Step 1 :
|
// Update element start display
|
||||||
* ********
|
dyD = clipping.y + clipping.h;
|
||||||
* ******
|
float addElement = TexSizeX * drawSize / (float)m_listElement[charIndex].property.m_sizeTexture.x;
|
||||||
* ****
|
// update texture start X Pos
|
||||||
* **
|
tvD -= addElement;
|
||||||
*
|
}
|
||||||
*/
|
}
|
||||||
// set texture coordonates :
|
if( dxB <= dxA
|
||||||
coordTex.PushBack(texturePos[0]);
|
|| dyD <= dyC) {
|
||||||
coordTex.PushBack(texturePos[1]);
|
// nothing to do ...
|
||||||
coordTex.PushBack(texturePos[2]);
|
} else {
|
||||||
// set display positions :
|
/* Bitmap position
|
||||||
coord.PushBack(bitmapDrawPos[0]);
|
* 0------1
|
||||||
coord.PushBack(bitmapDrawPos[1]);
|
* | |
|
||||||
coord.PushBack(bitmapDrawPos[2]);
|
* | |
|
||||||
|
* 3------2
|
||||||
/* Step 2 :
|
*/
|
||||||
*
|
Vector2D<int32_t> bitmapDrawPos[4];
|
||||||
* **
|
bitmapDrawPos[0].x = (int32_t)dxA;
|
||||||
* ****
|
bitmapDrawPos[1].x = (int32_t)dxB;
|
||||||
* ******
|
bitmapDrawPos[2].x = (int32_t)dxB;
|
||||||
* ********
|
bitmapDrawPos[3].x = (int32_t)dxA;
|
||||||
*/
|
|
||||||
// set texture coordonates :
|
bitmapDrawPos[0].y = (int32_t)dyC;
|
||||||
coordTex.PushBack(texturePos[0]);
|
bitmapDrawPos[1].y = (int32_t)dyC;
|
||||||
coordTex.PushBack(texturePos[2]);
|
bitmapDrawPos[2].y = (int32_t)dyD;
|
||||||
coordTex.PushBack(texturePos[3]);
|
bitmapDrawPos[3].y = (int32_t)dyD;
|
||||||
// set display positions :
|
/* texture Position :
|
||||||
coord.PushBack(bitmapDrawPos[0]);
|
* 0------1
|
||||||
coord.PushBack(bitmapDrawPos[2]);
|
* | |
|
||||||
coord.PushBack(bitmapDrawPos[3]);
|
* | |
|
||||||
|
* 3------2
|
||||||
|
*/
|
||||||
|
texCoord_ts texturePos[4];
|
||||||
|
texturePos[0].u = tuA;
|
||||||
|
texturePos[1].u = tuB;
|
||||||
|
texturePos[2].u = tuB;
|
||||||
|
texturePos[3].u = tuA;
|
||||||
|
|
||||||
|
texturePos[0].v = tvC;
|
||||||
|
texturePos[1].v = tvC;
|
||||||
|
texturePos[2].v = tvD;
|
||||||
|
texturePos[3].v = tvD;
|
||||||
|
|
||||||
|
// NOTE : Android does not support the Quads elements ...
|
||||||
|
/* Step 1 :
|
||||||
|
* ********
|
||||||
|
* ******
|
||||||
|
* ****
|
||||||
|
* **
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// set texture coordonates :
|
||||||
|
coordTex.PushBack(texturePos[0]);
|
||||||
|
coordTex.PushBack(texturePos[1]);
|
||||||
|
coordTex.PushBack(texturePos[2]);
|
||||||
|
// set display positions :
|
||||||
|
coord.PushBack(bitmapDrawPos[0]);
|
||||||
|
coord.PushBack(bitmapDrawPos[1]);
|
||||||
|
coord.PushBack(bitmapDrawPos[2]);
|
||||||
|
|
||||||
|
/* Step 2 :
|
||||||
|
*
|
||||||
|
* **
|
||||||
|
* ****
|
||||||
|
* ******
|
||||||
|
* ********
|
||||||
|
*/
|
||||||
|
// set texture coordonates :
|
||||||
|
coordTex.PushBack(texturePos[0]);
|
||||||
|
coordTex.PushBack(texturePos[2]);
|
||||||
|
coordTex.PushBack(texturePos[3]);
|
||||||
|
// set display positions :
|
||||||
|
coord.PushBack(bitmapDrawPos[0]);
|
||||||
|
coord.PushBack(bitmapDrawPos[2]);
|
||||||
|
coord.PushBack(bitmapDrawPos[3]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
posDrawX += m_listElement[charIndex].property.m_advance.x;
|
posDrawX += m_listElement[charIndex].property.m_advance.x;
|
||||||
|
@ -57,11 +57,15 @@ namespace ewol
|
|||||||
int32_t Draw(Vector2D<float> textPos,
|
int32_t Draw(Vector2D<float> textPos,
|
||||||
const etk::UString& unicodeString,
|
const etk::UString& unicodeString,
|
||||||
etk::Vector<Vector2D<float> > & coord,
|
etk::Vector<Vector2D<float> > & coord,
|
||||||
etk::Vector<texCoord_ts> & coordTex);
|
etk::Vector<texCoord_ts> & coordTex,
|
||||||
|
bool hasClipping,
|
||||||
|
clipping_ts& clipping);
|
||||||
int32_t Draw(Vector2D<float> textPos,
|
int32_t Draw(Vector2D<float> textPos,
|
||||||
const uniChar_t unicodeChar,
|
const uniChar_t unicodeChar,
|
||||||
etk::Vector<Vector2D<float> > & coord,
|
etk::Vector<Vector2D<float> > & coord,
|
||||||
etk::Vector<texCoord_ts> & coordTex);
|
etk::Vector<texCoord_ts> & coordTex,
|
||||||
|
bool hasClipping,
|
||||||
|
clipping_ts& clipping);
|
||||||
Vector2D<float> GetSize(const etk::UString & unicodeString);
|
Vector2D<float> GetSize(const etk::UString & unicodeString);
|
||||||
Vector2D<float> GetSize(const uniChar_t unicodeChar);
|
Vector2D<float> GetSize(const uniChar_t unicodeChar);
|
||||||
// TODO : Remove this element, it is stupid ...
|
// TODO : Remove this element, it is stupid ...
|
||||||
|
@ -183,11 +183,7 @@ int32_t ewol::OObject2DTextColored::Text(Vector2D<float> textPos, const etk::USt
|
|||||||
}
|
}
|
||||||
int32_t nbElementInTheArray = m_coord.Size();
|
int32_t nbElementInTheArray = m_coord.Size();
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
if (true==m_hasClipping) {
|
size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex, m_hasClipping, m_clipping);
|
||||||
size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex);
|
|
||||||
} else {
|
|
||||||
size = m_font->Draw(textPos, unicodeString, m_coord, m_coordTex);
|
|
||||||
}
|
|
||||||
// set the color ...
|
// set the color ...
|
||||||
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
||||||
m_coordColor.PushBack(m_color);
|
m_coordColor.PushBack(m_color);
|
||||||
@ -203,11 +199,7 @@ int32_t ewol::OObject2DTextColored::Text(Vector2D<float> textPos, const uniChar_
|
|||||||
}
|
}
|
||||||
int32_t nbElementInTheArray = m_coord.Size();
|
int32_t nbElementInTheArray = m_coord.Size();
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
if (true==m_hasClipping) {
|
size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex, m_hasClipping, m_clipping);
|
||||||
size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex);
|
|
||||||
} else {
|
|
||||||
size = m_font->Draw(textPos, unicodeChar, m_coord, m_coordTex);
|
|
||||||
}
|
|
||||||
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
|
||||||
m_coordColor.PushBack(m_color);
|
m_coordColor.PushBack(m_color);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user