From 11ec3b0b83e9f5adef34eb74e4af70204aa95697 Mon Sep 17 00:00:00 2001 From: "jshin%mailaps.org" Date: Thu, 3 Mar 2005 00:29:30 +0000 Subject: [PATCH] bug 282819 : use NS_ConvertASCIItoUTF16 instead of the manual expansion of ASCII to UTF-16 in nsFontMetricsGTK/Xlib r=smontagu, sr=dbaron git-svn-id: svn://10.0.0.236/trunk@170114 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gfx/src/gtk/nsFontMetricsGTK.cpp | 58 ++++--------------- .../gfx/src/xlib/nsRenderingContextXlib.cpp | 46 ++++----------- 2 files changed, 22 insertions(+), 82 deletions(-) diff --git a/mozilla/gfx/src/gtk/nsFontMetricsGTK.cpp b/mozilla/gfx/src/gtk/nsFontMetricsGTK.cpp index 1f730201698..e6db91a9aab 100644 --- a/mozilla/gfx/src/gtk/nsFontMetricsGTK.cpp +++ b/mozilla/gfx/src/gtk/nsFontMetricsGTK.cpp @@ -3623,18 +3623,9 @@ nsFontMetricsGTK::GetWidth (const char* aString, PRUint32 aLength, gint rawWidth; if (mCurrentFont->IsFreeTypeFont()) { - PRUnichar unichars[WIDEN_8_TO_16_BUF_SIZE]; - - // need to fix this for long strings - PRUint32 len = PR_MIN(aLength, WIDEN_8_TO_16_BUF_SIZE); - - // convert 7 bit data to unicode // this function is only supposed to be called for ascii data - for (PRUint32 i=0; iGetWidth(unichars, len); + rawWidth = mCurrentFont-> + GetWidth(NS_ConvertASCIItoUTF16(aString, aLength).get(), aLength); } else if (!mCurrentFont->GetXFontIs10646()) { NS_ASSERTION(xFont->IsSingleByte(),"wrong string/font size"); @@ -3759,19 +3750,10 @@ nsFontMetricsGTK::DrawString(const char *aString, PRUint32 aLength, aContext->GetTranMatrix()->TransformCoord(&xx, &yy); if (mCurrentFont->IsFreeTypeFont()) { - PRUnichar unichars[WIDEN_8_TO_16_BUF_SIZE]; - - // need to fix this for long strings - PRUint32 len = PR_MIN(aLength, WIDEN_8_TO_16_BUF_SIZE); - - // convert 7 bit data to unicode // this function is only supposed to be called for ascii data - for (PRUint32 i=0; iDrawString(aContext, aSurface, xx, yy, - unichars, len); + rv = mCurrentFont->DrawString(aContext, aSurface, xx, yy, + NS_ConvertASCIItoUTF16(aString, aLength).get(), + aLength); } else if (!mCurrentFont->GetXFontIs10646()) { // 8 bit data with an 8 bit font @@ -3792,19 +3774,10 @@ nsFontMetricsGTK::DrawString(const char *aString, PRUint32 aLength, aContext->GetTranMatrix()->TransformCoord(&x, &y); if (mCurrentFont->IsFreeTypeFont()) { - PRUnichar unichars[WIDEN_8_TO_16_BUF_SIZE]; - - // need to fix this for long strings - PRUint32 len = PR_MIN(aLength, WIDEN_8_TO_16_BUF_SIZE); - - // convert 7 bit data to unicode // this function is only supposed to be called for ascii data - for (PRUint32 i=0; iDrawString(aContext, aSurface, x, y, - unichars, len); + rv = mCurrentFont->DrawString(aContext, aSurface, x, y, + NS_ConvertASCIItoUTF16(aString, aLength).get(), + aLength); } else if (!mCurrentFont->GetXFontIs10646()) { // keep 8 bit path fast // 8 bit data with an 8 bit font @@ -3966,19 +3939,10 @@ nsFontMetricsGTK::GetBoundingMetrics(const char *aString, PRUint32 aLength, nsXFont *xFont = mCurrentFont->GetXFont(); if (mCurrentFont->IsFreeTypeFont()) { - PRUnichar unichars[WIDEN_8_TO_16_BUF_SIZE]; - - // need to fix this for long strings - PRUint32 len = PR_MIN(aLength, WIDEN_8_TO_16_BUF_SIZE); - - // convert 7 bit data to unicode // this function is only supposed to be called for ascii data - for (PRUint32 i=0; iGetBoundingMetrics(unichars, len, - aBoundingMetrics); + rv = mCurrentFont->GetBoundingMetrics( + NS_ConvertASCIItoUTF16(aString, aLength).get(), + aLength, aBoundingMetrics); } else if (!mCurrentFont->GetXFontIs10646()) { // 8 bit data with an 8 bit font diff --git a/mozilla/gfx/src/xlib/nsRenderingContextXlib.cpp b/mozilla/gfx/src/xlib/nsRenderingContextXlib.cpp index 43d4df2237a..699011121b1 100644 --- a/mozilla/gfx/src/xlib/nsRenderingContextXlib.cpp +++ b/mozilla/gfx/src/xlib/nsRenderingContextXlib.cpp @@ -1334,15 +1334,9 @@ nsRenderingContextXlib::GetWidth(const char* aString, PRUint32 aLength, nsXFont *xFont = mCurrentFont->GetXFont(); #ifdef USE_FREETYPE if (mCurrentFont->IsFreeTypeFont()) { - PRUnichar unichars[WIDEN_8_TO_16_BUF_SIZE]; - // need to fix this for long strings - PRUint32 len = PR_MIN(aLength, WIDEN_8_TO_16_BUF_SIZE); - // convert 7 bit data to unicode // this function is only supposed to be called for ascii data - for (PRUint32 i=0; iGetWidth(unichars, len); + rawWidth = mCurrentFont-> + GetWidth(NS_ConvertASCIItoUTF16(aString, aLength).get(), aLength); } else #endif /* USE_FREETYPE */ @@ -2066,16 +2060,10 @@ nsRenderingContextXlib::DrawString(const char *aString, PRUint32 aLength, mTranMatrix->TransformCoord(&xx, &yy); #ifdef USE_FREETYPE if (mCurrentFont->IsFreeTypeFont()) { - PRUnichar unichars[WIDEN_8_TO_16_BUF_SIZE]; - // need to fix this for long strings - PRUint32 len = PR_MIN(aLength, WIDEN_8_TO_16_BUF_SIZE); - // convert 7 bit data to unicode // this function is only supposed to be called for ascii data - for (PRUint32 i=0; iDrawString(this, mSurface, xx, yy, - unichars, len); + res = mCurrentFont->DrawString(this, mSurface, xx, yy, + NS_ConvertASCIItoUTF16(aString, aLength).get(), + aLength); } else #endif /* USE_FREETYPE */ @@ -2097,16 +2085,10 @@ nsRenderingContextXlib::DrawString(const char *aString, PRUint32 aLength, mTranMatrix->TransformCoord(&x, &y); #ifdef USE_FREETYPE if (mCurrentFont->IsFreeTypeFont()) { - PRUnichar unichars[WIDEN_8_TO_16_BUF_SIZE]; - // need to fix this for long strings - PRUint32 len = PR_MIN(aLength, WIDEN_8_TO_16_BUF_SIZE); - // convert 7 bit data to unicode // this function is only supposed to be called for ascii data - for (PRUint32 i=0; iDrawString(this, mSurface, x, y, - unichars, len); + res = mCurrentFont->DrawString(this, mSurface, x, y, + NS_ConvertASCIItoUTF16(aString, aLength).get(), + aLength); } else #endif /* USE_FREETYPE */ @@ -2379,16 +2361,10 @@ nsRenderingContextXlib::GetBoundingMetrics(const char* aString, nsXFont *xFont = mCurrentFont->GetXFont(); #ifdef USE_FREETYPE if (mCurrentFont->IsFreeTypeFont()) { - PRUnichar unichars[WIDEN_8_TO_16_BUF_SIZE]; - // need to fix this for long strings - PRUint32 len = PR_MIN(aLength, WIDEN_8_TO_16_BUF_SIZE); - // convert 7 bit data to unicode // this function is only supposed to be called for ascii data - for (PRUint32 i=0; iGetBoundingMetrics(unichars, len, - aBoundingMetrics); + res = mCurrentFont->GetBoundingMetrics( + NS_ConvertASCIItoUTF16(aString, aLength).get(), + aLength, aBoundingMetrics); } else #endif /* USE_FREETYPE */