d=backing out my changes, until we can figure out what version of gtk we

need to use.
This commit is contained in:
waqar%netscape.com 2000-08-30 02:38:43 +00:00
Родитель 65cc0d01b7
Коммит 9fb7a1a477
1 изменённых файлов: 0 добавлений и 85 удалений

Просмотреть файл

@ -58,10 +58,6 @@
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
#define GDK_DEFAULT_FONT1 "-*-helvetica-medium-r-*--*-100-*-*-*-*-iso8859-1"
#define GDK_DEFAULT_FONT2 "-*-fixed-medium-r-*-*-*-100-*-*-*-*-*-*"
extern GdkFont *default_font;
nscoord nsDeviceContextGTK::mDpi = 96;
NS_IMPL_ISUPPORTS1(nsDeviceContextGTK, nsIDeviceContext)
@ -358,88 +354,7 @@ NS_IMETHODIMP nsDeviceContextGTK::GetSystemAttribute(nsSystemAttrID anID, System
case eSystemAttr_Font_Field:
case eSystemAttr_Font_Tooltips: // moz
case eSystemAttr_Font_Widget:
aInfo->mFont->style = NS_FONT_STYLE_NORMAL;
aInfo->mFont->weight = NS_FONT_WEIGHT_NORMAL;
aInfo->mFont->decorations = NS_FONT_DECORATION_NONE;
// do we have the default_font defined by GTK/GDK then
// we use it, if not then we load helvetica, if not then
// we load fixed font else we error out.
if ( !theFont )
theFont = default_font; // GTK default font
if ( !theFont )
theFont = ::gdk_font_load (GDK_DEFAULT_FONT1);
if ( !theFont )
theFont = ::gdk_font_load (GDK_DEFAULT_FONT2);
if (!theFont )
{
status = NS_ERROR_FAILURE;
}
else
{
char *fontName, *fontFamily;
GdkFontPrivate *fontPrivate;
XFontStruct *fontInfo;
// XXX I am not sure if I can use this as it is supposed to
// be private.
fontPrivate = (GdkFontPrivate*) theFont;
fontName = PL_strdup( (char *)fontPrivate->names->data);
#ifdef DEBUG_waqar
printf("XXX default font $%s$\n", fontName);
#endif
// XXX strtok is not in NSPR but since this code is on Linux only
// I am using this to parse the name of the font family
fontFamily = strtok(fontName, "-");
fontFamily = strtok((char *)NULL, "-");
aInfo->mFont->name.AssignWithConversion( fontFamily );
PL_strfree(fontName);
fontInfo = (XFontStruct *)GDK_FONT_XFONT(theFont);
unsigned long pr = 0;
::XGetFontProperty(fontInfo, XA_WEIGHT, &pr);
if ( pr > 10 )
aInfo->mFont->weight = NS_FONT_WEIGHT_BOLD;
pr = 0;
::XGetFontProperty(fontInfo, XA_POINT_SIZE, &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;
aInfo->mFont->size = NSIntPointsToTwips( fontSize );
}
pr = 0;
::XGetFontProperty(fontInfo, XA_ITALIC_ANGLE, &pr);
if( pr )
aInfo->mFont->style = NS_FONT_STYLE_ITALIC;
pr = 0;
::XGetFontProperty(fontInfo, XA_UNDERLINE_THICKNESS, &pr);
if( pr )
aInfo->mFont->decorations = NS_FONT_DECORATION_UNDERLINE;
status = NS_OK;
}
break;
} // switch