bug 282819 : use NS_ConvertASCIItoUTF16 instead of the manual expansion of ASCII to UTF-16 in nsFontMetricsGTK/Xlib r=smontagu, sr=dbaron

This commit is contained in:
jshin%mailaps.org 2005-03-03 00:29:30 +00:00
Родитель d1eee00bc1
Коммит 0a34526337
2 изменённых файлов: 22 добавлений и 82 удалений

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

@ -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; i<len; i++) {
unichars[i] = (PRUnichar)((unsigned char)aString[i]);
}
rawWidth = mCurrentFont->GetWidth(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; i<len; i++) {
unichars[i] = (PRUnichar)((unsigned char)aString[i]);
}
rv = mCurrentFont->DrawString(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; i<len; i++) {
unichars[i] = (PRUnichar)((unsigned char)aString[i]);
}
rv = mCurrentFont->DrawString(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; i<len; i++) {
unichars[i] = (PRUnichar)((unsigned char)aString[i]);
}
rv = mCurrentFont->GetBoundingMetrics(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

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

@ -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; i<len; i++) {
unichars[i] = (PRUnichar)((unsigned char)aString[i]);
}
rawWidth = mCurrentFont->GetWidth(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; i<len; i++) {
unichars[i] = (PRUnichar)((unsigned char)aString[i]);
}
res = mCurrentFont->DrawString(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; i<len; i++) {
unichars[i] = (PRUnichar)((unsigned char)aString[i]);
}
res = mCurrentFont->DrawString(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; i<len; i++) {
unichars[i] = (PRUnichar)((unsigned char)aString[i]);
}
res = mCurrentFont->GetBoundingMetrics(unichars, len,
aBoundingMetrics);
res = mCurrentFont->GetBoundingMetrics(
NS_ConvertASCIItoUTF16(aString, aLength).get(),
aLength, aBoundingMetrics);
}
else
#endif /* USE_FREETYPE */