Fix for bug 7841. Some fonts return bad glyph IDs. Now checking for these.

It turns out that GulimChe is one of those bad fonts.
This commit is contained in:
erik%netscape.com 1999-06-16 03:57:55 +00:00
Родитель 9113d8f716
Коммит 15179a0b0c
1 изменённых файлов: 19 добавлений и 12 удалений

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

@ -304,7 +304,7 @@ GetIndexToLocFormat(HDC aDC)
}
static PRUint8*
GetSpaces(HDC aDC)
GetSpaces(HDC aDC, PRUint32* aMaxGlyph)
{
int isLong = GetIndexToLocFormat(aDC);
if (isLong < 0) {
@ -325,6 +325,7 @@ GetSpaces(HDC aDC)
}
if (isLong) {
DWORD longLen = ((len / 4) - 1);
*aMaxGlyph = longLen;
PRUint32* longBuf = (PRUint32*) buf;
for (PRUint32 i = 0; i < longLen; i++) {
if (longBuf[i] == longBuf[i+1]) {
@ -337,6 +338,7 @@ GetSpaces(HDC aDC)
}
else {
DWORD shortLen = ((len / 2) - 1);
*aMaxGlyph = shortLen;
PRUint16* shortBuf = (PRUint16*) buf;
for (PRUint16 i = 0; i < shortLen; i++) {
if (shortBuf[i] == shortBuf[i+1]) {
@ -472,7 +474,8 @@ nsFontMetricsWin::GetCMAP(HDC aDC)
}
SET_SPACE(0x3000);
}
PRUint8* isSpace = GetSpaces(aDC);
PRUint32 maxGlyph;
PRUint8* isSpace = GetSpaces(aDC, &maxGlyph);
if (!isSpace) {
PR_Free(buf);
delete name;
@ -490,14 +493,16 @@ nsFontMetricsWin::GetCMAP(HDC aDC)
if ((PRUint8*) g < end) {
if (*g) {
PRUint16 glyph = idDelta[i] + *g;
if (isSpace[glyph]) {
if (SHOULD_BE_SPACE(c)) {
if (glyph < maxGlyph) {
if (isSpace[glyph]) {
if (SHOULD_BE_SPACE(c)) {
ADD_GLYPH(map, c);
}
}
else {
ADD_GLYPH(map, c);
}
}
else {
ADD_GLYPH(map, c);
}
}
}
else {
@ -510,14 +515,16 @@ nsFontMetricsWin::GetCMAP(HDC aDC)
PRUint16 endC = endCode[i];
for (PRUint32 c = startCode[i]; c <= endC; c++) {
PRUint16 glyph = idDelta[i] + c;
if (isSpace[glyph]) {
if (SHOULD_BE_SPACE(c)) {
if (glyph < maxGlyph) {
if (isSpace[glyph]) {
if (SHOULD_BE_SPACE(c)) {
ADD_GLYPH(map, c);
}
}
else {
ADD_GLYPH(map, c);
}
}
else {
ADD_GLYPH(map, c);
}
}
//printf("0x%04X-0x%04X ", startCode[i], endC);
}