Page 1 of 1

ttf fonts are having bad offsets?

Posted: Mon Nov 19, 2012 4:20 pm
by utunnels
I know it has been discussed before.

When I tried that last time, all my images were displayed as white boxes if I printed something.

So I edited Gpyph.cpp to add glBindTexture(GL_TEXTURE_2D, 0) after glDisableClientState. The white box problem was fixed, but for some reason, I noticed the texts had wrong offsets.

For example, if I draw a string at (0, 10), on windows its upper border is at 10, but on android, its lower border is at 10. Any ideas?

Code: Select all

	void Glyph::draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const
	{
		static Matrix t;
		
		t.setTransformation(x, y, angle, sx, sy, ox, oy);

		if(texture != 0)
			glBindTexture(GL_TEXTURE_2D,texture);

		glPushMatrix();

		glMultMatrixf((const GLfloat*)t.getElements());
		glTranslatef(static_cast<float>(data->getBearingX()), static_cast<float>(-data->getBearingY()), 0.0f);

		glEnableClientState(GL_VERTEX_ARRAY);
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
		glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&vertices[0].x);
		glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&vertices[0].s);
		glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		glDisableClientState(GL_VERTEX_ARRAY);
		glBindTexture(GL_TEXTURE_2D, 0);

		glPopMatrix();

	}


Re: ttf fonts are having bad offsets?

Posted: Mon Nov 19, 2012 6:07 pm
by bartbes
That's because the android port is based on an older version of love.

Re: ttf fonts are having bad offsets?

Posted: Tue Nov 20, 2012 12:11 am
by utunnels
Oh thank you.
Now I recall it is based on 0.7...

Re: ttf fonts are having bad offsets?

Posted: Sat Dec 01, 2012 8:42 pm
by hagish
Yes currently it is 0.7.2.