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