Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

perl-tk fonts with linux

257 views
Skip to first unread message

patcat

unread,
Jun 17, 2010, 3:09:13 AM6/17/10
to
Hello,
I am trying to use the unicode font "STIXGeneral.otf" with Perl-Tk
(since I am making a math word processor). In order to test this font,
I have written a small HTML file and a small Perl-Tk script (see
below) and used them with the following results :
-- the HTML file works very well with Windows Vista and Linux Ubuntu
(better with Linux since it displays the &#1F000; character)
-- the Perl-Tk script works very well with Windows Vista,
but very bad with Linux Ubuntu (the characters are either ugly,
or displayed with another font).
Why is Perl-Tk working not so good with Linux than with Windows ?
Is there now (or in a near future) a solution for this problem ? Does
it depend on Perl-Tk, on Linux or on STIXGeneral ? Is it a version
problem ?
Please, can anyone help me ?
--------
-- STIXtest.htm
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title></head><body><font face="STIXGeneral" size="5">
STIXGeneral (html)<br>——o——<br>A B C D ̀x ̂x ̃x ̄x<br>
ℌ ℎ ℒ ℕ ∂ ∇ ∑ √ !🀀!<br>——o——<br>
</font></body></html>
--------
-- STIXtest.pl
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();
--------

Steve C

unread,
Jun 17, 2010, 4:36:45 PM6/17/10
to
patcat wrote:
> Hello,
> I am trying to use the unicode font "STIXGeneral.otf" with Perl-Tk
> (since I am making a math word processor). In order to test this font,
> I have written a small HTML file and a small Perl-Tk script (see
> below) and used them with the following results :
> -- the HTML file works very well with Windows Vista and Linux Ubuntu
> (better with Linux since it displays the &#1F000; character)
> -- the Perl-Tk script works very well with Windows Vista,
> but very bad with Linux Ubuntu (the characters are either ugly,
> or displayed with another font).
> Why is Perl-Tk working not so good with Linux than with Windows ?
> Is there now (or in a near future) a solution for this problem ? Does
> it depend on Perl-Tk, on Linux or on STIXGeneral ? Is it a version
> problem ?
> Please, can anyone help me ?


I think it is likely that X is not supplying the font to Tk.

On Windows, to install a font you copy it to the Font folder.

On linux, to install an OpenType font you copy it to ~/.fonts
Verify that it is detected by running:
fc-list

Try printing some of the attributes described in Tk::Font to see
if they are what you expect.

$t->configure(-font=>$font);
print join(" ",$t->fontActual($font)),"\n";

I wasn't able to get an otf font to work on my system, it always
printed: -family fixed

When I tried a helvetica or courier font, it printed the right family.

You could also try converting it to a truetype font using fontforge.

perlgenome

unread,
Jun 17, 2010, 5:11:08 PM6/17/10
to
Test this code coming from Master Book :

use Tk;
use strict;

# initial banner text. Entry is not read-only
my $str =
"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789";

my $mw = MainWindow->new;
my $lframe = $mw->Frame->pack(-fill => 'both',
-side => 'left', -expand => 1);
my $lb = $lframe->Scrolled("Listbox", -scrollbars => "e",
-height => 3)->pack(-fill => 'both', -expand => 1, -side => 'top');

$lb->insert('end', sort $mw->fontFamilies);

# Button that will pop the config widgets in and out
my $hidebutton = $mw->Button(-text => ">")->pack(-side => 'left',
-fill => 'y');
$hidebutton->configure(-command =>
sub {
if ($hidebutton->cget(-text) eq ">") {
$lframe->packForget; $hidebutton->configure(-text => "<")
} else {
$lframe->pack(-before => $hidebutton, -fill => 'both',
-side => 'left', -expand => 1);
$hidebutton->configure(-text => ">");
}
}, -font => "courier 8");

my $entry = $mw->Entry(
-textvariable => \$str,
-width => 12,
-font => "{Comic Sans MS} 72",
-relief => 'raised',
-highlightthickness => 0,
)->pack(-expand => 1, -fill => 'x', -side => 'left');

$lb->bind("<Button>", sub { $entry->configure(
-font => "{". $lb->get($lb->curselection) . "} 72"); });

my $repeat_id = $mw->repeat(300, \&shift_banner);

my $f = $lframe->Frame->pack(-side => 'bottom', -fill => 'y');
my $start_button;
$start_button = $f->Button(-text => "Start",
-command => sub {
$repeat_id = $mw->repeat(300,\&shift_banner);
$start_button->configure(-state => 'disabled'); },
-state => 'disabled')->pack(-side => 'left', -padx => 3);
my $stop_button = $f->Button(-text => "Stop", -command => sub {
$repeat_id->cancel( );
$start_button->configure(-state => 'normal'); }
)->pack(-side => 'left', -padx => 3);

MainLoop;

# Causes text to be wrapped around in entry
sub shift_banner {
my $newstr = substr($str, 1) . substr($str, 0, 1);
$str = $newstr;
}

Steve C

unread,
Jun 17, 2010, 6:04:41 PM6/17/10
to
perlgenome wrote:
> Test this code coming from Master Book :
>

It lists none of my installed otf fonts.

0 new messages