Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) GetFontHeight

 

Function to get the height of a Font in pixels.

The member function Font::Size and std::abs on Font::Height don't work perfectly.

Use Canvas::TextHeight on a random string instead.

 

//From http://www.richelbilderbeek.nl/CppGetFontHeight.htm
const int GetFontHeight(const TImage * const image)
{
  // const_cast necessary as the VCL is not const-correct. Grumble, grumble...
  return const_cast<TImage*>(image)->Canvas->TextHeight("x");
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict