webengine/wmlengine/src/gdi/src/GDIDeviceContext.cpp
changeset 1 7c90e6132015
parent 0 dd21522fd290
child 26 cb62a4f66ebe
--- a/webengine/wmlengine/src/gdi/src/GDIDeviceContext.cpp	Mon Mar 30 12:54:55 2009 +0300
+++ b/webengine/wmlengine/src/gdi/src/GDIDeviceContext.cpp	Fri May 08 08:25:06 2009 +0300
@@ -1216,13 +1216,18 @@
     InitializeGraphicsContext();
     gc->UseFont(epocFont);
 
+    //Calculate Baseline offset
+    //Baseline is calculated as (Height + ascent in pixels - descent in pixels) /2
+    //iDisplayBounds and iOrigin are kept as it is to make sure drawing is respective to
+    //display bound
+    TInt heightInPixels = epocFont->HeightInPixels();
     TInt descentInPixels = epocFont->DescentInPixels();
-
+    TInt acsentInPixels = epocFont->FontMaxAscent();
+    TInt baseLineOffset = (iDisplayBounds.point.y) + (heightInPixels + acsentInPixels - descentInPixels ) / (2) - iOrigin.y; 
+    
     TPtrC ptrC(string);
-    TPoint point( aLocation->x - iOrigin.x + iDisplayBounds.point.x+1,
-                  aLocation->y + epocFont->HeightInPixels()
-                  - descentInPixels - iOrigin.y +
-                  iDisplayBounds.point.y +1);
+    TPoint point( aLocation->x - iOrigin.x + iDisplayBounds.point.x,
+                  aLocation->y + baseLineOffset);
 
     if (aDecoration & NW_GDI_TextDecoration_Underline) {
       gc->SetUnderlineStyle(EUnderlineOn);