I would guess you are working on Windows?

wxVSCROLL isn't in the list of styles available for wxTextCtrl. It isn't needed. Remove it and all works OK.

It seems you can get away with it on Linux - but not on Windows.

For the Wx::Font you can just do

 my $font = Wx::Font->new( $FontSize}, wxFONTFAMILY_SWISS,
 wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, 0, "Arial");

Cheers

Mark




On 22/04/2013 20:51, Octavian Rasnita wrote:
Hi,

I have a text field defined as:

    $self->{defs} = Wx::TextCtrl->new(
        $self->{panel},
        -1,
        "",
        wxDefaultPosition,
        [ 500, 400 ],
        wxTE_MULTILINE | wxTE_READONLY | wxVSCROLL | wxTE_PROCESS_ENTER |
          wxTE_RICH2
    );

And I am trying to set a font for it using:

    my $font = Wx::Font->new( $FontSize}, wxFONTFAMILY_SWISS,
wxFONTSTYLE_NORMAL,
        wxFONTWEIGHT_NORMAL, 0, "Arial Unicode MS",
wxFONTENCODING_SYSTEM );

    my $style = Wx::TextAttr->new;
    $style->Wx::TextAttr::SetFont($font);
    $self->{defs}->SetDefaultStyle($style);

But if I print UTF-8 chars in this field, it prints squares instead of
special UTF-8 chars (non ASCII).
Should it work this way and the text might be wrong UTF-8 encoded?

I also read in the WxPerl documentation:

""
The known font encodings are:
...
wxFONTENCODING_UTF8,            // UTF-8 Unicode encoding
""

So I tried to change wxFONTENCODING_SYSTEM with wxFONTENCODING_UTF8 in
the code above.
But this just makes WxPerl to pop up a window that tells:

""
Wx::SimpleApp: unknown encoding
No font for displaying text in encoding 'Unicode 8 bit (UTF-8)'
found.Would you like to select a font to be used for this encoding
(otherwise the text in this encoding will not be shown correctly)?
Yes No
""

So I created another small program to find which are the available
encodings:

use Wx ':everything';
use Data::Dump 'pp';
my $enum = Wx::FontEnumerator->new;
my @encodings = $enum->GetEncodings;
print pp \@encodings;

And the result was:

[
  "WINDOWS-1250",
  "WINDOWS-437",
  "unknown-87",
  "WINDOWS-1252",
  "WINDOWS-1255",
  "WINDOWS-1256",
  "WINDOWS-1253",
  "WINDOWS-1254",
  "WINDOWS-1257",
  "WINDOWS-1251",
  "unknown--1",
  "WINDOWS-874",
  "unknown--1",
  "WINDOWS-932",
  "WINDOWS-949",
  "unknown--1",
  "WINDOWS-936",
  "WINDOWS-950",
]

So there is no encoding that contains "UTF-8" in its name.
Does this mean that WxPerl can't print UTF-8 texts?

Or there is something else I need to do?

In the same documentation page, when describing the constructor of the
Wx::Font object, it describes the "encoding" parameter as:

""
encoding

    An encoding which may be one of
wxFONTENCODING_SYSTEM
wxFONTENCODING_DEFAULT
wxFONTENCODING_ISO8859_1...15
wxFONTENCODING_KOI8
wxFONTENCODING_CP1250...1252
""

In this list of possible encodings appear only these items, and no one
that includes "UTF8".

Eventually, is there an example of writing text with a certain font that
supports UTF-8?

Thanks.

--Octavian


Reply via email to