source: vendor/trolltech/current/src/codecs/qfontlaocodec.cpp

Last change on this file was 2, checked in by dmik, 20 years ago

Imported xplatform parts of the official release 3.3.1 from Trolltech

  • Property svn:keywords set to Id
File size: 4.3 KB
Line 
1/****************************************************************************
2** $Id: qfontlaocodec.cpp 2 2005-11-16 15:49:26Z dmik $
3**
4** Font utilities for X11
5**
6** Created : 20001101
7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9**
10** This file is part of the tools module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "private/qfontcodecs_p.h"
39
40#ifndef QT_NO_CODECS
41#ifndef QT_NO_BIG_CODECS
42
43static unsigned char const unicode_to_mulelao[256] =
44 {
45 // U+0E80
46 0x00, 0xa1, 0xa2, 0x00, 0xa4, 0x00, 0x00, 0xa7,
47 0xa8, 0x00, 0xaa, 0x00, 0x00, 0xad, 0x00, 0x00,
48 // U+0E90
49 0x00, 0x00, 0x00, 0x00, 0xb4, 0xb5, 0xb6, 0xb7,
50 0x00, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
51 // U+0EA0
52 0x00, 0xc1, 0xc2, 0xc3, 0x00, 0xc5, 0x00, 0xc7,
53 0x00, 0x00, 0xca, 0xcb, 0x00, 0xcd, 0xce, 0xcf,
54 // U+0EB0
55 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
56 0xd8, 0xd9, 0x00, 0xdb, 0xdc, 0xdd, 0x00, 0x00,
57 // U+0EC0
58 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0x00, 0xe6, 0x00,
59 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0x00, 0x00,
60 // U+0ED0
61 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
62 0xf8, 0xf9, 0x00, 0x00, 0xfc, 0xfd, 0x00, 0x00,
63 // U+0EE0
64 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
65 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
66 // U+0EF0
67 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
68 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
69 };
70
71
72QFontLaoCodec::QFontLaoCodec()
73{
74}
75
76const char *QFontLaoCodec::name() const
77{
78 return "mulelao-1";
79}
80
81int QFontLaoCodec::mibEnum() const
82{
83 return -4242;
84}
85
86unsigned short QFontLaoCodec::characterFromUnicode(const QString &str, int pos) const
87{
88 const QChar * const ch = str.unicode() + pos;
89 if (ch->unicode() < 0x80)
90 return ch->unicode();
91 if ( ch->unicode() >= 0x0e80 && ch->unicode() <= 0x0eff )
92 return unicode_to_mulelao[ch->unicode() - 0x0e80];
93 return 0;
94}
95
96QCString QFontLaoCodec::fromUnicode(const QString& uc, int& lenInOut ) const
97{
98 QCString rstring( lenInOut+1 );
99 uchar *rdata = (uchar *) rstring.data();
100 const QChar *sdata = uc.unicode();
101 int i = 0;
102 for ( ; i < lenInOut; ++i, ++sdata, ++rdata ) {
103 if ( sdata->unicode() < 0x80 ) {
104 *rdata = (uchar) sdata->unicode();
105 } else if ( sdata->unicode() >= 0x0e80 && sdata->unicode() <= 0x0eff ) {
106 uchar lao = unicode_to_mulelao[sdata->unicode() - 0x0e80];
107 if ( lao )
108 *rdata = lao;
109 else
110 *rdata = '?';
111 } else {
112 *rdata = '?';
113 }
114 }
115 *rdata = 0u;
116 return rstring;
117}
118
119void QFontLaoCodec::fromUnicode(const QChar *in, unsigned short *out, int length) const
120{
121 while (length--) {
122 if ( in->unicode() < 0x80 ) {
123 *out = (uchar) in->unicode();
124 } else if ( in->unicode() >= 0x0e80 && in->unicode() <= 0x0eff ) {
125 *out = unicode_to_mulelao[in->unicode() - 0x0e80];
126 } else {
127 *out = 0;
128 }
129
130 ++in;
131 ++out;
132 }
133}
134
135int QFontLaoCodec::heuristicContentMatch(const char *, int) const
136{
137 return -1;
138}
139
140bool QFontLaoCodec::canEncode( QChar ch ) const
141{
142 return ( ch.unicode() < 0x80 ||
143 unicode_to_mulelao[ch.unicode() - 0x0e80] != 0x00 );
144}
145
146
147#endif // QT_NO_BIG_CODECS
148#endif // QT_NO_CODECS
149
Note: See TracBrowser for help on using the repository browser.