From 5eeeba2ff6d51f457e304bb5941e474ab683dbf2 Mon Sep 17 00:00:00 2001 From: "erik%netscape.com" Date: Thu, 13 Jul 2000 21:13:13 +0000 Subject: [PATCH] bug 39570; we were using the Western font to determine the height of the URL bar, and this caused the Japanese text to be truncated; we now use the locale's language group when the caller does not pass us the correct one; r=nhotta git-svn-id: svn://10.0.0.236/trunk@74180 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gfx/public/nsDeviceContext.h | 3 ++- mozilla/gfx/src/nsDeviceContext.cpp | 25 ++++++++++++++++++++---- mozilla/gfx/src/ps/nsDeviceContextPS.cpp | 4 ++-- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/mozilla/gfx/public/nsDeviceContext.h b/mozilla/gfx/public/nsDeviceContext.h index 106a09335fb..884d7af65bd 100644 --- a/mozilla/gfx/public/nsDeviceContext.h +++ b/mozilla/gfx/public/nsDeviceContext.h @@ -100,13 +100,14 @@ protected: nsresult AliasFont(const nsString& aFont, const nsString& aAlias, const nsString& aAltAlias, PRBool aForceAlias); + void GetLocaleLangGroup(void); float mTwipsToPixels; float mPixelsToTwips; float mAppUnitsToDevUnits; float mDevUnitsToAppUnits; nsFontCache *mFontCache; - nsCOMPtr mWestern; // XXX temporary fix for performance bug - erik + nsCOMPtr mLocaleLangGroup; // XXX temp fix for performance bug - erik float mZoom; float mTextZoom; float mGammaValue; diff --git a/mozilla/gfx/src/nsDeviceContext.cpp b/mozilla/gfx/src/nsDeviceContext.cpp index 5e2de185807..0cf7a68d774 100644 --- a/mozilla/gfx/src/nsDeviceContext.cpp +++ b/mozilla/gfx/src/nsDeviceContext.cpp @@ -37,6 +37,8 @@ #include "nsVoidArray.h" #include "nsIFontMetrics.h" #include "nsHashtable.h" +#include "nsILanguageAtomService.h" +#include "nsIServiceManager.h" class nsFontCache { @@ -236,6 +238,21 @@ nsresult DeviceContextImpl::CreateFontCache() return NS_OK; } +void +DeviceContextImpl::GetLocaleLangGroup(void) +{ + if (!mLocaleLangGroup) { + nsCOMPtr langService; + langService = do_GetService(NS_LANGUAGEATOMSERVICE_PROGID); + if (langService) { + langService->GetLocaleLanguageGroup(getter_AddRefs(mLocaleLangGroup)); + } + if (!mLocaleLangGroup) { + mLocaleLangGroup = getter_AddRefs(NS_NewAtom("x-western")); + } + } +} + NS_IMETHODIMP DeviceContextImpl::GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup, nsIFontMetrics*& aMetrics) { @@ -246,12 +263,12 @@ NS_IMETHODIMP DeviceContextImpl::GetMetricsFor(const nsFont& aFont, return rv; } // XXX temporary fix for performance problem -- erik - mWestern = getter_AddRefs(NS_NewAtom("x-western")); + GetLocaleLangGroup(); } // XXX figure out why aLangGroup is NULL sometimes if (!aLangGroup) { - aLangGroup = mWestern; + aLangGroup = mLocaleLangGroup; } return mFontCache->GetMetricsFor(aFont, aLangGroup, aMetrics); @@ -266,9 +283,9 @@ NS_IMETHODIMP DeviceContextImpl::GetMetricsFor(const nsFont& aFont, nsIFontMetri return rv; } // XXX temporary fix for performance problem -- erik - mWestern = getter_AddRefs(NS_NewAtom("x-western")); + GetLocaleLangGroup(); } - return mFontCache->GetMetricsFor(aFont, mWestern, aMetrics); + return mFontCache->GetMetricsFor(aFont, mLocaleLangGroup, aMetrics); } NS_IMETHODIMP DeviceContextImpl :: SetZoom(float aZoom) diff --git a/mozilla/gfx/src/ps/nsDeviceContextPS.cpp b/mozilla/gfx/src/ps/nsDeviceContextPS.cpp index 3d40e3d3fa1..e641cadf4f1 100644 --- a/mozilla/gfx/src/ps/nsDeviceContextPS.cpp +++ b/mozilla/gfx/src/ps/nsDeviceContextPS.cpp @@ -369,8 +369,8 @@ NS_IMETHODIMP nsDeviceContextPS :: ConvertPixel(nscolor aColor, PRUint32 & aPixe */ NS_IMETHODIMP nsDeviceContextPS::GetMetricsFor(const nsFont& aFont, nsIFontMetrics *&aMetrics) { - mWestern = getter_AddRefs(NS_NewAtom("x-western")); - return GetMetricsFor(aFont, mWestern, aMetrics); + GetLocaleLangGroup(); + return GetMetricsFor(aFont, mLocaleLangGroup, aMetrics); } NS_IMETHODIMP nsDeviceContextPS::GetMetricsFor(const nsFont& aFont, nsIAtom* aLangGroup, nsIFontMetrics *&aMetrics)