fix bug 50816. add if statement for prevFont so it won't crash on win95J while prevFont is null (when we try to render a

Unicode which do not have glyph in any font on the system.
r=buster,erik a=buster.
This commit is contained in:
ftang%netscape.com 2000-09-20 23:13:12 +00:00
parent cecb8d2d14
commit 90c1083f5c

View File

@ -2209,7 +2209,10 @@ nsRenderingContextWin::GetWidth(const PRUnichar *aString,
fontMetricsWin->GetSpaceWidth(twWidth);
} else {
pxWidth = prevFont->GetWidth(mDC, &pstr[start], numChars);
if(prevFont)
pxWidth = prevFont->GetWidth(mDC, &pstr[start], numChars);
else
pxWidth = 0;
twWidth = NSToCoordRound(float(pxWidth) * mP2T);
}
@ -2263,7 +2266,7 @@ nsRenderingContextWin::GetWidth(const PRUnichar *aString,
breakIndex = 0;
if (aBreaks[breakIndex] < i)
{
while (aBreaks[breakIndex + 1] < i) {
while (((breakIndex + 1) < aNumBreaks) && (aBreaks[breakIndex + 1] < i)) {
breakIndex++;
}
}
@ -2287,7 +2290,10 @@ nsRenderingContextWin::GetWidth(const PRUnichar *aString,
fontMetricsWin->GetSpaceWidth(twWidth);
} else {
pxWidth = prevFont->GetWidth(mDC, &pstr[start], numChars);
if(prevFont)
pxWidth = prevFont->GetWidth(mDC, &pstr[start], numChars);
else
pxWidth =0;
twWidth = NSToCoordRound(float(pxWidth) * mP2T);
}
@ -3451,7 +3457,8 @@ nsRenderingContextWinA::GetWidth(const PRUnichar *aString,
while (aBreaks[breakIndex + 1] <= estimatedBreakOffset) {
breakIndex++;
}
NS_ASSERTION(aBreaks[breakIndex] <= estimatedBreakOffset, "bad break index");
if (breakIndex == -1)
breakIndex = 0;
// We found a place to break that is before the estimated break
// offset. Where we break depends on whether the text crosses a
@ -3488,7 +3495,10 @@ nsRenderingContextWinA::GetWidth(const PRUnichar *aString,
fontMetricsWin->GetSpaceWidth(twWidth);
} else {
pxWidth = prevFont->GetWidth(mDC, &pstr[start], numChars);
if(prevFont)
pxWidth = prevFont->GetWidth(mDC, &pstr[start], numChars);
else
pxWidth =0;
twWidth = NSToCoordRound(float(pxWidth) * mP2T);
}
@ -3540,8 +3550,12 @@ nsRenderingContextWinA::GetWidth(const PRUnichar *aString,
i = start + numChars;
if (breakIndex == -1) {
breakIndex = 0;
while (aBreaks[breakIndex + 1] < i) {
breakIndex++;
if (aBreaks[breakIndex] < i)
{
while (((breakIndex + 1) < aNumBreaks) && (aBreaks[breakIndex + 1] < i)) {
breakIndex++;
}
}
}
@ -3563,7 +3577,10 @@ nsRenderingContextWinA::GetWidth(const PRUnichar *aString,
fontMetricsWin->GetSpaceWidth(twWidth);
} else {
pxWidth = prevFont->GetWidth(mDC, &pstr[start], numChars);
if(prevFont)
pxWidth = prevFont->GetWidth(mDC, &pstr[start], numChars);
else
pxWidth =0;
twWidth = NSToCoordRound(float(pxWidth) * mP2T);
}