source: trunk/src/gui/text/qfont_pm.cpp@ 371

Last change on this file since 371 was 371, checked in by Dmitry A. Kuminov, 15 years ago

gui: Improved font handling (patch by komh):

  • Read national face names from font files instead of always taking the Latin name.
  • Use the PM_AssociateFont registry key to select a fallback font for missing glyphs (important on DBCS systems).
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Date Revision Author Id
File size: 4.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** Copyright (C) 2009 netlabs.org. OS/2 parts.
7**
8** This file is part of the QtGui module of the Qt Toolkit.
9**
10** $QT_BEGIN_LICENSE:LGPL$
11** Commercial Usage
12** Licensees holding valid Qt Commercial licenses may use this file in
13** accordance with the Qt Commercial License Agreement provided with the
14** Software or, alternatively, in accordance with the terms contained in
15** a written agreement between you and Nokia.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 2.1 requirements
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24**
25** In addition, as a special exception, Nokia gives you certain
26** additional rights. These rights are described in the Nokia Qt LGPL
27** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
28** package.
29**
30** GNU General Public License Usage
31** Alternatively, this file may be used under the terms of the GNU
32** General Public License version 3.0 as published by the Free Software
33** Foundation and appearing in the file LICENSE.GPL included in the
34** packaging of this file. Please review the following information to
35** ensure the GNU General Public License version 3.0 requirements will be
36** met: http://www.gnu.org/copyleft/gpl.html.
37**
38** If you are unsure which license is appropriate for your use, please
39** contact the sales department at [email protected].
40** $QT_END_LICENSE$
41**
42****************************************************************************/
43
44#include "qt_os2.h"
45#include "qfont.h"
46#include "qfont_p.h"
47#include "qfontengine_p.h"
48#include "qtextengine_p.h"
49#include "qfontmetrics.h"
50#include "qfontinfo.h"
51
52QT_BEGIN_NAMESPACE
53
54Q_GUI_EXPORT const char *qt_fontFamilyFromStyleHint(const QFontDef &request)
55{
56 const char *family = 0;
57 switch (request.styleHint) {
58 case QFont::Helvetica:
59 family = "Helvetica";
60 break;
61 case QFont::Times:
62 case QFont::OldEnglish:
63 family = "Times New Roman";
64 break;
65 case QFont::Courier:
66 family = "Courier";
67 break;
68 case QFont::System:
69 family = "WarpSans";
70 break;
71 case QFont::AnyStyle:
72 default:
73 static char szFontName[FACESIZE + 1] = {0,};
74
75 // already queried ?
76 if (szFontName[0] != ';') {
77 szFontName[0] = ';';
78 // query the associated font
79 if (PrfQueryProfileString(HINI_USERPROFILE,
80 "PM_SystemFonts", "PM_AssociateFont", 0,
81 szFontName, sizeof(szFontName))) {
82 szFontName[FACESIZE] = '\0';
83
84 // the format of the associated font is face_name;point_size
85 // so remove ';' and later
86 for (PSZ pch = szFontName; *pch; pch++)
87 if (*pch == ';') {
88 *pch = '\0';
89 break;
90 }
91 }
92 }
93
94 // is the associated font available ?
95 if (szFontName[0] != '\0' && szFontName[0] != ';')
96 family = szFontName;
97 else if (request.fixedPitch)
98 family = "Courier";
99 else
100 family = "Helvetica";
101 break;
102 }
103 return family;
104}
105
106/*****************************************************************************
107 QFont member functions
108 *****************************************************************************/
109
110void QFont::initialize()
111{
112}
113
114void QFont::cleanup()
115{
116 QFontCache::cleanup();
117}
118
119QString QFont::rawName() const
120{
121 return family();
122}
123
124void QFont::setRawName(const QString &name)
125{
126 setFamily(name);
127}
128
129QString QFont::defaultFamily() const
130{
131 return QString::fromLocal8Bit(qt_fontFamilyFromStyleHint(d->request));
132}
133
134QString QFont::lastResortFamily() const
135{
136 return QString::fromLatin1("Helvetica");
137}
138
139QString QFont::lastResortFont() const
140{
141 return QString::fromLatin1("Helvetica");
142}
143
144QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.