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