CSS fonts
- From: "Les Trol" <lestrol123 gmx com>
- To: gtk-perl-list gnome org
- Subject: CSS fonts
- Date: Thu, 14 Feb 2019 10:56:57 +0100
Hello all,
I have been trying to apply colours and fonts to a Gtk3::TextView, so I can use it as terminal with coloured text. Colours work fine, but fonts don't work at all.
I notice from various Google searches that there was a bug in earlier versions of Gtk3. On my Linux Mint box, /usr/share/perl5/Gtk3.pm provides $Gtk3::VERSION = '0.032', so presumably that bug doesn't apply.
I've tried various combinations of fonts, sizes and styles. I've tried different CSS attributes besides 'font', for example 'font-family' and 'font-size'.
Can anyone confirm whether they are having the same problem, or suggest a way to get it working?
---
#!/usr/bin/perl
use strict;
use diagnostics;
use warnings;
#use Glib qw(TRUE FALSE);
use Gtk3 '-init';
# Set up CSS style
my $provider = Gtk3::CssProvider->new();
my $display = Gtk3::Gdk::Display::get_default;
my $screen = Gtk3::Gdk::Display::get_default_screen($display);
Gtk3::StyleContext::add_provider_for_screen($screen, $provider, 600);
my $theming = "textview text {\nbackground-color: #000000;\ncolor: #FF0000;font: 10px \"Monospace\";\n}";
$provider->load_from_data($theming);
# Open a Gtk3 window containing a Gtk3::TextView
my $window = Gtk3::Window->new('toplevel');
$window->set_title('Hello world');
$window->set_position('center');
$window->set_default_size(600, 400);
$window->signal_connect('delete-event' => sub {
Gtk3->main_quit();
exit;
});
my $scrollWin = Gtk3::ScrolledWindow->new(undef, undef);
$window->add($scrollWin);
my $textView = Gtk3::TextView->new;
$scrollWin->add_with_viewport($textView);
$textView->get_buffer()->set_text("Hello, world!");
$window->show_all();
Gtk3->main();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]