Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
No such thing as a small change
 
PerlMonks  

Perl Tk -font option is not working in linux if the language is japanese

by LeonelMendoza (Initiate)
on Nov 06, 2012 at 07:56 UTC ( #1002427=perlquestion: print w/ replies, xml ) Need Help??
LeonelMendoza has asked for the wisdom of the Perl Monks concerning the following question:

-font option is not working in all my widget, I specified "-adobe-helvetica-regular-r-normal-*-12-*-*-*-*-*-*-*" in all the font options, but the font options its displaying is kochi-gothic. This only happens when the language is japanese. But sadly, I have to support -adobe-helvetica- as its fonts even though the language is japanese! please help.....

Comment on Perl Tk -font option is not working in linux if the language is japanese
Re: Perl Tk -font option is not working in linux if the language is japanese
by choroba (Abbot) on Nov 06, 2012 at 08:59 UTC
    Does the font setting work for any other font with Japanese?
    Are you sure the font in questions can display Japanese?
    Can you show a short sample code that demostrates the problem?
    This works for me:
    perl -MEncode -MTk -e 'my $j = decode("utf-8", "\xe6\x97\xa5\xe6\x9c\x +ac\xe5\x9b\xbd"); my $w = new MainWindow::; $w->Label(-text => $j, -font => "-adobe-helvetica-regular-r-normal-*-12-*-*-*-* +-*-*-*" )->pack; MainLoop()'
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Perl Tk -font option is not working in linux if the language is japanese
by zentara (Archbishop) on Nov 06, 2012 at 18:11 UTC
    I've hit that glitch before. Maybe try making a Tk::Font object. Try to make a small example which demonstrates the problem. This displays Japanese for me.
    #!/usr/bin/perl use warnings; use strict; use Tk; my $mw=tkinit; $mw->fontCreate('big', -family=>'arial', -weight=>'bold', -size=> 38 ); my $string = "\x{65E5}\x{672C}\x{8A9E}\x{306E}\x{3072}\x{3089}\x{304C} +\x{306A}\x{6F22 }\x{5B57}\x{3068}\x{30AB}\x{30BF}\x{30AB}\x{30CA}"; my $label = $mw->Label(-bg => 'white', -text => $string, -font => 'big')->pack(); MainLoop;

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
      Here's my code:
      my $label = $mw->Label(-bg => 'white', -text => $string, -font => "-adobe-helvetica-regular-r-normal-*-1 +2-*-*-*-*-*-*-*")->pack();

      I've tried english as the language when using linux, and instead of adobe helvetica that i specified it is using "Nimbus sans L" as its font. I've also tried font create but it's the same....

        First, do you actually have the adobe font that you're trying to use? On my system, it doesn't exist; however, I improvised and settled on this:
        #!/usr/bin/perl BEGIN { $| = 1; $^W = 1; } use strict; use warnings; use Tk; use Tk::X11Font; my $font = "-adobe-helvetica-bold-r-normal--12-120-75-75-p-70-iso8859- +1"; my $mw = MainWindow->new; $mw->geometry('100x150'); my $label = $mw->Label( -bg => 'white', -text => "Help!", -font => \$font, )->pack; MainLoop;
        Your code works for me here. I think you are missing the font you specified. This works, 2 labels shown, both Japanese, different fonts.
        #!/usr/bin/perl use warnings; use strict; use Tk; my $mw=tkinit; $mw->fontCreate('big', -family=>'arial', -weight=>'bold', -size=> 38 ); my $string = "\x{65E5}\x{672C}\x{8A9E}\x{306E}\x{3072}\x{3089}\x{304C} +\x{306A}\x{6F22 }\x{5B57}\x{3068}\x{30AB}\x{30BF}\x{30AB}\x{30CA}"; my $label = $mw->Label(-bg => 'white', -text => $string, -font => 'big')->pack(); my $label1 = $mw->Label(-bg => 'white', -text => $string, -font => "-adobe-helvetica-regular-r-normal-*-1 +2-*-*-*-*-*-*-*")->pack(); MainLoop;

        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1002427]
Approved by rovf
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (15)
As of 2014-04-16 20:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (434 votes), past polls