bug 205387 : need to exclude truly invisible default_ignorable_code_points' from draw_string and measurement : patch by YAMASHITA Makoto (makotoy%ms.u-tokyo.ac.jp), r=me, sr=rbs

This commit is contained in:
jshin%mailaps.org 2006-02-23 02:37:47 +00:00
parent 0e4a9b3645
commit b3b3381f83
5 changed files with 17 additions and 12 deletions

View File

@ -44,8 +44,6 @@
#include "nsGfxUtils.h"
#include "nsFontUtils.h"
#define BAD_FONT_NUM -1
nsFontMetricsMac :: nsFontMetricsMac()
{

View File

@ -47,11 +47,12 @@
#include "nsCompressedCharMap.h"
#include "nsMacUnicodeFontInfo.h"
#define BAD_FONT_NUM -1
#define BAD_SCRIPT 0x7f
#include <UnicodeConverter.h>
//------------------------------------------------------------------------
#include "ignorable.x-ccmap"
DEFINE_X_CCMAP(gIgnorableCCMapExt, /* nothing */);
//------------------------------------------------------------------------
static UnicodeToTextInfo gConverters[32] = {
nsnull, nsnull, nsnull, nsnull, nsnull, nsnull, nsnull, nsnull,
@ -502,6 +503,11 @@ short nsUnicodeFontMappingMac::GetFontID(PRUnichar aChar) {
short firstSymbolicFont = BAD_FONT_NUM, firstNonSymbolicFont = BAD_FONT_NUM;
PRInt32 firstSymbolicFontIndex = -1;
// Trap invisible chars
if (CCMAP_HAS_CHAR_EXT(gIgnorableCCMapExt, aChar)) {
return IGNORABLE_FONT_NUM;
}
// find the first symbolic font that has a glyph for aChar
// and if there is one, remember it's index in the font list
for(PRInt32 i = 0; i < mFontList.Count(); i++)

View File

@ -43,6 +43,10 @@
#include "nsFont.h"
#include "nsVoidArray.h"
#define BAD_FONT_NUM -1
#define IGNORABLE_FONT_NUM -2
#define BAD_SCRIPT 0x7f
class nsUnicodeMappingUtil;
class nsUnicodeFontMappingCache;

View File

@ -39,6 +39,7 @@
#include "nsIServiceManager.h"
#include "nsTextFormatter.h"
#include "nsUnicodeMappingUtil.h"
#include "nsUnicodeFontMappingMac.h"
#include "nsDeviceContextMac.h"
#include "nsReadableUtils.h"
#include "nsString.h"
@ -46,8 +47,6 @@
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
#define BAD_FONT_NUM -1
//--------------------------------------------------------------------------
nsUnicodeMappingUtil *nsUnicodeMappingUtil::gSingleton = nsnull;

View File

@ -54,8 +54,6 @@
#include <FixMath.h>
#define BAD_FONT_NUM -1
#define BAD_SCRIPT 0x7F
#define STACK_TRESHOLD 1000
static NS_DEFINE_CID(kSaveAsCharsetCID, NS_SAVEASCHARSET_CID);
@ -1236,7 +1234,7 @@ nsUnicodeRenderingToolkit::GetTextSegmentDimensions(
nsTextDimensions& oDim)
{
oDim.Clear();
if(aLength == 0)
if(aLength == 0 || fontNum == IGNORABLE_FONT_NUM)
return NS_OK;
NS_PRECONDITION(BAD_FONT_NUM != fontNum, "illegal font num");
PRUint32 processLen = 0;
@ -1422,7 +1420,7 @@ nsUnicodeRenderingToolkit::GetTextSegmentBoundingMetrics(
nsBoundingMetrics& oBoundingMetrics)
{
oBoundingMetrics.Clear();
if(aLength == 0)
if(aLength == 0 || fontNum == IGNORABLE_FONT_NUM)
return NS_OK;
NS_PRECONDITION(BAD_FONT_NUM != fontNum, "illegal font num");
PRBool firstTime = PR_TRUE;
@ -1567,7 +1565,7 @@ nsresult nsUnicodeRenderingToolkit :: DrawTextSegment(
short fontNum, nsUnicodeFontMappingMac& fontMapping,
PRInt32 x, PRInt32 y, PRUint32& oWidth)
{
if(aLength == 0) {
if(aLength == 0 || fontNum == IGNORABLE_FONT_NUM) {
oWidth = 0;
return NS_OK;
}