From 1e1d0be19102670c4ea8c08ec5b9fd9467dcf02c Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 16 Jan 2000 22:53:19 +0000 Subject: [PATCH] wxNativeEncoding::To/FromString now stores wxFontEncoding info as well (don't worry, wxFontMapper stores data under different name now) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5460 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/fontutil.cpp | 13 +++++++++++-- src/mac/fontutil.cpp | 13 +++++++++++-- src/msw/fontutil.cpp | 14 +++++++++++--- src/os2/fontutil.cpp | 13 +++++++++++-- src/unix/fontutil.cpp | 15 +++++++++++---- 5 files changed, 55 insertions(+), 13 deletions(-) diff --git a/src/mac/carbon/fontutil.cpp b/src/mac/carbon/fontutil.cpp index 49d08234bc..c5a0f583d6 100644 --- a/src/mac/carbon/fontutil.cpp +++ b/src/mac/carbon/fontutil.cpp @@ -48,12 +48,18 @@ // ---------------------------------------------------------------------------- // convert to/from the string representation: format is -// facename[;charset] +// encodingid;facename[;charset] bool wxNativeEncodingInfo::FromString(const wxString& s) { wxStringTokenizer tokenizer(s, _T(";")); + wxString encid = tokenizer.GetNextToken(); + long enc; + if ( !encid.ToLong(&enc) ) + return FALSE; + encoding = (wxFontEncoding)enc; + facename = tokenizer.GetNextToken(); if ( !facename ) return FALSE; @@ -79,7 +85,10 @@ bool wxNativeEncodingInfo::FromString(const wxString& s) wxString wxNativeEncodingInfo::ToString() const { - wxString s(facename); + wxString s; + + s << (long)encoding << _T(';') << facename; + if ( charset != 0 ) { s << _T(';') << charset; diff --git a/src/mac/fontutil.cpp b/src/mac/fontutil.cpp index 49d08234bc..c5a0f583d6 100644 --- a/src/mac/fontutil.cpp +++ b/src/mac/fontutil.cpp @@ -48,12 +48,18 @@ // ---------------------------------------------------------------------------- // convert to/from the string representation: format is -// facename[;charset] +// encodingid;facename[;charset] bool wxNativeEncodingInfo::FromString(const wxString& s) { wxStringTokenizer tokenizer(s, _T(";")); + wxString encid = tokenizer.GetNextToken(); + long enc; + if ( !encid.ToLong(&enc) ) + return FALSE; + encoding = (wxFontEncoding)enc; + facename = tokenizer.GetNextToken(); if ( !facename ) return FALSE; @@ -79,7 +85,10 @@ bool wxNativeEncodingInfo::FromString(const wxString& s) wxString wxNativeEncodingInfo::ToString() const { - wxString s(facename); + wxString s; + + s << (long)encoding << _T(';') << facename; + if ( charset != 0 ) { s << _T(';') << charset; diff --git a/src/msw/fontutil.cpp b/src/msw/fontutil.cpp index f75d090505..6d80870a22 100644 --- a/src/msw/fontutil.cpp +++ b/src/msw/fontutil.cpp @@ -50,12 +50,18 @@ // ---------------------------------------------------------------------------- // convert to/from the string representation: format is -// facename[;charset] +// encodingid;facename[;charset] bool wxNativeEncodingInfo::FromString(const wxString& s) { wxStringTokenizer tokenizer(s, _T(";")); + wxString encid = tokenizer.GetNextToken(); + long enc; + if ( !encid.ToLong(&enc) ) + return FALSE; + encoding = (wxFontEncoding)enc; + facename = tokenizer.GetNextToken(); if ( !facename ) return FALSE; @@ -81,10 +87,12 @@ bool wxNativeEncodingInfo::FromString(const wxString& s) wxString wxNativeEncodingInfo::ToString() const { - wxString s(facename); + wxString s; + + s << (long)encoding << _T(';') << facename; if ( charset != ANSI_CHARSET ) { - s << _T(';') << charset; + s << _T(';') << charset; } return s; diff --git a/src/os2/fontutil.cpp b/src/os2/fontutil.cpp index d36dbb08f5..5f135b0327 100644 --- a/src/os2/fontutil.cpp +++ b/src/os2/fontutil.cpp @@ -42,12 +42,18 @@ // ---------------------------------------------------------------------------- // convert to/from the string representation: format is -// facename[;charset] +// encodingid;facename[;charset] bool wxNativeEncodingInfo::FromString(const wxString& s) { wxStringTokenizer tokenizer(s, _T(";")); + wxString encid = tokenizer.GetNextToken(); + long enc; + if ( !encid.ToLong(&enc) ) + return FALSE; + encoding = (wxFontEncoding)enc; + facename = tokenizer.GetNextToken(); if ( !facename ) return FALSE; @@ -74,7 +80,10 @@ bool wxNativeEncodingInfo::FromString(const wxString& s) wxString wxNativeEncodingInfo::ToString() const { - wxString s(facename); + wxString s; + + s << (long)encoding << _T(';') << facename; + // TODO: what is this for OS/2? /* if ( charset != ANSI_CHARSET ) diff --git a/src/unix/fontutil.cpp b/src/unix/fontutil.cpp index db1939e352..036c84272d 100644 --- a/src/unix/fontutil.cpp +++ b/src/unix/fontutil.cpp @@ -106,10 +106,17 @@ static wxNativeFont wxLoadQueryFont(int pointSize, // ---------------------------------------------------------------------------- // convert to/from the string representation: format is -// registry-encoding[-facename] +// encodingid;registry;encoding[;facename] bool wxNativeEncodingInfo::FromString(const wxString& s) { - wxStringTokenizer tokenizer(s, _T("-")); + wxStringTokenizer tokenizer(s, _T(";")); + // cannot use "-" because it may be part of encoding name + + wxString encid = tokenizer.GetNextToken(); + long enc; + if ( !encid.ToLong(&enc) ) + return FALSE; + encoding = (wxFontEncoding)enc; xregistry = tokenizer.GetNextToken(); if ( !xregistry ) @@ -128,10 +135,10 @@ bool wxNativeEncodingInfo::FromString(const wxString& s) wxString wxNativeEncodingInfo::ToString() const { wxString s; - s << xregistry << _T('-') << xencoding; + s << (long)encoding << _T(';') << xregistry << _T(';') << xencoding; if ( !!facename ) { - s << _T('-') << facename; + s << _T(';') << facename; } return s; -- 2.45.2