GLuint m_font;
int m_fontHeight;
+ int m_fontAscent;
+ int m_fontDescent;
/// \brief Renders \p string at the current raster-position of the current context.
void drawString(const char* string) const
GLFont glfont_create(const char* font_string)
{
GLuint font_list_base = glGenLists (256);
- gint font_height = 0;
+ gint font_height = 0, font_ascent = 0, font_descent = 0;
PangoFontDescription* font_desc = pango_font_description_from_string (font_string);
{
PangoFontMetrics* font_metrics = pango_font_get_metrics (font, 0);
- font_height = pango_font_metrics_get_ascent (font_metrics) +
- pango_font_metrics_get_descent (font_metrics);
+ font_ascent = pango_font_metrics_get_ascent (font_metrics);
+ font_descent = pango_font_metrics_get_descent (font_metrics);
+ font_height = font_ascent + font_descent;
+
+ font_ascent = PANGO_PIXELS (font_ascent);
+ font_descent = PANGO_PIXELS (font_descent);
font_height = PANGO_PIXELS (font_height);
pango_font_metrics_unref (font_metrics);
pango_font_description_free (font_desc);
// fix for pango/gtkglext metrix bug
- if(font_height > 16)
+ if(font_height > 256)
font_height = 16;
- return GLFont(font_list_base, font_height);
+ return GLFont(font_list_base, font_ascent, font_descent, font_height);
}
void glfont_release(GLFont& font)
{
glDeleteLists(font.getDisplayList(), 256);
- font = GLFont(0, 0);
+ font = GLFont(0, 0, 0, 0);
}
#endif
{
GLuint m_displayList;
int m_pixelHeight;
+ int m_pixelAscent;
+ int m_pixelDescent;
public:
- GLFont(GLuint displayList, int pixelHeight) : m_displayList(displayList), m_pixelHeight(pixelHeight)
+ GLFont(GLuint displayList, int asc, int desc, int pixelHeight) : m_displayList(displayList), m_pixelHeight(pixelHeight), m_pixelAscent(asc), m_pixelDescent(desc)
{
}
GLuint getDisplayList() const
{
return m_pixelHeight;
}
+ int getPixelAscent() const
+ {
+ return m_pixelAscent;
+ }
+ int getPixelDescent() const
+ {
+ return m_pixelDescent;
+ }
};
GLFont glfont_create(const char* font_string);
if(g_camwindow_globals_private.m_showStats)
{
- glRasterPos3f(1.0f, static_cast<float>(m_Camera.height) - 1.0f, 0.0f);
+ glRasterPos3f(1.0f, static_cast<float>(m_Camera.height) - GlobalOpenGL().m_fontDescent, 0.0f);
extern const char* Renderer_GetStats();
GlobalOpenGL().drawString(Renderer_GetStats());
- glRasterPos3f(1.0f, static_cast<float>(m_Camera.height) - 11.0f, 0.0f);
+ glRasterPos3f(1.0f, static_cast<float>(m_Camera.height) - GlobalOpenGL().m_fontDescent - GlobalOpenGL().m_fontHeight, 0.0f);
extern const char* Cull_GetStats();
GlobalOpenGL().drawString(Cull_GetStats());
}
namespace
{
- GLFont g_font(0, 0);
+ GLFont g_font(0, 0, 0, 0);
}
void GlobalGL_sharedContextCreated()
GlobalOpenGL().m_font = g_font.getDisplayList();
GlobalOpenGL().m_fontHeight = g_font.getPixelHeight();
+ GlobalOpenGL().m_fontAscent = g_font.getPixelAscent();
+ GlobalOpenGL().m_fontDescent = g_font.getPixelDescent();
}
void GlobalGL_sharedContextDestroyed()
// draw coordinate text if needed
if ( g_xywindow_globals_private.show_coordinates) {
glColor3fv(vector3_to_array(g_xywindow_globals.color_gridtext));
- float offx = m_vOrigin[nDim2] + h - 6 / m_fScale, offy = m_vOrigin[nDim1] - w + 1 / m_fScale;
+ float offx = m_vOrigin[nDim2] + h - (1 + GlobalOpenGL().m_fontAscent) / m_fScale;
+ float offy = m_vOrigin[nDim1] - w + 1 / m_fScale;
for (x = xb - fmod(xb, stepx); x <= xe ; x += stepx) {
glRasterPos2f (x, offx);
sprintf (text, "%g", x);