Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

open-type fonts for Perl-Tk with Linux

by patcat (Initiate)
on Jun 21, 2010 at 13:43 UTC ( #845748=perlquestion: print w/replies, xml ) Need Help??
patcat has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to use the unicode open-type font "STIXGeneral.otf" with Perl-Tk, for I am making a math word processor. In order to test this font, I have written a small Perl-Tk script (see below) and a small HTML file (displaying the same characters), in order to test this font.
use utf8;use Tk; $f="STIXGeneral";$c="\n"; $s="\x{2014}"x2;$s=$c.$s."o".$s.$c;$p=" (Perl-Tk)"; $s=$f.$p.$s."A B C D \x{300}x \x{302}x \x{303}x ". "\x{304}x".$c."\x{210C} \x{210E} \x{2112} \x{2115} ". "\x{2202} \x{2207} \x{2211} \x{221A}".$s; $m=MainWindow->new(-title=>'STIXtest (P. Assouad)'); $m->geometry('400x400+40+40'); $t=$m->Scrolled('Text')->pack(); $t->configure(-font=>"{".$f."} 18 {normal}"); $t->insert('1.0',$s); MainLoop();
The results are the following : -- the Perl-Tk script works very well with Windows Vista, but very bad with Linux Ubuntu (the font is not recognized by Perl-Tk, although the browser recognizes it) ; -- the HTML file works very well with both Windows Vista and Linux Ubuntu. If I replace open-type by true-type, the things are not better. What do you think about ?

Replies are listed 'Best First'.
Re: open-type fonts for Perl-Tk with Linux
by lamprecht (Friar) on Jun 21, 2010 at 15:43 UTC

    which version of Tk is that? Your example looks nice on Ubuntu 8.04. You probably need to build Tk with XFT=1. I think this is default with latest versions from CPAN.

    Cheers, Chris

    Update: Sorry, I was wrong: It's not set by default. You have to explicitly enable XFT support with perl Makefile.PL XFT=1

Re: open-type fonts for Perl-Tk with Linux
by Tux (Abbot) on Jun 22, 2010 at 08:28 UTC

    I'd like to try, but I cannot find STIXGeneral.otf available for download or in a (OpenSUSE) package.

    Enjoy, Have FUN! H.Merijn

        I fetched the ZIP-file from download, copied all Fonts/*.otf to /usr/share/fonts/truetype and then ran

        use strict; use warnings; use Tk; my $f = "STIXGeneral"; my $l = "\x{2014}\x{2014}o\x{2014}\x{2014}"; my $m = MainWindow->new (-title => "STIXtest (P. Assouad)"); $m->geometry ("400x400+40+40"); my $t = $m->Scrolled ("Text")->pack; $t->configure (-font => "{$f} 18 normal"); $t->insert ("1.0", join "\n" => "$f (Perl-Tk)", $l, "A B C D \x{300}x \x{302}x \x{303}x \x{304}x", "\x{210C} \x{210E} \x{2112} \x{2115} \x{2202}". "\x{2207} \x{2211} \x{221A}", $l); MainLoop ();

        and then got this, which looks pretty OK to me. Note that I left out the braces around normal

        This is perl, v5.10.1 (*) built for x86_64-linux ...perl5/site_perl/5.10.1/x86_64-linux/ 804.029

        Enjoy, Have FUN! H.Merijn

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://845748]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2018-04-25 02:02 GMT
Find Nodes?
    Voting Booth?