Removed the bitsPerPixel field in the generic DC structure, and leave
[wine] / dlls / x11drv / codepage.c
1 /*
2  * X11 codepage handling
3  *
4  * Copyright 2000 Hidenori Takeshima <hidenori@a2.ctktv.ne.jp>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "config.h"
22
23 #include <math.h>
24 #include <stdarg.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winnls.h"
29 #include "x11font.h"
30 #include "wine/debug.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(text);
33
34 /***********************************************************************
35  *           IsLegalDBCSChar for cp932/936/949/950/euc
36  */
37 static inline
38 int IsLegalDBCSChar_cp932( BYTE lead, BYTE trail )
39 {
40     return ( ( ( lead >= (BYTE)0x81 && lead <= (BYTE)0x9f ) ||
41                ( lead >= (BYTE)0xe0 && lead <= (BYTE)0xfc ) ) &&
42              ( ( trail >= (BYTE)0x40 && trail <= (BYTE)0x7e ) ||
43                ( trail >= (BYTE)0x80 && trail <= (BYTE)0xfc ) ) );
44 }
45
46 static inline
47 int IsLegalDBCSChar_cp936( BYTE lead, BYTE trail )
48 {
49     return ( ( lead >= (BYTE)0x81 && lead <= (BYTE)0xfe ) &&
50              ( trail >= (BYTE)0x40 && trail <= (BYTE)0xfe ) );
51 }
52
53 static inline
54 int IsLegalDBCSChar_cp949( BYTE lead, BYTE trail )
55 {
56     return ( ( lead >= (BYTE)0x81 && lead <= (BYTE)0xfe ) &&
57              ( trail >= (BYTE)0x41 && trail <= (BYTE)0xfe ) );
58 }
59
60 static inline
61 int IsLegalDBCSChar_cp950( BYTE lead, BYTE trail )
62 {
63     return (   ( lead >= (BYTE)0x81 && lead <= (BYTE)0xfe ) &&
64              ( ( trail >= (BYTE)0x40 && trail <= (BYTE)0x7e ) ||
65                ( trail >= (BYTE)0xa1 && trail <= (BYTE)0xfe ) ) );
66 }
67
68 static inline
69 int IsLegalDBCSChar_euc( BYTE lead, BYTE trail )
70 {
71     return ( ( lead >= (BYTE)0xa1 && lead <= (BYTE)0xfe ) &&
72              ( trail >= (BYTE)0xa1 && trail <= (BYTE)0xfe ) );
73 }
74
75
76 /***********************************************************************
77  *           DBCSCharToXChar2b for cp932/euc
78  */
79
80 static inline
81 void DBCSCharToXChar2b_cp932( XChar2b* pch, BYTE lead, BYTE trail )
82 {
83     unsigned int  high, low;
84
85     high = (unsigned int)lead;
86     low = (unsigned int)trail;
87
88     if ( high <= 0x9f )
89         high = (high<<1) - 0xe0;
90     else
91         high = (high<<1) - 0x160;
92     if ( low < 0x9f )
93     {
94         high --;
95         if ( low < 0x7f )
96             low -= 0x1f;
97         else
98             low -= 0x20;
99     }
100     else
101     {
102         low -= 0x7e;
103     }
104
105     pch->byte1 = (unsigned char)high;
106     pch->byte2 = (unsigned char)low;
107 }
108
109 static inline
110 void DBCSCharToXChar2b_euc( XChar2b* pch, BYTE lead, BYTE trail )
111 {
112     pch->byte1 = lead & (BYTE)0x7f;
113     pch->byte2 = trail & (BYTE)0x7f;
114 }
115
116
117
118
119 static WORD X11DRV_enum_subfont_charset_normal( UINT index )
120 {
121     return DEFAULT_CHARSET;
122 }
123
124 static WORD X11DRV_enum_subfont_charset_cp932( UINT index )
125 {
126     switch ( index )
127     {
128     case 0: return X11FONT_JISX0201_CHARSET;
129     case 1: return X11FONT_JISX0212_CHARSET;
130     }
131
132     return DEFAULT_CHARSET;
133 }
134
135 static WORD X11DRV_enum_subfont_charset_cp936( UINT index )
136 {
137     switch ( index )
138     {
139     case 0: return ANSI_CHARSET;
140     }
141
142     return DEFAULT_CHARSET;
143 }
144
145 static WORD X11DRV_enum_subfont_charset_cp949( UINT index )
146 {
147     switch ( index )
148     {
149     case 0: return ANSI_CHARSET;
150     }
151
152     return DEFAULT_CHARSET;
153 }
154
155 static WORD X11DRV_enum_subfont_charset_cp950( UINT index )
156 {
157     switch ( index )
158     {
159     case 0: return ANSI_CHARSET;
160     }
161
162     return DEFAULT_CHARSET;
163 }
164
165
166 static XChar2b* X11DRV_unicode_to_char2b_sbcs( fontObject* pfo,
167                                                LPCWSTR lpwstr, UINT count )
168 {
169     XChar2b *str2b;
170     UINT i;
171     BYTE *str;
172     UINT codepage = pfo->fi->codepage;
173     char ch = pfo->fs->default_char;
174
175     if (!(str2b = HeapAlloc( GetProcessHeap(), 0, count * sizeof(XChar2b) )))
176         return NULL;
177     if (!(str = HeapAlloc( GetProcessHeap(), 0, count )))
178     {
179         HeapFree( GetProcessHeap(), 0, str2b );
180         return NULL;
181     }
182
183     WideCharToMultiByte( codepage, 0, lpwstr, count, str, count, &ch, NULL );
184
185     for (i = 0; i < count; i++)
186     {
187         str2b[i].byte1 = 0;
188         str2b[i].byte2 = str[i];
189     }
190     HeapFree( GetProcessHeap(), 0, str );
191
192     return str2b;
193 }
194
195 static XChar2b* X11DRV_unicode_to_char2b_unicode( fontObject* pfo,
196                                                   LPCWSTR lpwstr, UINT count )
197 {
198     XChar2b *str2b;
199     UINT i;
200
201     if (!(str2b = HeapAlloc( GetProcessHeap(), 0, count * sizeof(XChar2b) )))
202         return NULL;
203
204     for (i = 0; i < count; i++)
205     {
206         str2b[i].byte1 = lpwstr[i] >> 8;
207         str2b[i].byte2 = lpwstr[i] & 0xff;
208     }
209
210     return str2b;
211 }
212
213 /* FIXME: handle jisx0212.1990... */
214 static XChar2b* X11DRV_unicode_to_char2b_cp932( fontObject* pfo,
215                                                 LPCWSTR lpwstr, UINT count )
216 {
217     XChar2b *str2b;
218     XChar2b *str2b_dst;
219     BYTE *str;
220     BYTE *str_src;
221     UINT i;
222     char ch = pfo->fs->default_char;
223
224     if (!(str2b = HeapAlloc( GetProcessHeap(), 0, count * sizeof(XChar2b) )))
225         return NULL;
226     if (!(str = HeapAlloc( GetProcessHeap(), 0, count*2 )))
227     {
228         HeapFree( GetProcessHeap(), 0, str2b );
229         return NULL;
230     }
231
232     /* handle jisx0212.1990... */
233     WideCharToMultiByte( 932, 0, lpwstr, count, str, count*2, &ch, NULL );
234
235     str_src = str;
236     str2b_dst = str2b;
237     for (i = 0; i < count; i++, str_src++, str2b_dst++)
238     {
239         if ( IsLegalDBCSChar_cp932( *str_src, *(str_src+1) ) )
240         {
241             DBCSCharToXChar2b_cp932( str2b_dst, *str_src, *(str_src+1) );
242             str_src++;
243         }
244         else
245         {
246             str2b_dst->byte1 = 0;
247             str2b_dst->byte2 = *str_src;
248         }
249     }
250
251     HeapFree( GetProcessHeap(), 0, str );
252
253     return str2b;
254 }
255
256
257 static XChar2b* X11DRV_unicode_to_char2b_cp936( fontObject* pfo,
258                                                 LPCWSTR lpwstr, UINT count )
259 {
260     XChar2b *str2b;
261     XChar2b *str2b_dst;
262     BYTE *str;
263     BYTE *str_src;
264     UINT i;
265     char ch = pfo->fs->default_char;
266
267     if (!(str2b = HeapAlloc( GetProcessHeap(), 0, count * sizeof(XChar2b) )))
268         return NULL;
269     if (!(str = HeapAlloc( GetProcessHeap(), 0, count*2 )))
270     {
271         HeapFree( GetProcessHeap(), 0, str2b );
272         return NULL;
273     }
274     WideCharToMultiByte( 936, 0, lpwstr, count, str, count*2, &ch, NULL );
275
276     str_src = str;
277     str2b_dst = str2b;
278     for (i = 0; i < count; i++, str_src++, str2b_dst++)
279     {
280         if ( IsLegalDBCSChar_cp936( *str_src, *(str_src+1) ) )
281         {
282             str2b_dst->byte1 = *str_src;
283             str2b_dst->byte2 = *(str_src+1);
284             str_src++;
285         }
286         else
287         {
288             str2b_dst->byte1 = 0;
289             str2b_dst->byte2 = *str_src;
290         }
291     }
292
293     HeapFree( GetProcessHeap(), 0, str );
294
295     return str2b;
296 }
297
298 static XChar2b* X11DRV_unicode_to_char2b_cp949( fontObject* pfo,
299                                                 LPCWSTR lpwstr, UINT count )
300 {
301     XChar2b *str2b;
302     XChar2b *str2b_dst;
303     BYTE *str;
304     BYTE *str_src;
305     UINT i;
306     char ch = pfo->fs->default_char;
307
308     if (!(str2b = HeapAlloc( GetProcessHeap(), 0, count * sizeof(XChar2b) )))
309         return NULL;
310     if (!(str = HeapAlloc( GetProcessHeap(), 0, count*2 )))
311     {
312         HeapFree( GetProcessHeap(), 0, str2b );
313         return NULL;
314     }
315     WideCharToMultiByte( 949, 0, lpwstr, count, str, count*2, &ch, NULL );
316
317     str_src = str;
318     str2b_dst = str2b;
319     for (i = 0; i < count; i++, str_src++, str2b_dst++)
320     {
321         if ( IsLegalDBCSChar_cp949( *str_src, *(str_src+1) ) )
322         {
323             str2b_dst->byte1 = *str_src;
324             str2b_dst->byte2 = *(str_src+1);
325             str_src++;
326         }
327         else
328         {
329             str2b_dst->byte1 = 0;
330             str2b_dst->byte2 = *str_src;
331         }
332     }
333
334     HeapFree( GetProcessHeap(), 0, str );
335
336     return str2b;
337 }
338
339
340 static XChar2b* X11DRV_unicode_to_char2b_cp950( fontObject* pfo,
341                                                 LPCWSTR lpwstr, UINT count )
342 {
343     XChar2b *str2b;
344     XChar2b *str2b_dst;
345     BYTE *str;
346     BYTE *str_src;
347     UINT i;
348     char ch = pfo->fs->default_char;
349
350     if (!(str2b = HeapAlloc( GetProcessHeap(), 0, count * sizeof(XChar2b) )))
351         return NULL;
352     if (!(str = HeapAlloc( GetProcessHeap(), 0, count*2 )))
353     {
354         HeapFree( GetProcessHeap(), 0, str2b );
355         return NULL;
356     }
357     WideCharToMultiByte( 950, 0, lpwstr, count, str, count*2, &ch, NULL );
358
359     str_src = str;
360     str2b_dst = str2b;
361     for (i = 0; i < count; i++, str_src++, str2b_dst++)
362     {
363         if ( IsLegalDBCSChar_cp950( *str_src, *(str_src+1) ) )
364         {
365             str2b_dst->byte1 = *str_src;
366             str2b_dst->byte2 = *(str_src+1);
367             str_src++;
368         }
369         else
370         {
371             str2b_dst->byte1 = 0;
372             str2b_dst->byte2 = *str_src;
373         }
374     }
375
376     HeapFree( GetProcessHeap(), 0, str );
377
378     return str2b;
379 }
380
381 static XChar2b* X11DRV_unicode_to_char2b_symbol( fontObject* pfo,
382                                                  LPCWSTR lpwstr, UINT count )
383 {
384     XChar2b *str2b;
385     UINT i;
386     char ch = pfo->fs->default_char;
387
388     if (!(str2b = HeapAlloc( GetProcessHeap(), 0, count * sizeof(XChar2b) )))
389         return NULL;
390
391     for (i = 0; i < count; i++)
392     {
393         str2b[i].byte1 = 0;
394         if(lpwstr[i] >= 0xf000 && lpwstr[i] < 0xf100)
395             str2b[i].byte2 = lpwstr[i] - 0xf000;
396         else if(lpwstr[i] < 0x100)
397             str2b[i].byte2 = lpwstr[i];
398         else
399             str2b[i].byte2 = ch;
400     }
401
402     return str2b;
403 }
404
405
406 static void X11DRV_DrawString_normal( fontObject* pfo, Display* pdisp,
407                                       Drawable d, GC gc, int x, int y,
408                                       XChar2b* pstr, int count )
409 {
410     wine_tsx11_lock();
411     XDrawString16( pdisp, d, gc, x, y, pstr, count );
412     wine_tsx11_unlock();
413 }
414
415 static int X11DRV_TextWidth_normal( fontObject* pfo, XChar2b* pstr, int count )
416 {
417     int ret;
418     wine_tsx11_lock();
419     ret = XTextWidth16( pfo->fs, pstr, count );
420     wine_tsx11_unlock();
421     return ret;
422 }
423
424 static void X11DRV_DrawText_normal( fontObject* pfo, Display* pdisp, Drawable d,
425                                     GC gc, int x, int y, XTextItem16* pitems,
426                                     int count )
427 {
428     wine_tsx11_lock();
429     XDrawText16( pdisp, d, gc, x, y, pitems, count );
430     wine_tsx11_unlock();
431 }
432
433 static void X11DRV_TextExtents_normal( fontObject* pfo, XChar2b* pstr, int count,
434                                        int* pdir, int* pascent, int* pdescent,
435                                        int* pwidth )
436 {
437     XCharStruct info;
438
439     wine_tsx11_lock();
440     XTextExtents16( pfo->fs, pstr, count, pdir, pascent, pdescent, &info );
441     wine_tsx11_unlock();
442     *pwidth = info.width;
443 }
444
445 static void X11DRV_GetTextMetricsW_normal( fontObject* pfo, LPTEXTMETRICW pTM )
446 {
447     LPIFONTINFO16 pdf = &pfo->fi->df;
448
449     if( ! pfo->lpX11Trans ) {
450       pTM->tmAscent = pfo->fs->ascent;
451       pTM->tmDescent = pfo->fs->descent;
452     } else {
453       pTM->tmAscent = pfo->lpX11Trans->ascent;
454       pTM->tmDescent = pfo->lpX11Trans->descent;
455     }
456
457     pTM->tmAscent *= pfo->rescale;
458     pTM->tmDescent *= pfo->rescale;
459
460     pTM->tmHeight = pTM->tmAscent + pTM->tmDescent;
461
462     pTM->tmAveCharWidth = pfo->foAvgCharWidth * pfo->rescale;
463     pTM->tmMaxCharWidth = pfo->foMaxCharWidth * pfo->rescale;
464
465     pTM->tmInternalLeading = pfo->foInternalLeading * pfo->rescale;
466     pTM->tmExternalLeading = pdf->dfExternalLeading * pfo->rescale;
467
468     pTM->tmStruckOut = (pfo->fo_flags & FO_SYNTH_STRIKEOUT )
469                         ? 1 : pdf->dfStrikeOut;
470     pTM->tmUnderlined = (pfo->fo_flags & FO_SYNTH_UNDERLINE )
471                         ? 1 : pdf->dfUnderline;
472
473     pTM->tmOverhang = 0;
474     if( pfo->fo_flags & FO_SYNTH_ITALIC )
475     {
476         pTM->tmOverhang += pTM->tmHeight/3;
477         pTM->tmItalic = 1;
478     } else
479         pTM->tmItalic = pdf->dfItalic;
480
481     pTM->tmWeight = pdf->dfWeight;
482     if( pfo->fo_flags & FO_SYNTH_BOLD )
483     {
484         pTM->tmOverhang++;
485         pTM->tmWeight += 100;
486     }
487
488     pTM->tmFirstChar = pdf->dfFirstChar;
489     pTM->tmLastChar = pdf->dfLastChar;
490     pTM->tmDefaultChar = pdf->dfDefaultChar;
491     pTM->tmBreakChar = pdf->dfBreakChar;
492
493     pTM->tmCharSet = pdf->dfCharSet;
494     pTM->tmPitchAndFamily = pdf->dfPitchAndFamily;
495
496     pTM->tmDigitizedAspectX = pdf->dfHorizRes;
497     pTM->tmDigitizedAspectY = pdf->dfVertRes;
498 }
499
500
501
502 static
503 void X11DRV_DrawString_dbcs( fontObject* pfo, Display* pdisp,
504                              Drawable d, GC gc, int x, int y,
505                              XChar2b* pstr, int count )
506 {
507     XTextItem16 item;
508
509     item.chars = pstr;
510     item.delta = 0;
511     item.nchars = count;
512     item.font = None;
513     X11DRV_cptable[pfo->fi->cptable].pDrawText(
514                 pfo, pdisp, d, gc, x, y, &item, 1 );
515 }
516
517 static
518 int X11DRV_TextWidth_dbcs_2fonts( fontObject* pfo, XChar2b* pstr, int count )
519 {
520     int i;
521     int width;
522     int curfont;
523     fontObject* pfos[X11FONT_REFOBJS_MAX+1];
524
525     pfos[0] = XFONT_GetFontObject( pfo->prefobjs[0] );
526     pfos[1] = pfo;
527     if ( pfos[0] == NULL ) pfos[0] = pfo;
528
529     width = 0;
530     wine_tsx11_lock();
531     for ( i = 0; i < count; i++ )
532     {
533         curfont = ( pstr->byte1 != 0 ) ? 1 : 0;
534         width += XTextWidth16( pfos[curfont]->fs, pstr, 1 );
535         pstr ++;
536     }
537     wine_tsx11_unlock();
538     return width;
539 }
540
541 static
542 void X11DRV_DrawText_dbcs_2fonts( fontObject* pfo, Display* pdisp, Drawable d,
543                                   GC gc, int x, int y, XTextItem16* pitems,
544                                   int count )
545 {
546     int i, nitems, prevfont = -1, curfont;
547     XChar2b* pstr;
548     XTextItem16* ptibuf;
549     XTextItem16* pti;
550     fontObject* pfos[X11FONT_REFOBJS_MAX+1];
551
552     pfos[0] = XFONT_GetFontObject( pfo->prefobjs[0] );
553     pfos[1] = pfo;
554     if ( pfos[0] == NULL ) pfos[0] = pfo;
555
556     nitems = 0;
557     for ( i = 0; i < count; i++ )
558         nitems += pitems->nchars;
559     ptibuf = HeapAlloc( GetProcessHeap(), 0, sizeof(XTextItem16) * nitems );
560     if ( ptibuf == NULL )
561         return; /* out of memory */
562
563     pti = ptibuf;
564     while ( count-- > 0 )
565     {
566         pti->chars = pstr = pitems->chars;
567         pti->delta = pitems->delta;
568         pti->font = None;
569         for ( i = 0; i < pitems->nchars; i++, pstr++ )
570         {
571             curfont = ( pstr->byte1 != 0 ) ? 1 : 0;
572             if ( curfont != prevfont )
573             {
574                 if ( pstr != pti->chars )
575                 {
576                     pti->nchars = pstr - pti->chars;
577                     pti ++;
578                     pti->chars = pstr;
579                     pti->delta = 0;
580                 }
581                 pti->font = pfos[curfont]->fs->fid;
582                 prevfont = curfont;
583             }
584         }
585         pti->nchars = pstr - pti->chars;
586         pitems ++; pti ++;
587     }
588     wine_tsx11_lock();
589     XDrawText16( pdisp, d, gc, x, y, ptibuf, pti - ptibuf );
590     wine_tsx11_unlock();
591     HeapFree( GetProcessHeap(), 0, ptibuf );
592 }
593
594 static
595 void X11DRV_TextExtents_dbcs_2fonts( fontObject* pfo, XChar2b* pstr, int count,
596                                      int* pdir, int* pascent, int* pdescent,
597                                      int* pwidth )
598 {
599     XCharStruct info;
600     int ascent, descent, width;
601     int i;
602     int curfont;
603     fontObject* pfos[X11FONT_REFOBJS_MAX+1];
604
605     pfos[0] = XFONT_GetFontObject( pfo->prefobjs[0] );
606     pfos[1] = pfo;
607     if ( pfos[0] == NULL ) pfos[0] = pfo;
608
609     width = 0;
610     *pascent = 0;
611     *pdescent = 0;
612     wine_tsx11_lock();
613     for ( i = 0; i < count; i++ )
614     {
615         curfont = ( pstr->byte1 != 0 ) ? 1 : 0;
616         XTextExtents16( pfos[curfont]->fs, pstr, 1, pdir, &ascent, &descent, &info );
617         if ( *pascent < ascent ) *pascent = ascent;
618         if ( *pdescent < descent ) *pdescent = descent;
619         width += info.width;
620
621         pstr ++;
622     }
623     wine_tsx11_unlock();
624     *pwidth = width;
625 }
626
627 static void X11DRV_GetTextMetricsW_cp932( fontObject* pfo, LPTEXTMETRICW pTM )
628 {
629     fontObject* pfo_ansi = XFONT_GetFontObject( pfo->prefobjs[0] );
630     LPIFONTINFO16 pdf = &pfo->fi->df;
631     LPIFONTINFO16 pdf_ansi;
632
633     pdf_ansi = ( pfo_ansi != NULL ) ? (&pfo_ansi->fi->df) : pdf;
634
635     if( ! pfo->lpX11Trans ) {
636       pTM->tmAscent = pfo->fs->ascent;
637       pTM->tmDescent = pfo->fs->descent;
638     } else {
639       pTM->tmAscent = pfo->lpX11Trans->ascent;
640       pTM->tmDescent = pfo->lpX11Trans->descent;
641     }
642
643     pTM->tmAscent *= pfo->rescale;
644     pTM->tmDescent *= pfo->rescale;
645
646     pTM->tmHeight = pTM->tmAscent + pTM->tmDescent;
647
648     if ( pfo_ansi != NULL )
649     {
650         pTM->tmAveCharWidth = floor((pfo_ansi->foAvgCharWidth * 2.0 + pfo->foAvgCharWidth) / 3.0 * pfo->rescale + 0.5);
651         pTM->tmMaxCharWidth = max(pfo_ansi->foMaxCharWidth, pfo->foMaxCharWidth) * pfo->rescale;
652     }
653     else
654     {
655         pTM->tmAveCharWidth = floor((pfo->foAvgCharWidth * pfo->rescale + 1.0) / 2.0);
656         pTM->tmMaxCharWidth = pfo->foMaxCharWidth * pfo->rescale;
657     }
658
659     pTM->tmInternalLeading = pfo->foInternalLeading * pfo->rescale;
660     pTM->tmExternalLeading = pdf->dfExternalLeading * pfo->rescale;
661
662     pTM->tmStruckOut = (pfo->fo_flags & FO_SYNTH_STRIKEOUT )
663                         ? 1 : pdf->dfStrikeOut;
664     pTM->tmUnderlined = (pfo->fo_flags & FO_SYNTH_UNDERLINE )
665                         ? 1 : pdf->dfUnderline;
666
667     pTM->tmOverhang = 0;
668     if( pfo->fo_flags & FO_SYNTH_ITALIC )
669     {
670         pTM->tmOverhang += pTM->tmHeight/3;
671         pTM->tmItalic = 1;
672     } else
673         pTM->tmItalic = pdf->dfItalic;
674
675     pTM->tmWeight = pdf->dfWeight;
676     if( pfo->fo_flags & FO_SYNTH_BOLD )
677     {
678         pTM->tmOverhang++;
679         pTM->tmWeight += 100;
680     }
681
682     pTM->tmFirstChar = pdf_ansi->dfFirstChar;
683     pTM->tmLastChar = pdf_ansi->dfLastChar;
684     pTM->tmDefaultChar = pdf_ansi->dfDefaultChar;
685     pTM->tmBreakChar = pdf_ansi->dfBreakChar;
686
687     pTM->tmCharSet = pdf->dfCharSet;
688     pTM->tmPitchAndFamily = pdf->dfPitchAndFamily;
689
690     pTM->tmDigitizedAspectX = pdf->dfHorizRes;
691     pTM->tmDigitizedAspectY = pdf->dfVertRes;
692 }
693
694
695
696
697
698 const X11DRV_CP X11DRV_cptable[X11DRV_CPTABLE_COUNT] =
699 {
700     { /* SBCS */
701         X11DRV_enum_subfont_charset_normal,
702         X11DRV_unicode_to_char2b_sbcs,
703         X11DRV_DrawString_normal,
704         X11DRV_TextWidth_normal,
705         X11DRV_DrawText_normal,
706         X11DRV_TextExtents_normal,
707         X11DRV_GetTextMetricsW_normal,
708     },
709     { /* UNICODE */
710         X11DRV_enum_subfont_charset_normal,
711         X11DRV_unicode_to_char2b_unicode,
712         X11DRV_DrawString_normal,
713         X11DRV_TextWidth_normal,
714         X11DRV_DrawText_normal,
715         X11DRV_TextExtents_normal,
716         X11DRV_GetTextMetricsW_normal,
717     },
718     { /* CP932 */
719         X11DRV_enum_subfont_charset_cp932,
720         X11DRV_unicode_to_char2b_cp932,
721         X11DRV_DrawString_dbcs,
722         X11DRV_TextWidth_dbcs_2fonts,
723         X11DRV_DrawText_dbcs_2fonts,
724         X11DRV_TextExtents_dbcs_2fonts,
725         X11DRV_GetTextMetricsW_cp932,
726     },
727     { /* CP936 */
728         X11DRV_enum_subfont_charset_cp936,
729         X11DRV_unicode_to_char2b_cp936,
730         X11DRV_DrawString_dbcs,
731         X11DRV_TextWidth_dbcs_2fonts,
732         X11DRV_DrawText_dbcs_2fonts,
733         X11DRV_TextExtents_dbcs_2fonts,
734         X11DRV_GetTextMetricsW_normal, /* FIXME */
735     },
736     { /* CP949 */
737         X11DRV_enum_subfont_charset_cp949,
738         X11DRV_unicode_to_char2b_cp949,
739         X11DRV_DrawString_dbcs,
740         X11DRV_TextWidth_dbcs_2fonts,
741         X11DRV_DrawText_dbcs_2fonts,
742         X11DRV_TextExtents_dbcs_2fonts,
743         X11DRV_GetTextMetricsW_normal, /* FIXME */
744     },
745     { /* CP950 */
746         X11DRV_enum_subfont_charset_cp950,
747         X11DRV_unicode_to_char2b_cp950,
748         X11DRV_DrawString_dbcs,
749         X11DRV_TextWidth_dbcs_2fonts,
750         X11DRV_DrawText_dbcs_2fonts,
751         X11DRV_TextExtents_dbcs_2fonts,
752         X11DRV_GetTextMetricsW_cp932,
753     },
754     { /* SYMBOL */
755         X11DRV_enum_subfont_charset_normal,
756         X11DRV_unicode_to_char2b_symbol,
757         X11DRV_DrawString_normal,
758         X11DRV_TextWidth_normal,
759         X11DRV_DrawText_normal,
760         X11DRV_TextExtents_normal,
761         X11DRV_GetTextMetricsW_normal,
762     }
763 };