From: Luca C. <luc...@se...> - 2009-03-11 17:08:44
|
Hello, I wrote a simple function which draws a string with the its bounding box centered to the given pCenter parameter: void drawCenteredText (wxPdfDocument& pPDF, wxString const& pString, Vector2f const& pCenter) { float lHeightMM = float (pPDF.GetFontSize ()) / 72.f * 2.54f / 10.f; //Height in mm. double lWidthMM = pPDF.GetStringWidth (pString);//Width in mm. pPDF.SetXY (pCenter.x - lWidthMM / 2.f, pCenter.y - lHeightMM / 2.f); pPDF.Cell (0, 0, pString); } To roughly center the string I need to know how much the actual font height is in millimeters, and for that purpose i use a formula that converts points to mm, assuming that a point is 1/72 inch, and then I convert inch to mm. Is there any better way than this approach? Greetings, Luca |