Added support for special treatments (use 2 or more fonts, codepage
conversion, etc...) for DBCS text.
This commit is contained in:
parent
9b1e1dc4c5
commit
c86cb24ec2
|
@ -10,6 +10,7 @@ C_SRCS = \
|
||||||
bitmap.c \
|
bitmap.c \
|
||||||
brush.c \
|
brush.c \
|
||||||
clipping.c \
|
clipping.c \
|
||||||
|
codepage.c \
|
||||||
dib.c \
|
dib.c \
|
||||||
graphics.c \
|
graphics.c \
|
||||||
init.c \
|
init.c \
|
||||||
|
|
|
@ -0,0 +1,262 @@
|
||||||
|
/*
|
||||||
|
* X11 codepage handling
|
||||||
|
*
|
||||||
|
* Copyright 2000 Hidenori Takeshima <hidenori@a2.ctktv.ne.jp>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "ts_xlib.h"
|
||||||
|
|
||||||
|
#include "windef.h"
|
||||||
|
#include "winnls.h"
|
||||||
|
#include "heap.h"
|
||||||
|
#include "x11font.h"
|
||||||
|
#include "debugtools.h"
|
||||||
|
|
||||||
|
DEFAULT_DEBUG_CHANNEL(text);
|
||||||
|
|
||||||
|
|
||||||
|
static XChar2b* X11DRV_unicode_to_char2b_sbcs( fontObject* pfo,
|
||||||
|
LPCWSTR lpwstr, UINT count )
|
||||||
|
{
|
||||||
|
XChar2b *str2b;
|
||||||
|
UINT i;
|
||||||
|
BYTE *str;
|
||||||
|
UINT codepage = pfo->fi->codepage;
|
||||||
|
char ch = pfo->fs->default_char;
|
||||||
|
|
||||||
|
if (!(str2b = HeapAlloc( GetProcessHeap(), 0, count * sizeof(XChar2b) )))
|
||||||
|
return NULL;
|
||||||
|
if (!(str = HeapAlloc( GetProcessHeap(), 0, count )))
|
||||||
|
{
|
||||||
|
HeapFree( GetProcessHeap(), 0, str2b );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
WideCharToMultiByte( codepage, 0, lpwstr, count, str, count, &ch, NULL );
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
str2b[i].byte1 = 0;
|
||||||
|
str2b[i].byte2 = str[i];
|
||||||
|
}
|
||||||
|
HeapFree( GetProcessHeap(), 0, str );
|
||||||
|
|
||||||
|
return str2b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static XChar2b* X11DRV_unicode_to_char2b_unicode( fontObject* pfo,
|
||||||
|
LPCWSTR lpwstr, UINT count )
|
||||||
|
{
|
||||||
|
XChar2b *str2b;
|
||||||
|
UINT i;
|
||||||
|
|
||||||
|
if (!(str2b = HeapAlloc( GetProcessHeap(), 0, count * sizeof(XChar2b) )))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
str2b[i].byte1 = lpwstr[i] >> 8;
|
||||||
|
str2b[i].byte2 = lpwstr[i] & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
return str2b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME: handle jisx0212.1990... */
|
||||||
|
static XChar2b* X11DRV_unicode_to_char2b_cp932( fontObject* pfo,
|
||||||
|
LPCWSTR lpwstr, UINT count )
|
||||||
|
{
|
||||||
|
XChar2b *str2b;
|
||||||
|
XChar2b *str2b_dst;
|
||||||
|
BYTE *str;
|
||||||
|
UINT i;
|
||||||
|
UINT codepage = pfo->fi->codepage;
|
||||||
|
char ch = pfo->fs->default_char;
|
||||||
|
|
||||||
|
if (!(str2b = HeapAlloc( GetProcessHeap(), 0, count * sizeof(XChar2b) )))
|
||||||
|
return NULL;
|
||||||
|
if (!(str = HeapAlloc( GetProcessHeap(), 0, count*2 )))
|
||||||
|
{
|
||||||
|
HeapFree( GetProcessHeap(), 0, str2b );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
WideCharToMultiByte( codepage, 0, lpwstr, count, str, count*2, &ch, NULL );
|
||||||
|
|
||||||
|
str2b_dst = str2b;
|
||||||
|
for (i = 0; i < count; i++, str2b_dst++)
|
||||||
|
{
|
||||||
|
if ( ( str[i] >= (BYTE)0x80 && str[i] <= (BYTE)0x9f ) ||
|
||||||
|
( str[i] >= (BYTE)0xe0 && str[i] <= (BYTE)0xfc ) )
|
||||||
|
{
|
||||||
|
unsigned int high, low;
|
||||||
|
|
||||||
|
high = (unsigned int)str[i];
|
||||||
|
low = (unsigned int)str[i+1];
|
||||||
|
|
||||||
|
if ( high <= 0x9f )
|
||||||
|
high = (high<<1) - 0xe0;
|
||||||
|
else
|
||||||
|
high = (high<<1) - 0x160;
|
||||||
|
if ( low < 0x9f )
|
||||||
|
{
|
||||||
|
high --;
|
||||||
|
if ( low < 0x7f )
|
||||||
|
low -= 0x1f;
|
||||||
|
else
|
||||||
|
low -= 0x20;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
low -= 0x7e;
|
||||||
|
}
|
||||||
|
|
||||||
|
str2b_dst->byte1 = (unsigned char)high;
|
||||||
|
str2b_dst->byte2 = (unsigned char)low;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str2b_dst->byte1 = 0;
|
||||||
|
str2b_dst->byte2 = str[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HeapFree( GetProcessHeap(), 0, str );
|
||||||
|
|
||||||
|
return str2b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static XChar2b* X11DRV_unicode_to_char2b_cp936( fontObject* pfo,
|
||||||
|
LPCWSTR lpwstr, UINT count )
|
||||||
|
{
|
||||||
|
FIXME( "please implement X11DRV_unicode_to_char2b_cp936!\n" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static XChar2b* X11DRV_unicode_to_char2b_cp949( fontObject* pfo,
|
||||||
|
LPCWSTR lpwstr, UINT count )
|
||||||
|
{
|
||||||
|
XChar2b *str2b;
|
||||||
|
XChar2b *str2b_dst;
|
||||||
|
BYTE *str;
|
||||||
|
UINT i;
|
||||||
|
UINT codepage = pfo->fi->codepage;
|
||||||
|
char ch = pfo->fs->default_char;
|
||||||
|
|
||||||
|
if (!(str2b = HeapAlloc( GetProcessHeap(), 0, count * sizeof(XChar2b) )))
|
||||||
|
return NULL;
|
||||||
|
if (!(str = HeapAlloc( GetProcessHeap(), 0, count*2 )))
|
||||||
|
{
|
||||||
|
HeapFree( GetProcessHeap(), 0, str2b );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
WideCharToMultiByte( codepage, 0, lpwstr, count, str, count*2, &ch, NULL );
|
||||||
|
|
||||||
|
str2b_dst = str2b;
|
||||||
|
for (i = 0; i < count; i++, str2b_dst++)
|
||||||
|
{
|
||||||
|
if ( str[i] & (BYTE)0x80 )
|
||||||
|
{
|
||||||
|
str2b_dst->byte1 = str[i];
|
||||||
|
str2b_dst->byte2 = str[i+1];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str2b_dst->byte1 = 0;
|
||||||
|
str2b_dst->byte2 = str[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
HeapFree( GetProcessHeap(), 0, str );
|
||||||
|
|
||||||
|
return str2b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static XChar2b* X11DRV_unicode_to_char2b_cp950( fontObject* pfo,
|
||||||
|
LPCWSTR lpwstr, UINT count )
|
||||||
|
{
|
||||||
|
FIXME( "please implement X11DRV_unicode_to_char2b_cp950!\n" );
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void X11DRV_DrawString_normal( fontObject* pfo, Display* pdisp,
|
||||||
|
Drawable d, GC gc, int x, int y,
|
||||||
|
XChar2b* pstr, int count )
|
||||||
|
{
|
||||||
|
TSXDrawString16( pdisp, d, gc, x, y, pstr, count );
|
||||||
|
}
|
||||||
|
|
||||||
|
static int X11DRV_TextWidth_normal( fontObject* pfo, XChar2b* pstr, int count )
|
||||||
|
{
|
||||||
|
return TSXTextWidth16( pfo->fs, pstr, count );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void X11DRV_DrawText_normal( fontObject* pfo, Display* pdisp, Drawable d,
|
||||||
|
GC gc, int x, int y, XTextItem16* pitems,
|
||||||
|
int count )
|
||||||
|
{
|
||||||
|
TSXDrawText16( pdisp, d, gc, x, y, pitems, count );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void X11DRV_TextExtents_normal( fontObject* pfo, XChar2b* pstr, int count,
|
||||||
|
int* pdir, int* pascent, int* pdescent,
|
||||||
|
int* pwidth )
|
||||||
|
{
|
||||||
|
XCharStruct info;
|
||||||
|
|
||||||
|
TSXTextExtents16( pfo->fs, pstr, count, pdir, pascent, pdescent, &info );
|
||||||
|
*pwidth = info.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
const X11DRV_CP X11DRV_cptable[X11DRV_CPTABLE_COUNT] =
|
||||||
|
{
|
||||||
|
{ /* SBCS */
|
||||||
|
X11DRV_unicode_to_char2b_sbcs,
|
||||||
|
X11DRV_DrawString_normal,
|
||||||
|
X11DRV_TextWidth_normal,
|
||||||
|
X11DRV_DrawText_normal,
|
||||||
|
X11DRV_TextExtents_normal,
|
||||||
|
},
|
||||||
|
{ /* UNICODE */
|
||||||
|
X11DRV_unicode_to_char2b_unicode,
|
||||||
|
X11DRV_DrawString_normal,
|
||||||
|
X11DRV_TextWidth_normal,
|
||||||
|
X11DRV_DrawText_normal,
|
||||||
|
X11DRV_TextExtents_normal,
|
||||||
|
},
|
||||||
|
{ /* CP932 */
|
||||||
|
X11DRV_unicode_to_char2b_cp932,
|
||||||
|
X11DRV_DrawString_normal, /* FIXME */
|
||||||
|
X11DRV_TextWidth_normal, /* FIXME */
|
||||||
|
X11DRV_DrawText_normal, /* FIXME */
|
||||||
|
X11DRV_TextExtents_normal, /* FIXME */
|
||||||
|
},
|
||||||
|
{ /* CP936 */
|
||||||
|
X11DRV_unicode_to_char2b_cp936,
|
||||||
|
X11DRV_DrawString_normal, /* FIXME */
|
||||||
|
X11DRV_TextWidth_normal, /* FIXME */
|
||||||
|
X11DRV_DrawText_normal, /* FIXME */
|
||||||
|
X11DRV_TextExtents_normal, /* FIXME */
|
||||||
|
},
|
||||||
|
{ /* CP949 */
|
||||||
|
X11DRV_unicode_to_char2b_cp949,
|
||||||
|
X11DRV_DrawString_normal, /* FIXME */
|
||||||
|
X11DRV_TextWidth_normal, /* FIXME */
|
||||||
|
X11DRV_DrawText_normal, /* FIXME */
|
||||||
|
X11DRV_TextExtents_normal, /* FIXME */
|
||||||
|
},
|
||||||
|
{ /* CP950 */
|
||||||
|
X11DRV_unicode_to_char2b_cp950,
|
||||||
|
X11DRV_DrawString_normal, /* FIXME */
|
||||||
|
X11DRV_TextWidth_normal, /* FIXME */
|
||||||
|
X11DRV_DrawText_normal, /* FIXME */
|
||||||
|
X11DRV_TextExtents_normal, /* FIXME */
|
||||||
|
},
|
||||||
|
};
|
|
@ -27,74 +27,6 @@ DEFAULT_DEBUG_CHANNEL(text);
|
||||||
#define IROUND(x) (int)((x)>0? (x)+0.5 : (x) - 0.5)
|
#define IROUND(x) (int)((x)>0? (x)+0.5 : (x) - 0.5)
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* unicode_to_char2b
|
|
||||||
*
|
|
||||||
* dup a Unicode string into a XChar2b array; must be HeapFree'd by the caller
|
|
||||||
*/
|
|
||||||
static XChar2b *unicode_to_char2b( LPCWSTR wstr, UINT count, UINT codepage, UINT def_char )
|
|
||||||
{
|
|
||||||
XChar2b *str2b;
|
|
||||||
UINT i;
|
|
||||||
|
|
||||||
if (!(str2b = HeapAlloc( GetProcessHeap(), 0, count * sizeof(XChar2b) )))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (codepage != 0) /* multibyte font */
|
|
||||||
{
|
|
||||||
BYTE *str;
|
|
||||||
char ch = def_char;
|
|
||||||
CPINFO cpinfo;
|
|
||||||
|
|
||||||
/* allocate the worst case count * 2 bytes */
|
|
||||||
if (!(str = HeapAlloc( GetProcessHeap(), 0, count * 2 )))
|
|
||||||
{
|
|
||||||
HeapFree( GetProcessHeap(), 0, str2b );
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we have to convert from unicode to codepage first */
|
|
||||||
WideCharToMultiByte( codepage, 0, wstr, count, str, count, &ch, NULL );
|
|
||||||
|
|
||||||
GetCPInfo( codepage, &cpinfo );
|
|
||||||
|
|
||||||
if (cpinfo.MaxCharSize == 1)
|
|
||||||
{
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
str2b[i].byte1 = 0;
|
|
||||||
str2b[i].byte2 = str[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
XChar2b *str2b_dst = str2b;
|
|
||||||
for (i = 0; i < count; i++, str2b_dst++)
|
|
||||||
{
|
|
||||||
str2b_dst->byte2 = str[i];
|
|
||||||
if (IsDBCSLeadByteEx( codepage, str[i] ))
|
|
||||||
{
|
|
||||||
str2b_dst->byte1 = str[i + 1];
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
str2b_dst->byte1 = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HeapFree( GetProcessHeap(), 0, str );
|
|
||||||
}
|
|
||||||
else /* codepage 0 -> unicode font */
|
|
||||||
{
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
str2b[i].byte1 = wstr[i] >> 8;
|
|
||||||
str2b[i].byte2 = wstr[i] & 0xff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return str2b;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* X11DRV_ExtTextOut
|
* X11DRV_ExtTextOut
|
||||||
*/
|
*/
|
||||||
|
@ -294,7 +226,7 @@ X11DRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw the text (count > 0 verified) */
|
/* Draw the text (count > 0 verified) */
|
||||||
if (!(str2b = unicode_to_char2b( wstr, count, pfo->fi->codepage, pfo->fs->default_char )))
|
if (!(str2b = X11DRV_cptable[pfo->fi->cptable].punicode_to_char2b( pfo, wstr, count )))
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
|
|
||||||
TSXSetForeground( display, physDev->gc, physDev->textPixel );
|
TSXSetForeground( display, physDev->gc, physDev->textPixel );
|
||||||
|
@ -302,8 +234,9 @@ X11DRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags,
|
||||||
{
|
{
|
||||||
if (!dc->w.charExtra && !dc->w.breakExtra && !lpDx)
|
if (!dc->w.charExtra && !dc->w.breakExtra && !lpDx)
|
||||||
{
|
{
|
||||||
TSXDrawString16( display, physDev->drawable, physDev->gc,
|
X11DRV_cptable[pfo->fi->cptable].pDrawString(
|
||||||
dc->w.DCOrgX + x, dc->w.DCOrgY + y, str2b, count );
|
pfo, display, physDev->drawable, physDev->gc,
|
||||||
|
dc->w.DCOrgX + x, dc->w.DCOrgY + y, str2b, count );
|
||||||
}
|
}
|
||||||
else /* Now the fun begins... */
|
else /* Now the fun begins... */
|
||||||
{
|
{
|
||||||
|
@ -336,7 +269,8 @@ X11DRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags,
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
delta += (lpDx[i] * dc->vportExtX + extra) / dc->wndExtX
|
delta += (lpDx[i] * dc->vportExtX + extra) / dc->wndExtX
|
||||||
- TSXTextWidth16( font, str2b + i, 1);
|
- X11DRV_cptable[pfo->fi->cptable].pTextWidth(
|
||||||
|
pfo, str2b + i, 1);
|
||||||
pitem->nchars++;
|
pitem->nchars++;
|
||||||
} while ((++i < count) && !delta);
|
} while ((++i < count) && !delta);
|
||||||
pitem++;
|
pitem++;
|
||||||
|
@ -363,8 +297,9 @@ X11DRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TSXDrawText16( display, physDev->drawable, physDev->gc,
|
X11DRV_cptable[pfo->fi->cptable].pDrawText( pfo, display,
|
||||||
dc->w.DCOrgX + x, dc->w.DCOrgY + y, items, pitem - items );
|
physDev->drawable, physDev->gc,
|
||||||
|
dc->w.DCOrgX + x, dc->w.DCOrgY + y, items, pitem - items );
|
||||||
HeapFree( GetProcessHeap(), 0, items );
|
HeapFree( GetProcessHeap(), 0, items );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,8 +318,9 @@ X11DRV_ExtTextOut( DC *dc, INT x, INT y, UINT flags,
|
||||||
int y_i = IROUND((double) (dc->w.DCOrgY + y) - offset *
|
int y_i = IROUND((double) (dc->w.DCOrgY + y) - offset *
|
||||||
pfo->lpX11Trans->b / pfo->lpX11Trans->pixelsize );
|
pfo->lpX11Trans->b / pfo->lpX11Trans->pixelsize );
|
||||||
|
|
||||||
TSXDrawString16( display, physDev->drawable, physDev->gc,
|
X11DRV_cptable[pfo->fi->cptable].pDrawString(
|
||||||
x_i, y_i, &str2b[i], 1);
|
pfo, display, physDev->drawable, physDev->gc,
|
||||||
|
x_i, y_i, &str2b[i], 1);
|
||||||
if (lpDx)
|
if (lpDx)
|
||||||
offset += XLSTODS(dc, lpDx[i]);
|
offset += XLSTODS(dc, lpDx[i]);
|
||||||
else
|
else
|
||||||
|
@ -460,11 +396,12 @@ BOOL X11DRV_GetTextExtentPoint( DC *dc, LPCWSTR str, INT count,
|
||||||
if( pfo ) {
|
if( pfo ) {
|
||||||
if( !pfo->lpX11Trans ) {
|
if( !pfo->lpX11Trans ) {
|
||||||
int dir, ascent, descent;
|
int dir, ascent, descent;
|
||||||
XCharStruct info;
|
int info_width;
|
||||||
XChar2b *p = unicode_to_char2b( str, count, pfo->fi->codepage, pfo->fs->default_char );
|
XChar2b *p = X11DRV_cptable[pfo->fi->cptable].punicode_to_char2b( pfo, str, count );
|
||||||
if (!p) return FALSE;
|
if (!p) return FALSE;
|
||||||
TSXTextExtents16( pfo->fs, p, count, &dir, &ascent, &descent, &info );
|
X11DRV_cptable[pfo->fi->cptable].pTextExtents( pfo, p,
|
||||||
size->cx = abs((info.width + dc->w.breakRem + count *
|
count, &dir, &ascent, &descent, &info_width );
|
||||||
|
size->cx = abs((info_width + dc->w.breakRem + count *
|
||||||
dc->w.charExtra) * dc->wndExtX / dc->vportExtX);
|
dc->w.charExtra) * dc->wndExtX / dc->vportExtX);
|
||||||
size->cy = abs((pfo->fs->ascent + pfo->fs->descent) *
|
size->cy = abs((pfo->fs->ascent + pfo->fs->descent) *
|
||||||
dc->wndExtY / dc->vportExtY);
|
dc->wndExtY / dc->vportExtY);
|
||||||
|
|
|
@ -102,117 +102,118 @@ static const char* INIDefaultSansSerif = "DefaultSansSerif";
|
||||||
|
|
||||||
typedef struct __sufch
|
typedef struct __sufch
|
||||||
{
|
{
|
||||||
LPSTR psuffix;
|
LPCSTR psuffix;
|
||||||
BYTE charset;
|
BYTE charset;
|
||||||
UINT16 codepage;
|
WORD codepage;
|
||||||
|
WORD cptable;
|
||||||
} SuffixCharset;
|
} SuffixCharset;
|
||||||
|
|
||||||
static SuffixCharset sufch_ansi[] = {
|
static const SuffixCharset sufch_ansi[] = {
|
||||||
{ "0", ANSI_CHARSET, 1252 },
|
{ "0", ANSI_CHARSET, 1252, X11DRV_CPTABLE_SBCS },
|
||||||
{ NULL, ANSI_CHARSET, 1252 }};
|
{ NULL, ANSI_CHARSET, 1252, X11DRV_CPTABLE_SBCS }};
|
||||||
|
|
||||||
static SuffixCharset sufch_iso646[] = {
|
static const SuffixCharset sufch_iso646[] = {
|
||||||
{ "irv", ANSI_CHARSET, 1252 },
|
{ "irv", ANSI_CHARSET, 1252, X11DRV_CPTABLE_SBCS },
|
||||||
{ NULL, ANSI_CHARSET, 1252 }};
|
{ NULL, ANSI_CHARSET, 1252, X11DRV_CPTABLE_SBCS }};
|
||||||
|
|
||||||
static SuffixCharset sufch_iso8859[] = {
|
static const SuffixCharset sufch_iso8859[] = {
|
||||||
{ "1", ANSI_CHARSET, 28591 },
|
{ "1", ANSI_CHARSET, 28591, X11DRV_CPTABLE_SBCS },
|
||||||
{ "2", EE_CHARSET, 28592 },
|
{ "2", EE_CHARSET, 28592, X11DRV_CPTABLE_SBCS },
|
||||||
{ "3", ISO3_CHARSET, 28593 },
|
{ "3", ISO3_CHARSET, 28593, X11DRV_CPTABLE_SBCS },
|
||||||
{ "4", ISO4_CHARSET, 28594 },
|
{ "4", ISO4_CHARSET, 28594, X11DRV_CPTABLE_SBCS },
|
||||||
{ "5", RUSSIAN_CHARSET, 28595 },
|
{ "5", RUSSIAN_CHARSET, 28595, X11DRV_CPTABLE_SBCS },
|
||||||
{ "6", ARABIC_CHARSET, 28596 },
|
{ "6", ARABIC_CHARSET, 28596, X11DRV_CPTABLE_SBCS },
|
||||||
{ "7", GREEK_CHARSET, 28597 },
|
{ "7", GREEK_CHARSET, 28597, X11DRV_CPTABLE_SBCS },
|
||||||
{ "8", HEBREW_CHARSET, 28598 },
|
{ "8", HEBREW_CHARSET, 28598, X11DRV_CPTABLE_SBCS },
|
||||||
{ "9", TURKISH_CHARSET, 28599 },
|
{ "9", TURKISH_CHARSET, 28599, X11DRV_CPTABLE_SBCS },
|
||||||
{ "10", BALTIC_CHARSET, 1257 }, /* FIXME */
|
{ "10", BALTIC_CHARSET, 1257, X11DRV_CPTABLE_SBCS }, /* FIXME */
|
||||||
{ "11", THAI_CHARSET, 874 }, /* FIXME */
|
{ "11", THAI_CHARSET, 874, X11DRV_CPTABLE_SBCS }, /* FIXME */
|
||||||
{ "12", SYMBOL_CHARSET, CP_SYMBOL },
|
{ "12", SYMBOL_CHARSET, CP_SYMBOL, X11DRV_CPTABLE_SBCS },
|
||||||
{ "13", SYMBOL_CHARSET, CP_SYMBOL },
|
{ "13", SYMBOL_CHARSET, CP_SYMBOL, X11DRV_CPTABLE_SBCS },
|
||||||
{ "14", SYMBOL_CHARSET, CP_SYMBOL },
|
{ "14", SYMBOL_CHARSET, CP_SYMBOL, X11DRV_CPTABLE_SBCS },
|
||||||
{ "15", ANSI_CHARSET, 1252 },
|
{ "15", ANSI_CHARSET, 1252, X11DRV_CPTABLE_SBCS },
|
||||||
{ NULL, ANSI_CHARSET, 1252 }};
|
{ NULL, ANSI_CHARSET, 1252, X11DRV_CPTABLE_SBCS }};
|
||||||
|
|
||||||
static SuffixCharset sufch_microsoft[] = {
|
static const SuffixCharset sufch_microsoft[] = {
|
||||||
{ "cp1250", EE_CHARSET, 1250 },
|
{ "cp1250", EE_CHARSET, 1250, X11DRV_CPTABLE_SBCS },
|
||||||
{ "cp1251", RUSSIAN_CHARSET, 1251 },
|
{ "cp1251", RUSSIAN_CHARSET, 1251, X11DRV_CPTABLE_SBCS },
|
||||||
{ "cp1252", ANSI_CHARSET, 1252 },
|
{ "cp1252", ANSI_CHARSET, 1252, X11DRV_CPTABLE_SBCS },
|
||||||
{ "cp1253", GREEK_CHARSET, 1253 },
|
{ "cp1253", GREEK_CHARSET, 1253, X11DRV_CPTABLE_SBCS },
|
||||||
{ "cp1254", TURKISH_CHARSET, 1254 },
|
{ "cp1254", TURKISH_CHARSET, 1254, X11DRV_CPTABLE_SBCS },
|
||||||
{ "cp1255", HEBREW_CHARSET, 1255 },
|
{ "cp1255", HEBREW_CHARSET, 1255, X11DRV_CPTABLE_SBCS },
|
||||||
{ "cp1256", ARABIC_CHARSET, 1256 },
|
{ "cp1256", ARABIC_CHARSET, 1256, X11DRV_CPTABLE_SBCS },
|
||||||
{ "cp1257", BALTIC_CHARSET, 1257 },
|
{ "cp1257", BALTIC_CHARSET, 1257, X11DRV_CPTABLE_SBCS },
|
||||||
{ "fontspecific", SYMBOL_CHARSET, CP_SYMBOL },
|
{ "fontspecific", SYMBOL_CHARSET, CP_SYMBOL, X11DRV_CPTABLE_SBCS },
|
||||||
{ "symbol", SYMBOL_CHARSET, CP_SYMBOL },
|
{ "symbol", SYMBOL_CHARSET, CP_SYMBOL, X11DRV_CPTABLE_SBCS },
|
||||||
{ NULL, ANSI_CHARSET, 1252 }};
|
{ NULL, ANSI_CHARSET, 1252, X11DRV_CPTABLE_SBCS }};
|
||||||
|
|
||||||
static SuffixCharset sufch_tcvn[] = {
|
static const SuffixCharset sufch_tcvn[] = {
|
||||||
{ "0", TCVN_CHARSET, 1252 }, /* FIXME */
|
{ "0", TCVN_CHARSET, 1252, X11DRV_CPTABLE_SBCS }, /* FIXME */
|
||||||
{ NULL, TCVN_CHARSET, 1252 }};
|
{ NULL, TCVN_CHARSET, 1252, X11DRV_CPTABLE_SBCS }};
|
||||||
|
|
||||||
static SuffixCharset sufch_tis620[] = {
|
static const SuffixCharset sufch_tis620[] = {
|
||||||
{ "0", THAI_CHARSET, 874 }, /* FIXME */
|
{ "0", THAI_CHARSET, 874, X11DRV_CPTABLE_SBCS }, /* FIXME */
|
||||||
{ NULL, THAI_CHARSET, 874 }};
|
{ NULL, THAI_CHARSET, 874, X11DRV_CPTABLE_SBCS }};
|
||||||
|
|
||||||
static SuffixCharset sufch_viscii[] = {
|
static const SuffixCharset sufch_viscii[] = {
|
||||||
{ "1", VISCII_CHARSET, 1252 }, /* FIXME */
|
{ "1", VISCII_CHARSET, 1252, X11DRV_CPTABLE_SBCS }, /* FIXME */
|
||||||
{ NULL, VISCII_CHARSET, 1252 }};
|
{ NULL, VISCII_CHARSET, 1252, X11DRV_CPTABLE_SBCS }};
|
||||||
|
|
||||||
static SuffixCharset sufch_windows[] = {
|
static const SuffixCharset sufch_windows[] = {
|
||||||
{ "1250", EE_CHARSET, 1250 },
|
{ "1250", EE_CHARSET, 1250, X11DRV_CPTABLE_SBCS },
|
||||||
{ "1251", RUSSIAN_CHARSET, 1251 },
|
{ "1251", RUSSIAN_CHARSET, 1251, X11DRV_CPTABLE_SBCS },
|
||||||
{ "1252", ANSI_CHARSET, 1252 },
|
{ "1252", ANSI_CHARSET, 1252, X11DRV_CPTABLE_SBCS },
|
||||||
{ "1253", GREEK_CHARSET, 1253 },
|
{ "1253", GREEK_CHARSET, 1253, X11DRV_CPTABLE_SBCS },
|
||||||
{ "1254", TURKISH_CHARSET, 1254 },
|
{ "1254", TURKISH_CHARSET, 1254, X11DRV_CPTABLE_SBCS },
|
||||||
{ "1255", HEBREW_CHARSET, 1255 },
|
{ "1255", HEBREW_CHARSET, 1255, X11DRV_CPTABLE_SBCS },
|
||||||
{ "1256", ARABIC_CHARSET, 1256 },
|
{ "1256", ARABIC_CHARSET, 1256, X11DRV_CPTABLE_SBCS },
|
||||||
{ "1257", BALTIC_CHARSET, 1257 },
|
{ "1257", BALTIC_CHARSET, 1257, X11DRV_CPTABLE_SBCS },
|
||||||
{ NULL, ANSI_CHARSET, 1252 }};
|
{ NULL, ANSI_CHARSET, 1252, X11DRV_CPTABLE_SBCS }};
|
||||||
|
|
||||||
static SuffixCharset sufch_koi8[] = {
|
static const SuffixCharset sufch_koi8[] = {
|
||||||
{ "r", RUSSIAN_CHARSET, 20866 },
|
{ "r", RUSSIAN_CHARSET, 20866, X11DRV_CPTABLE_SBCS },
|
||||||
{ "u", RUSSIAN_CHARSET, 20866 },
|
{ "u", RUSSIAN_CHARSET, 20866, X11DRV_CPTABLE_SBCS },
|
||||||
{ NULL, RUSSIAN_CHARSET, 20866 }};
|
{ NULL, RUSSIAN_CHARSET, 20866, X11DRV_CPTABLE_SBCS }};
|
||||||
|
|
||||||
/* FIXME: DBCS charsets need 2 or more fonts */
|
/* FIXME: DBCS charsets need 2 or more fonts */
|
||||||
static SuffixCharset sufch_jisx0201[] = {
|
static const SuffixCharset sufch_jisx0201[] = {
|
||||||
{ "0", ANSI_CHARSET, 932 },
|
{ "0", ANSI_CHARSET, 932, X11DRV_CPTABLE_SBCS },
|
||||||
{ NULL, ANSI_CHARSET, 932 }};
|
{ NULL, ANSI_CHARSET, 932, X11DRV_CPTABLE_SBCS }};
|
||||||
|
|
||||||
static SuffixCharset sufch_jisx0208[] = {
|
static const SuffixCharset sufch_jisx0208[] = {
|
||||||
{ "0", SHIFTJIS_CHARSET, 932 },
|
{ "0", SHIFTJIS_CHARSET, 932, X11DRV_CPTABLE_CP932 },
|
||||||
{ NULL, SHIFTJIS_CHARSET, 932 }};
|
{ NULL, SHIFTJIS_CHARSET, 932, X11DRV_CPTABLE_CP932 }};
|
||||||
|
|
||||||
static SuffixCharset sufch_ksc5601[] = {
|
static const SuffixCharset sufch_ksc5601[] = {
|
||||||
{ "0", HANGEUL_CHARSET, 949 },
|
{ "0", HANGEUL_CHARSET, 949, X11DRV_CPTABLE_CP949 },
|
||||||
{ NULL, HANGEUL_CHARSET, 949 }};
|
{ NULL, HANGEUL_CHARSET, 949, X11DRV_CPTABLE_CP949 }};
|
||||||
|
|
||||||
static SuffixCharset sufch_gb2312[] = {
|
static const SuffixCharset sufch_gb2312[] = {
|
||||||
{ "0", GB2312_CHARSET, 936 },
|
{ "0", GB2312_CHARSET, 936, X11DRV_CPTABLE_CP936 },
|
||||||
{ NULL, GB2312_CHARSET, 936 }};
|
{ NULL, GB2312_CHARSET, 936, X11DRV_CPTABLE_CP936 }};
|
||||||
|
|
||||||
static SuffixCharset sufch_big5[] = {
|
static const SuffixCharset sufch_big5[] = {
|
||||||
{ "0", CHINESEBIG5_CHARSET, 950 },
|
{ "0", CHINESEBIG5_CHARSET, 950, X11DRV_CPTABLE_CP950 },
|
||||||
{ NULL, CHINESEBIG5_CHARSET, 950 }};
|
{ NULL, CHINESEBIG5_CHARSET, 950, X11DRV_CPTABLE_CP950 }};
|
||||||
|
|
||||||
static SuffixCharset sufch_unicode[] = {
|
static const SuffixCharset sufch_unicode[] = {
|
||||||
{ "0", DEFAULT_CHARSET, 0 },
|
{ "0", DEFAULT_CHARSET, 0, X11DRV_CPTABLE_UNICODE },
|
||||||
{ NULL, DEFAULT_CHARSET, 0 }};
|
{ NULL, DEFAULT_CHARSET, 0, X11DRV_CPTABLE_UNICODE }};
|
||||||
|
|
||||||
static SuffixCharset sufch_iso10646[] = {
|
static const SuffixCharset sufch_iso10646[] = {
|
||||||
{ "1", DEFAULT_CHARSET, 0 },
|
{ "1", DEFAULT_CHARSET, 0, X11DRV_CPTABLE_UNICODE },
|
||||||
{ NULL, DEFAULT_CHARSET, 0 }};
|
{ NULL, DEFAULT_CHARSET, 0, X11DRV_CPTABLE_UNICODE }};
|
||||||
|
|
||||||
/* Each of these must be matched explicitly */
|
/* Each of these must be matched explicitly */
|
||||||
static SuffixCharset sufch_any[] = {
|
static const SuffixCharset sufch_any[] = {
|
||||||
{ "fontspecific", SYMBOL_CHARSET, CP_SYMBOL },
|
{ "fontspecific", SYMBOL_CHARSET, CP_SYMBOL, X11DRV_CPTABLE_SBCS },
|
||||||
{ NULL, 0, 0 }};
|
{ NULL, 0, 0, X11DRV_CPTABLE_SBCS }};
|
||||||
|
|
||||||
|
|
||||||
typedef struct __fet
|
typedef struct __fet
|
||||||
{
|
{
|
||||||
LPSTR prefix;
|
LPSTR prefix;
|
||||||
SuffixCharset* sufch;
|
const SuffixCharset* sufch;
|
||||||
struct __fet* next;
|
struct __fet* next;
|
||||||
} fontEncodingTemplate;
|
} fontEncodingTemplate;
|
||||||
|
|
||||||
|
@ -390,7 +391,7 @@ static LFD* LFD_Parse(LPSTR lpFont)
|
||||||
|
|
||||||
static void LFD_UnParse(LPSTR dp, UINT buf_size, LFD* lfd)
|
static void LFD_UnParse(LPSTR dp, UINT buf_size, LFD* lfd)
|
||||||
{
|
{
|
||||||
char* lfd_fld[LFD_FIELDS];
|
const char* lfd_fld[LFD_FIELDS];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!buf_size)
|
if (!buf_size)
|
||||||
|
@ -415,7 +416,7 @@ static void LFD_UnParse(LPSTR dp, UINT buf_size, LFD* lfd)
|
||||||
|
|
||||||
for (i = 0; i < LFD_FIELDS; i++)
|
for (i = 0; i < LFD_FIELDS; i++)
|
||||||
{
|
{
|
||||||
char* sp = lfd_fld[i];
|
const char* sp = lfd_fld[i];
|
||||||
if (!sp || !buf_size)
|
if (!sp || !buf_size)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -523,7 +524,7 @@ static int LFD_InitFontInfo( fontInfo* fi, const LFD* lfd, LPCSTR fullname )
|
||||||
int i, j, dec_style_check, scalability;
|
int i, j, dec_style_check, scalability;
|
||||||
fontEncodingTemplate* boba;
|
fontEncodingTemplate* boba;
|
||||||
const char* ridiculous = "font '%s' has ridiculous %s\n";
|
const char* ridiculous = "font '%s' has ridiculous %s\n";
|
||||||
char* lpstr;
|
const char* lpstr;
|
||||||
|
|
||||||
if (!lfd->charset_registry)
|
if (!lfd->charset_registry)
|
||||||
{
|
{
|
||||||
|
@ -649,7 +650,7 @@ static int LFD_InitFontInfo( fontInfo* fi, const LFD* lfd, LPCSTR fullname )
|
||||||
strstr(lpstr, "gb2312") ||
|
strstr(lpstr, "gb2312") ||
|
||||||
strstr(lpstr, "big5") )
|
strstr(lpstr, "big5") )
|
||||||
{
|
{
|
||||||
FIXME("DBCS fonts like '%s' are not worked correctly now.\n", fullname);
|
FIXME("DBCS fonts like '%s' are not working correctly now.\n", fullname);
|
||||||
}
|
}
|
||||||
|
|
||||||
fi->df.dfCharSet = ANSI_CHARSET;
|
fi->df.dfCharSet = ANSI_CHARSET;
|
||||||
|
@ -666,6 +667,7 @@ static int LFD_InitFontInfo( fontInfo* fi, const LFD* lfd, LPCSTR fullname )
|
||||||
{
|
{
|
||||||
fi->df.dfCharSet = boba->sufch[j].charset;
|
fi->df.dfCharSet = boba->sufch[j].charset;
|
||||||
fi->codepage = boba->sufch[j].codepage;
|
fi->codepage = boba->sufch[j].codepage;
|
||||||
|
fi->cptable = boba->sufch[j].cptable;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -675,6 +677,7 @@ static int LFD_InitFontInfo( fontInfo* fi, const LFD* lfd, LPCSTR fullname )
|
||||||
fullname, lfd->charset_encoding);
|
fullname, lfd->charset_encoding);
|
||||||
fi->df.dfCharSet = boba->sufch[j].charset;
|
fi->df.dfCharSet = boba->sufch[j].charset;
|
||||||
fi->codepage = boba->sufch[j].codepage;
|
fi->codepage = boba->sufch[j].codepage;
|
||||||
|
fi->cptable = boba->sufch[j].cptable;
|
||||||
j = 254;
|
j = 254;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -685,6 +688,7 @@ static int LFD_InitFontInfo( fontInfo* fi, const LFD* lfd, LPCSTR fullname )
|
||||||
;
|
;
|
||||||
fi->df.dfCharSet = boba->sufch[j].charset;
|
fi->df.dfCharSet = boba->sufch[j].charset;
|
||||||
fi->codepage = boba->sufch[j].codepage;
|
fi->codepage = boba->sufch[j].codepage;
|
||||||
|
fi->cptable = boba->sufch[j].cptable;
|
||||||
j = 255;
|
j = 255;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -2062,6 +2066,7 @@ static BOOL XFONT_ReadCachedMetrics( int fd, int res, unsigned x_checksum, int x
|
||||||
while( TRUE )
|
while( TRUE )
|
||||||
{
|
{
|
||||||
if( offset > length ||
|
if( offset > length ||
|
||||||
|
pfi->cptable >= (UINT16)X11DRV_CPTABLE_COUNT ||
|
||||||
(int)(pfi->next) != j++ ) goto fail;
|
(int)(pfi->next) != j++ ) goto fail;
|
||||||
|
|
||||||
if( pfi->df.dfPixHeight == 0 ) goto fail;
|
if( pfi->df.dfPixHeight == 0 ) goto fail;
|
||||||
|
|
|
@ -72,12 +72,24 @@ typedef struct
|
||||||
#define FI_ENC_TCVN 7
|
#define FI_ENC_TCVN 7
|
||||||
#define FI_ENC_TIS620 8
|
#define FI_ENC_TIS620 8
|
||||||
|
|
||||||
|
enum X11DRV_CPTABLE
|
||||||
|
{
|
||||||
|
X11DRV_CPTABLE_SBCS,
|
||||||
|
X11DRV_CPTABLE_UNICODE,
|
||||||
|
X11DRV_CPTABLE_CP932,
|
||||||
|
X11DRV_CPTABLE_CP936,
|
||||||
|
X11DRV_CPTABLE_CP949,
|
||||||
|
X11DRV_CPTABLE_CP950,
|
||||||
|
X11DRV_CPTABLE_COUNT
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct tagFontInfo
|
typedef struct tagFontInfo
|
||||||
{
|
{
|
||||||
struct tagFontInfo* next;
|
struct tagFontInfo* next;
|
||||||
UINT16 fi_flags;
|
UINT16 fi_flags;
|
||||||
UINT16 fi_encoding;
|
UINT16 fi_encoding;
|
||||||
UINT16 codepage;
|
UINT16 codepage;
|
||||||
|
UINT16 cptable;
|
||||||
|
|
||||||
/* LFD parameters can be quite different from the actual metrics */
|
/* LFD parameters can be quite different from the actual metrics */
|
||||||
|
|
||||||
|
@ -96,20 +108,20 @@ typedef struct tagFontInfo
|
||||||
#define LFD_FIELDS 14
|
#define LFD_FIELDS 14
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char* foundry;
|
const char* foundry;
|
||||||
char* family;
|
const char* family;
|
||||||
char* weight;
|
const char* weight;
|
||||||
char* slant;
|
const char* slant;
|
||||||
char* set_width;
|
const char* set_width;
|
||||||
char* add_style;
|
const char* add_style;
|
||||||
char* pixel_size;
|
const char* pixel_size;
|
||||||
char* point_size;
|
const char* point_size;
|
||||||
char* resolution_x;
|
const char* resolution_x;
|
||||||
char* resolution_y;
|
const char* resolution_y;
|
||||||
char* spacing;
|
const char* spacing;
|
||||||
char* average_width;
|
const char* average_width;
|
||||||
char* charset_registry;
|
const char* charset_registry;
|
||||||
char* charset_encoding;
|
const char* charset_encoding;
|
||||||
} LFD;
|
} LFD;
|
||||||
|
|
||||||
typedef struct tagFontResource
|
typedef struct tagFontResource
|
||||||
|
@ -214,4 +226,20 @@ extern fontObject* XFONT_GetFontObject( X_PHYSFONT pFont );
|
||||||
extern XFontStruct* XFONT_GetFontStruct( X_PHYSFONT pFont );
|
extern XFontStruct* XFONT_GetFontStruct( X_PHYSFONT pFont );
|
||||||
extern LPIFONTINFO16 XFONT_GetFontInfo( X_PHYSFONT pFont );
|
extern LPIFONTINFO16 XFONT_GetFontInfo( X_PHYSFONT pFont );
|
||||||
|
|
||||||
|
typedef struct tagX11DRV_CP
|
||||||
|
{
|
||||||
|
XChar2b* (*punicode_to_char2b)( fontObject* pfo,
|
||||||
|
LPCWSTR lpwstr, UINT count );
|
||||||
|
void (*pDrawString)( fontObject* pfo, Display* pdisp, Drawable d, GC gc,
|
||||||
|
int x, int y, XChar2b* pstr, int count );
|
||||||
|
int (*pTextWidth)( fontObject* pfo, XChar2b* pstr, int count );
|
||||||
|
void (*pDrawText)( fontObject* pfo, Display* pdisp, Drawable d, GC gc,
|
||||||
|
int x, int y, XTextItem16* pitems, int count );
|
||||||
|
void (*pTextExtents)( fontObject* pfo, XChar2b* pstr, int count,
|
||||||
|
int* pdir, int* pascent, int* pdescent,
|
||||||
|
int* pwidth );
|
||||||
|
} X11DRV_CP;
|
||||||
|
|
||||||
|
extern const X11DRV_CP X11DRV_cptable[X11DRV_CPTABLE_COUNT];
|
||||||
|
|
||||||
#endif /* __WINE_X11FONT_H */
|
#endif /* __WINE_X11FONT_H */
|
||||||
|
|
Loading…
Reference in New Issue