]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/fontutil.cpp
use WX_DEFINE_ARRAY_INT for an array of ints (bug 1536482)
[wxWidgets.git] / src / mac / carbon / fontutil.cpp
CommitLineData
72e7876b
SC
1///////////////////////////////////////////////////////////////////////////////
2// Name: msw/fontutil.cpp
3// Purpose: font-related helper functions for wxMSW
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 05.11.99
7// RCS-ID: $Id$
8// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
65571936 9// Licence: wxWindows licence
72e7876b
SC
10///////////////////////////////////////////////////////////////////////////////
11
72e7876b
SC
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
18#ifndef WX_PRECOMP
19 #include "wx/string.h"
20 #include "wx/log.h"
21 #include "wx/intl.h"
f3078f07 22#endif
72e7876b
SC
23
24#include "wx/fontutil.h"
25#include "wx/fontmap.h"
050ffabb 26#include "wx/encinfo.h"
72e7876b
SC
27#include "wx/tokenzr.h"
28
72e7876b 29
f3078f07
DS
30// convert to/from the string representation:
31// format is facename[;charset]
32//
33bool wxNativeEncodingInfo::FromString( const wxString& s )
72e7876b 34{
f3078f07 35 wxStringTokenizer tokenizer(s, wxT(";"));
72e7876b
SC
36
37 facename = tokenizer.GetNextToken();
38 if ( !facename )
f3078f07 39 return false;
72e7876b
SC
40
41 wxString tmp = tokenizer.GetNextToken();
42 if ( !tmp )
43 {
44 // default charset (don't use DEFAULT_CHARSET though because of subtle
45 // Windows 9x/NT differences in handling it)
46 charset = 0;
47 }
48 else
49 {
f3078f07 50 if ( wxSscanf( tmp, wxT("%u"), &charset ) != 1 )
72e7876b 51 // should be a number!
f3078f07 52 return false;
72e7876b
SC
53 }
54
f3078f07 55 return true;
72e7876b
SC
56}
57
58wxString wxNativeEncodingInfo::ToString() const
59{
2f1ae414 60 wxString s(facename);
72e7876b 61 if ( charset != 0 )
f3078f07 62 s << wxT(';') << charset;
72e7876b
SC
63
64 return s;
65}
66
67// ----------------------------------------------------------------------------
68// helper functions
69// ----------------------------------------------------------------------------
70
f3078f07 71bool wxGetNativeFontEncoding( wxFontEncoding encoding, wxNativeEncodingInfo *info )
72e7876b 72{
f3078f07 73 wxCHECK_MSG( info, false, wxT("bad pointer in wxGetNativeFontEncoding") );
72e7876b
SC
74
75 if ( encoding == wxFONTENCODING_DEFAULT )
72e7876b 76 encoding = wxFont::GetDefaultEncoding();
72e7876b 77
f3078f07 78 info->encoding = encoding;
72e7876b 79
f3078f07 80 return true;
72e7876b
SC
81}
82
f3078f07 83bool wxTestFontEncoding( const wxNativeEncodingInfo& info )
72e7876b 84{
f3078f07
DS
85 // basically we should be able to support every encoding via the OS
86 return true;
72e7876b 87}