Add <U+ > for Unicode fallback instead of ?

This commit is contained in:
ftang%netscape.com 1999-12-02 23:26:42 +00:00
Родитель 6ada3ddd02
Коммит 331338ca67
2 изменённых файлов: 43 добавлений и 0 удалений

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

@ -26,6 +26,7 @@
#include "nsTransform2D.h" #include "nsTransform2D.h"
#include "nsFontMetricsMac.h" #include "nsFontMetricsMac.h"
#include "nsGraphicState.h" #include "nsGraphicState.h"
#include "prprf.h"
#define BAD_FONT_NUM -1 #define BAD_FONT_NUM -1
#define BAD_SCRIPT 0x7F #define BAD_SCRIPT 0x7F
@ -33,6 +34,7 @@
//#define DISABLE_TEC_FALLBACK //#define DISABLE_TEC_FALLBACK
#define DISABLE_ATSUI_FALLBACK #define DISABLE_ATSUI_FALLBACK
//#define DISABLE_UPLUS_FALLBACK
@ -245,6 +247,32 @@ PRBool nsUnicodeRenderingToolkit :: QuestionMarkFallbackDrawChar(
DrawScriptText(question, 3, x, y, oWidth); DrawScriptText(question, 3, x, y, oWidth);
return PR_TRUE; return PR_TRUE;
} }
//------------------------------------------------------------------------
PRBool nsUnicodeRenderingToolkit :: UPlusFallbackGetWidth(
const PRUnichar *aCharPt,
short& oWidth)
{
char buf[16];
PRUint32 len = PR_snprintf(buf, 16 , "<U+%04X>", *aCharPt);
if(len != -1)
GetScriptTextWidth(buf, len, oWidth);
return (-1 != len);
}
//------------------------------------------------------------------------
PRBool nsUnicodeRenderingToolkit :: UPlusFallbackDrawChar(
const PRUnichar *aCharPt,
PRInt32 x,
PRInt32 y,
short& oWidth)
{
char buf[16];
PRUint32 len = PR_snprintf(buf, 16 , "<U+%04X>", *aCharPt);
if(len != -1)
DrawScriptText(buf, len, x, y, oWidth);
return (-1 != len);
}
//------------------------------------------------------------------------ //------------------------------------------------------------------------
void nsUnicodeRenderingToolkit :: GetScriptTextWidth( void nsUnicodeRenderingToolkit :: GetScriptTextWidth(
@ -361,6 +389,12 @@ nsresult nsUnicodeRenderingToolkit :: GetTextSegmentWidth(
mGS->mColor ); mGS->mColor );
} }
#endif #endif
#ifndef DISABLE_UPLUS_FALLBACK
// Fallback to UPlus
if(! fallbackDone)
fallbackDone = UPlusFallbackGetWidth(aString, thisWidth);
#endif
// Fallback to question mark // Fallback to question mark
if(! fallbackDone) if(! fallbackDone)
QuestionMarkFallbackGetWidth(aString, thisWidth); QuestionMarkFallbackGetWidth(aString, thisWidth);
@ -477,6 +511,12 @@ nsresult nsUnicodeRenderingToolkit :: DrawTextSegment(
mGS->mColor ); mGS->mColor );
} }
#endif #endif
#ifndef DISABLE_UPLUS_FALLBACK
// Fallback to U+xxxx
if(! fallbackDone)
fallbackDone = UPlusFallbackDrawChar(aString, x, y, thisWidth);
#endif
// Fallback to question mark // Fallback to question mark
if(! fallbackDone) if(! fallbackDone)
QuestionMarkFallbackDrawChar(aString, x, y, thisWidth); QuestionMarkFallbackDrawChar(aString, x, y, thisWidth);

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

@ -50,6 +50,9 @@ private:
PRBool ATSUIFallbackGetWidth(const PRUnichar *pChar, short& oWidth, short fontNum, short aSize, PRBool aBold, PRBool aItalic, nscolor aColor); PRBool ATSUIFallbackGetWidth(const PRUnichar *pChar, short& oWidth, short fontNum, short aSize, PRBool aBold, PRBool aItalic, nscolor aColor);
PRBool ATSUIFallbackDrawChar(const PRUnichar *pChar, PRInt32 x, PRInt32 y, short& oWidth, short fontNum, short aSize, PRBool aBold, PRBool aItalic, nscolor aColor); PRBool ATSUIFallbackDrawChar(const PRUnichar *pChar, PRInt32 x, PRInt32 y, short& oWidth, short fontNum, short aSize, PRBool aBold, PRBool aItalic, nscolor aColor);
PRBool UPlusFallbackGetWidth(const PRUnichar *pChar, short& oWidth);
PRBool UPlusFallbackDrawChar(const PRUnichar *pChar, PRInt32 x, PRInt32 y, short& oWidth);
PRBool QuestionMarkFallbackGetWidth(const PRUnichar *pChar, short& oWidth); PRBool QuestionMarkFallbackGetWidth(const PRUnichar *pChar, short& oWidth);
PRBool QuestionMarkFallbackDrawChar(const PRUnichar *pChar, PRInt32 x, PRInt32 y, short& oWidth); PRBool QuestionMarkFallbackDrawChar(const PRUnichar *pChar, PRInt32 x, PRInt32 y, short& oWidth);