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 method Font::Size and std::abs on Font::Height don't work perfectly.

Use Canvas::TextHeight on a random string instead.

* View the code of 'GetFontHeight' in plain text.

 

 

//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.