From 75458f69c476fd4bd9ace92e12e4bb6be72c0c18 Mon Sep 17 00:00:00 2001 From: "waqar%netscape.com" Date: Thu, 14 Sep 2000 18:57:05 +0000 Subject: [PATCH] #=48907 r=pavlov@netscape.com d=Get the font size using the pixel size instead of the point size. Pixel size seems to work better for non default resolutions. --- gfx/src/gtk/nsDeviceContextGTK.cpp | 25 +++++-------------------- gfx/src/gtk/nsDeviceContextGTK.h | 2 ++ 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/gfx/src/gtk/nsDeviceContextGTK.cpp b/gfx/src/gtk/nsDeviceContextGTK.cpp index cfb2c6048e97..5d45b401c523 100644 --- a/gfx/src/gtk/nsDeviceContextGTK.cpp +++ b/gfx/src/gtk/nsDeviceContextGTK.cpp @@ -61,7 +61,6 @@ static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); #define GDK_DEFAULT_FONT1 "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1" #define GDK_DEFAULT_FONT2 "-*-fixed-medium-r-*-*-*-120-*-*-*-*-*-*" extern GdkFont *default_font; -nsresult GetSystemFontInfo(GdkFont* iFont, nsSystemAttrID anID, nsFont* aFont); nscoord nsDeviceContextGTK::mDpi = 96; @@ -538,7 +537,8 @@ int nsDeviceContextGTK::prefChanged(const char *aPref, void *aClosure) return 0; } -nsresult GetSystemFontInfo( GdkFont* iFont, nsSystemAttrID anID, nsFont* aFont) +nsresult +nsDeviceContextGTK::GetSystemFontInfo( GdkFont* iFont, nsSystemAttrID anID, nsFont* aFont) const { nsresult status = NS_OK; GdkFont *theFont = iFont; @@ -589,25 +589,10 @@ nsresult GetSystemFontInfo( GdkFont* iFont, nsSystemAttrID anID, nsFont* aFont) aFont->weight = NS_FONT_WEIGHT_BOLD; pr = 0; - ::XGetFontProperty( fontInfo, XA_POINT_SIZE, &pr ); + Atom pixelSizeAtom = ::XInternAtom(gdk_display, "PIXEL_SIZE", 0); + ::XGetFontProperty( fontInfo, pixelSizeAtom, &pr ); if( pr ) - { - int fontSize = pr/10; - // Per rods@netscape.com, the default size of 12 is too large - // we need to bump it down two points. - if( anID == eSystemAttr_Font_Button || - anID == eSystemAttr_Font_Field || - anID == eSystemAttr_Font_List || - anID == eSystemAttr_Font_Widget || - anID == eSystemAttr_Font_Caption ) - fontSize -= 2; - - // if we are below 1 then we have a problem we just make it 1 - if( fontSize < 1 ) - fontSize = 1; - - aFont->size = NSIntPointsToTwips( fontSize ); - } + aFont->size = NSIntPixelsToTwips(pr, mPixelsToTwips); pr = 0; ::XGetFontProperty( fontInfo, XA_ITALIC_ANGLE, &pr ); diff --git a/gfx/src/gtk/nsDeviceContextGTK.h b/gfx/src/gtk/nsDeviceContextGTK.h index d27048d05da8..0cf480022baf 100644 --- a/gfx/src/gtk/nsDeviceContextGTK.h +++ b/gfx/src/gtk/nsDeviceContextGTK.h @@ -91,6 +91,8 @@ private: float mHeightFloat; PRInt32 mWidth; PRInt32 mHeight; + + nsresult GetSystemFontInfo(GdkFont* iFont, nsSystemAttrID anID, nsFont* aFont) const; }; #endif /* nsDeviceContextGTK_h___ */