Added support for *-iso10646-1 fonts. Variable width only for now, fixed
width will be supported later through font property. git-svn-id: svn://10.0.0.236/trunk@38571 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -887,6 +887,26 @@ DoubleByteConvert(nsFontCharSetInfo* aSelf, const PRUnichar* aSrcBuf,
|
||||
return count;
|
||||
}
|
||||
|
||||
static gint
|
||||
ISO10646Convert(nsFontCharSetInfo* aSelf, const PRUnichar* aSrcBuf,
|
||||
PRInt32 aSrcLen, char* aDestBuf, PRInt32 aDestLen)
|
||||
{
|
||||
aDestLen /= 2;
|
||||
if (aSrcLen > aDestLen) {
|
||||
aSrcLen = aDestLen;
|
||||
}
|
||||
if (aSrcLen < 0) {
|
||||
aSrcLen = 0;
|
||||
}
|
||||
XChar2b* dest = (XChar2b*) aDestBuf;
|
||||
for (PRInt32 i = 0; i < aSrcLen; i++) {
|
||||
dest[i].byte1 = (aSrcBuf[i] >> 8);
|
||||
dest[i].byte2 = (aSrcBuf[i] & 0xFF);
|
||||
}
|
||||
|
||||
return (gint) aSrcLen * 2;
|
||||
}
|
||||
|
||||
static void
|
||||
SetUpFontCharSetInfo(nsFontCharSetInfo* aSelf)
|
||||
{
|
||||
@@ -965,6 +985,9 @@ static nsFontCharSetInfo JISX0212 =
|
||||
static nsFontCharSetInfo KSC5601 =
|
||||
{ "ks_c_5601-1987", DoubleByteConvert, 1 };
|
||||
|
||||
static nsFontCharSetInfo ISO106461 =
|
||||
{ nsnull, ISO10646Convert, 1 };
|
||||
|
||||
/*
|
||||
* Normally, the charset of an X font can be determined simply by looking at
|
||||
* the last 2 fields of the long XLFD font name (CHARSET_REGISTRY and
|
||||
@@ -1042,7 +1065,7 @@ static nsFontCharSetMap gCharSetMap[] =
|
||||
{ "iso8859-7", &ISO88597 },
|
||||
{ "iso8859-8", &ISO88598 },
|
||||
{ "iso8859-9", &ISO88599 },
|
||||
{ "iso10646-1", &Ignore },
|
||||
{ "iso10646-1", &ISO106461 },
|
||||
{ "jisx0201.1976-0", &JISX0201 },
|
||||
{ "jisx0201.1976-1", &JISX0201 },
|
||||
{ "jisx0208.1983-0", &JISX0208 },
|
||||
@@ -1173,14 +1196,54 @@ GetUnderlineInfo(XFontStruct* aFont, unsigned long* aPositionX2,
|
||||
}
|
||||
}
|
||||
|
||||
static PRUint32*
|
||||
GetMapFor10646Font(XFontStruct* aFont)
|
||||
{
|
||||
PRUint32* map = (PRUint32*) PR_Calloc(2048, 4);
|
||||
if (map) {
|
||||
if (aFont->per_char) {
|
||||
PRInt32 minByte1 = aFont->min_byte1;
|
||||
PRInt32 maxByte1 = aFont->max_byte1;
|
||||
PRInt32 minByte2 = aFont->min_char_or_byte2;
|
||||
PRInt32 maxByte2 = aFont->max_char_or_byte2;
|
||||
PRInt32 charsPerRow = maxByte2 - minByte2 + 1;
|
||||
for (PRInt32 row = minByte1; row <= maxByte1; row++) {
|
||||
PRInt32 offset = (((row - minByte1) * charsPerRow) - minByte2);
|
||||
for (PRInt32 cell = minByte2; cell <= maxByte2; cell++) {
|
||||
XCharStruct* bounds = &aFont->per_char[offset + cell];
|
||||
if ((!bounds->ascent) && (!bounds->descent)) {
|
||||
SET_REPRESENTABLE(map, (row << 8) | cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
// XXX look at glyph ranges property, if any
|
||||
PR_Free(map);
|
||||
map = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
void
|
||||
nsFontGTK::LoadFont(nsFontCharSet* aCharSet, nsFontMetricsGTK* aMetrics)
|
||||
{
|
||||
GdkFont* gdkFont = ::gdk_font_load(mName);
|
||||
if (gdkFont) {
|
||||
mFont = gdkFont;
|
||||
mMap = aCharSet->mInfo->mMap;
|
||||
XFontStruct* xFont = (XFontStruct*) GDK_FONT_XFONT(gdkFont);
|
||||
if (aCharSet->mInfo->mCharSet) {
|
||||
mMap = aCharSet->mInfo->mMap;
|
||||
}
|
||||
else {
|
||||
mMap = GetMapFor10646Font(xFont);
|
||||
if (!mMap) {
|
||||
::gdk_font_unref(gdkFont);
|
||||
return;
|
||||
}
|
||||
}
|
||||
mFont = gdkFont;
|
||||
mActualSize = xFont->max_bounds.ascent + xFont->max_bounds.descent;
|
||||
if (aCharSet->mInfo->mSpecialUnderline) {
|
||||
XFontStruct* asciiXFont =
|
||||
@@ -1347,6 +1410,12 @@ PickASizeAndLoad(nsFontSearch* aSearch, nsFontStretch* aStretch,
|
||||
}
|
||||
}
|
||||
|
||||
if (!aCharSet->mInfo->mCharSet) {
|
||||
if (!IS_REPRESENTABLE(s->mMap, aSearch->mChar)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (m->mLoadedFontsCount == m->mLoadedFontsAlloc) {
|
||||
int newSize;
|
||||
if (m->mLoadedFontsAlloc) {
|
||||
@@ -1654,16 +1723,18 @@ SearchCharSet(PLHashEntry* he, PRIntn i, void* arg)
|
||||
PRUint32* map = charSetInfo->mMap;
|
||||
nsFontSearch* search = (nsFontSearch*) arg;
|
||||
PRUnichar c = search->mChar;
|
||||
if (!map) {
|
||||
map = (PRUint32*) PR_Calloc(2048, 4);
|
||||
if (charSetInfo->mCharSet) {
|
||||
if (!map) {
|
||||
map = (PRUint32*) PR_Calloc(2048, 4);
|
||||
if (!map) {
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
charSetInfo->mMap = map;
|
||||
SetUpFontCharSetInfo(charSetInfo);
|
||||
}
|
||||
if (!IS_REPRESENTABLE(map, c)) {
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
charSetInfo->mMap = map;
|
||||
SetUpFontCharSetInfo(charSetInfo);
|
||||
}
|
||||
if (!IS_REPRESENTABLE(map, c)) {
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
|
||||
TryCharSet(search, charSet);
|
||||
|
||||
Reference in New Issue
Block a user