Giter Site home page Giter Site logo

prima's Introduction

Description

PRIMA is a general-purpose extensible graphical user interface toolkit with a rich set of standard widgets and an emphasis on 2D image processing tasks. A Perl program using PRIMA looks and behaves identically on X11 and Win32.

Example

Screenshot

use Prima qw(Application Buttons);

Prima::MainWindow->new(
	text     => 'Hello world!',
	size     => [ 200, 200],
)-> insert( Button =>
	centered => 1,
	text     => 'Hello world!',
	onClick  => sub { $::application-> close },
);

run Prima;

More screenshots at http://prima.eu.org/big-picture/

Installation

Debian/Ubuntu

apt-get install libgtk-3-dev libgif-dev libjpeg-dev libtiff-dev libxpm-dev libwebp-dev libfribidi-dev libharfbuzz-dev libthai-dev libheif-dev libfreetype-dev

FreeBSD

pkg install gtk3 fribidi harfbuzz libxpm libthai pkgconf tiff webp
giflib libheif freetype2 libheif Xrandr libXcomposite libXcursor
libXft fontconfig

OpenSUSE

zypper install gtk3-devel giflib-devel libjpeg-devel libtiff-devel libXpm-devel libXrandr-devel libXcomposite-devel libXcursor-devel libfribidi-devel libwebp-devel libharfbuzz-devel libthai-devel libheif-devel libfreetype-dev

Solaris

Download and install Oracle Developer Studio as the vendor-provided perl is compiled with cc, not gcc

Cygwin

Win32-Strawberry

v5.32 had the necessary libraries included, but v5.38 hasn't. Install these:

Win32-ActiveState

ActiveState currently doesn't support local compilations. The official answer is here: https://community.activestate.com/t/how-to-install-gcc-and-or-mingw/10993/2 . Consider migrating to Strawberry Perl.

Win32-other

For the older distributions or custom Perl builds, CPAN contains binary distributions that can be installed just for this purpose:

it should work for all MSVC and GCC compilers and native, cygwin, and mingw/strawberry perl runtimes.

MacOSX

You'll need homebrew, XQuartz, and a set of extra libraries.

  • install homebrew:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  • install XQuartz:

    brew install --cask xquartz

  • install support libraries:

    brew install libiconv libxcomposite libxrandr libxcursor libxft fribidi fontconfig freetype giflib gtk+3 harfbuzz jpeg libpng libtiff webp libxpm libheif

Note: if Prima crashes in libxft, do this: remove libxft and install custom-built xorg libraries, either very minimal

brew install dk/x11/xorg-macros dk/x11/libxft

or linux-homebrew's (not tested)

brew tap linuxbrew/xorg

brew install linuxbrew/xorg/libxft

  • install libthai:

    brew install dk/libthai/libthai

Optional dependencies

Graphic libraries

Prima can use several graphic libraries to handle image files. Compiling Prima with at least one library, preferably for GIF files is strongly recommended, because internal library images are stored in GIFs. Support for the following libraries can be compiled on all platforms:

  • libXpm
  • libpng
  • libjpeg
  • libgif
  • libtiff
  • libwebp,libwebpdemux,libwebpmux
  • libheif

(libheif is not widespread yet. See Prima/Image/heif.pm for details)

Bidirectional input and complex scripts

  • To support bi-directional unicode text input and output you'll need the fribidi library. Additionally for unix builds you'll need the harfbuzz library for output of complex scripts and font ligature support. Prima can compile and work fine without these libraries, but the support of the features will be rather primitive.

  • The Thai language doesn't use spaces between the words in a sentence. To wrap Thai texts properly Prima can be compiled with the libthai library. No special treatment of Thai text is needed programmatically, the text wrapper does everything under the hood.

GTK3/GTK2

It is recommended to build Prima with GTK3/GTK2 on X11 installations because in that case, Prima will use standard GTK fonts, colors, and file dialogs. By default, Prima tries to build with it, but if you don't want it, run

perl Makefile.PL WITH_GTK2=0 WITH_GTK3=0

Source distribution installation

Create a makefile by running Makefile.PL using perl and then run make ( or gmake, or nmake for Win32):

perl Makefile.PL
make
make test
make install

(the brave souls may run make xtest too)

If 'perl Makefile.PL' fails, the compilation history along with errors can be found in makefile.log.

If make fails with message

** No image codecs found

that means you don't have image libraries that Prima supports in your path. See the Installation section.

If some of the required libraries or include files can not be found, INC=-I/some/include and LIBS=-L/some/lib semantics should be used to tell Makefile.PL about these. Check ExtUtils::MakeMaker for more.

Binary distribution installation

Available only for MSWin32. Please use the installation from the source for the other platforms.

To install the toolkit from the binary distribution run

perl ms_install.pl

You have to patch Prima::Config.pm manually if you need to compile prima-dependent modules.

Usage examples

Try running the toolkit examples, by default installed in INSTALLSITEARCH/Prima/examples directory ( find it by running perl -V:installsitearch ). All examples and programs included in the distribution can be run either by their name or with perl as argument - for example, ..../helloworld or perl ..../helloworld . ( perl ..../helloworld.bat for win32 )

Typical code starts with

use Prima qw(Application);

and ends with

run Prima;

, the event loop. Start with the following code:

use Prima qw(Application Buttons);

new Prima::MainWindow(
   text     => 'Hello world!',
   size     => [ 200, 200],
)-> insert( Button =>
   centered => 1,
   text     => 'Hello world!',
   onClick  => sub { $::application-> close },
);

run Prima;

Alternatively, start the VB program, the toolkit visual builder.

More information

The toolkit contains a set of POD files describing its features and the programming interfaces. Run the 'podview Prima' or 'perldoc Prima' commands to start with the main manual page.

Visit http://www.prima.eu.org/ for the recent versions of the toolkit. You can use github.com/dk/Prima to keep in touch. See the Prima homepage for details.

Online documentation at MetaCPAN: https://metacpan.org/dist/Prima/view/Prima.pm

Printable documentation: http://prima.eu.org/download/Prima.pdf

Copyright

(c) 1997-2003 The Protein Laboratory, University of Copenhagen

(c) 1997-2024 Dmitry Karasik

Author

Credits

  • Anton Berezin
  • Vadim Belman
  • David Scott
  • Teo Sankaro
  • Kai Fiebach
  • Johannes Blankenstein
  • Mike Castle
  • H.Merijn Brand
  • Richard Morgan
  • Kevin Ryde
  • Chris Marshall
  • Slaven Rezic
  • Waldemar Biernacki
  • Andreas Hernitscheck
  • David Mertens
  • Gabor Szabo
  • Fabio D'Alfonso
  • Rob "Sisyphus"
  • Chris Marshall
  • Reini Urban
  • Nadim Khemir
  • Vikas N Kumar
  • Upasana Shukla
  • Sergey Romanov
  • Mathieu Arnold
  • Petr Pisar
  • Judy Hawkins
  • Myra Nelson
  • Sean Healy
  • Ali Yassen
  • Maximilian Lika
  • kmx
  • Mario Roy
  • Timothy Witham
  • Mohammad S Anwar
  • Jean-Damien Durand
  • Zsban Ambrus
  • Max Maischein
  • Reinier Maliepaard

Thanks to

  • SourceForge for hosting
  • Github for hosting and CI
  • Grammarly for free proofreading service
  • Perltesters for the CI

prima's People

Contributors

dk avatar eserte avatar genio avatar haraldjoerg avatar jddurand avatar jluis avatar manwar avatar mat813 avatar maxperl avatar mohawk2 avatar ppisar avatar reinierma avatar run4flat avatar sergeyromanov avatar siddhesh avatar szabgab avatar twitham1 avatar upasana-me avatar vikasnkumar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prima's Issues

Text editor deletion of empty line is weird

Run the editor example script, typing the contents as shown below. Select the line ghi, including the newline:
selection-pre-delete

Hitting delete, I get this result:
post-delete

Notice that the contents of the line 123 are doubled. This is a true doubling of the contents of that line, the 123 actually appears twice in the text buffer after this operation.

Commenting out this line fixes the problem:

$res .= $self-> get_line( $sel[3] + 1);

I'm sure that logic was put in there for a good reason, but I'm not sure what it is. Also, this is a problem I have experienced since writing App::Prima::REPL, so it's been around for a while. It is not due to the recent Bidi contributions.

Infinite loop due to _get_gui_font_ratio

In the process of figuring out a gui font ratio (_get_gui_font_ratio), line 1288 of Prima::PS::Drawable sets the application font to the requested font. Unfortunately, changing the global font kicks off a series of events which can lead to an infinite loop. The infinite loop occurs, rather unsuspectingly, in Prima::FileDialog::Directory_FontChanged, which tries to pear down the string with fewer and fewer ... abbreviations to accommodate the desired font size. For very large fonts, it's simply not possible to pear down the string to something short enough to fit.

Given that this happens during postscript creation, I highly doubt that changes to the FileDialog were ever expected to happen. :-)

I have two ideas. One, I wonder if there is a better way to query font information other than changing $::application's font. I would guess this works with $::application because it can trust that $::application always exists; would it be possible to create a global, always hidden widget for this purpose instead? Also, would that work if I am trying to build a postscript file without actually invoking the GUI? Two, as a hack, it might be possible to set some sort of $::application::ignore_font_change global, which could be queried by later functions (such as Directory_Fontchanged) so that they ignore the presumably temporary change.

Text editor selection is weird

Text selection gives the wrong result due to incorrect logic in selection_to_physical. I am not sure what the function is trying to achieve, so I am not sure how to fix things.

To reproduce the problem, run the text editor example script (editor.pl). Type abc in the first row and def in the second row. Select from c to d, over the newline (Shift-Down-Left). Copy, then paste into another text editor. I get bc\nde instead of the expected c\nd.

I am running v1.44, but it persists in the latest repository, I believe.

t/Object/Application.t fails on big-endian s390x

I experience a test regression between 1.67 and 1.67001 (also current HEAD 71f6143):

# xvfb-run -d prove -b t/Object/Application.t
t/Object/Application.t .. 1/?
#   Failed test 'one pixel is red'
#   at t/Object/Application.t line 57.

#   Failed test 'another is green'
#   at t/Object/Application.t line 59.
t/Object/Application.t .. 10/? # Looks like you failed 2 tests of 17.
t/Object/Application.t .. Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/17 subtests

Prima::PS::Drawable::get_text_box

Axis rendering in PDL::Graphics::Prima uses the get_text_box method to center the axis labels. This appears to have broken. Given the number of times I've had to re-install Prima throughout the different versions, this might only be an issue on my setup.

To reproduce the problem (or prove that it's a setup thing), install PDL::Graphics::Prima and run any example script. Save the figure to a file by right-clicking on the figure and selecting "Save to postscript" You should see the following output while the postscript figure is being produced:

Twiddling plot; close window or press q or Q to resume
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.
Use of uninitialized value in numeric gt (>) at /Users/dcmertens/projects/Perl/PDL-Graphics-Prima/examples/../blib/lib/PDL/Graphics/Prima/Axis.pm line 822.

Also, the top and bottom axes will be missing.

semistatic and uninitialized memory

Analysing thai usage, I stumpled around uninitialized reads that appear to be a transversal thing. A typical report as per Dr Memory is:

Error #2: UNINITIALIZED READ: reading register ax
# 0 thai.dll!th_brk_wc_find_breaks        [C:\Users\jddfr\git\perlbuildwindows-build\thai-prefix\src\thai\src\thwbrk\thwbrk.c:60]
# 1 Prima.dll!text_get_libthai_breaks     [C:\Users\jddfr\git\perlbuildwindows-build\.cpan\build\Prima-1.67-0\class\Drawable\wrap.c:383]
# 2 Prima.dll!text_init_wrap_rec          [C:\Users\jddfr\git\perlbuildwindows-build\.cpan\build\Prima-1.67-0\class\Drawable\wrap.c:433]
# 3 Prima.dll!string_glyphs_wrap          [C:\Users\jddfr\git\perlbuildwindows-build\.cpan\build\Prima-1.67-0\class\Drawable\wrap.c:1218]
# 4 Prima.dll!Drawable_text_wrap          [C:\Users\jddfr\git\perlbuildwindows-build\.cpan\build\Prima-1.67-0\class\Drawable\wrap.c:1283]
Note: @0:00:20.469 in thread 596
Note: instruction: data16 test   %ax %ax

Error #3: UNINITIALIZED READ: reading register ax
# 0 thai.dll!th_uni2tis_line              [C:\Users\jddfr\git\perlbuildwindows-build\thai-prefix\src\thai\src\thwchar\thwchar.c:207]
# 1 thai.dll!th_brk_wc_find_breaks        [C:\Users\jddfr\git\perlbuildwindows-build\thai-prefix\src\thai\src\thwbrk\thwbrk.c:64]
# 2 Prima.dll!text_get_libthai_breaks     [C:\Users\jddfr\git\perlbuildwindows-build\.cpan\build\Prima-1.67-0\class\Drawable\wrap.c:383]
# 3 Prima.dll!text_init_wrap_rec          [C:\Users\jddfr\git\perlbuildwindows-build\.cpan\build\Prima-1.67-0\class\Drawable\wrap.c:433]
# 4 Prima.dll!string_glyphs_wrap          [C:\Users\jddfr\git\perlbuildwindows-build\.cpan\build\Prima-1.67-0\class\Drawable\wrap.c:1218]
# 5 Prima.dll!Drawable_text_wrap          [C:\Users\jddfr\git\perlbuildwindows-build\.cpan\build\Prima-1.67-0\class\Drawable\wrap.c:1283]
Note: @0:00:20.472 in thread 596
Note: instruction: data16 test   %ax %ax

though it has nothing to do with libthai itself, it has to do with how the internal stack is managed in semistatic.c.

Error about gif support in ActivePerl 5.36

Hi! This is a very old issue that I found years ago, was unable to solve, and I'm facing again after trying to use Prima with a new ActivePerl installation (using the new "ActiveState Platform" version and the "state tool" to install and update modules).

Whenever I use Prima; in a script, I get this error message in the console as the script starts executing:

Failed to load standard bitmap 'c:/Users/sebastian/AppData/Local/activestate/cache/fe8afb71/site/lib/Prima/sys/win32/sysimage.gif':No appropriate codec found. Did you compile Prima with GIF support?

Then, of course, I can't use any gif images in my script.

I tried uninstalling Prima, installing Prima::codecs::win64, and then reinstalling Prima, just in case. But, alas, it didn't work.

I see there are precompiled binaries for other Perls, but not for ActivePerl, so I wonder if there is a way I can get one, or instruct ActiveState, somehow, to build Prima with gif support.

I can't switch to Strawberry Perl for several reasons, one of them being the future of that particular Perl looks dubious (the latest version being 5.32).

Any help will be appreciated!

Feature wish: Spinner widget and indeterminate mode in Prima::Sliders::Gauge

Dear Dimitry,
I have created a little spinner widget similar as in Gtk3 (see GtkSpinner Widget ).
Perhaps this would be a good idea for Prima. There is no progress widget with indeterminate time (I will try to add an indeterminate modus to Prima::Sliders::Gauge but this will last some time).

I noticed some problems:

  1. Why does this not work:
sub init
{
	my $self = shift;
	my %profile = $self-> SUPER::init(@_);

	for (qw( style scaleFactor start_angle end_angle is_active colors))
	{$self-> $_($profile{$_}); }
	
	return %profile;
}

I get the error:

Use of uninitialized value $MySpinner::scale_factor in multiplication (*)

Instead of this I have to do my %profile = $self->SUPER::init(@_); later. I think it is just a problem of understanding in my person..,

  1. If color is passed not as BAREWORD but in single or double quotes I get the following errors:

Argument "cl::Blue" isn't numeric in subroutine entry at ./14_toggle_button.pl line 94.
Argument "cl::White" isn't numeric in subroutine entry at ./14_toggle_button.pl line 117.
and so on....

I am looking forward for your feedback and help.

Best wishes,
Max

PS.: I implemented the Module in a little demo program with a button. Then you can see the Widget in action
14_toggle_button.txt

EXTRA_CCFLAGS might come too early on command-line

To get Prima to find my gif, jpeg, and tiff libraries (in my Macports tree), I had to build the Makefile thusly:

perl Makefile.PL INSTALL_BASE=~/local EXTRA_LDFLAGS=-L/opt/local/lib

and that worked just fine. Before that, I had also added EXTRA_CCFLAGS=-I/opt/local/include. It turns out that was not necessary because that directory was already in the include search path. But when I ran "make" with that EXTRA_CCFLAGS, I got a function prototype mismatch with /opt/local/include/menu.h, which seems to be part of ncurses. This is because the EXTRA_CCFLAGS path was searched before Prima's include/generic/Menu.h.

I don't know if the intention of EXTRA_CCFLAGS is to replace what Prima ships with, or to supplement it. If the latter, then that part of the command-line building might want to be moved further down in the sequence in Makefile.PL's sub cc_command_line. If the former, you could mark this as not-a-bug.

FWIW, this wouldn't be an issue if the OSX file system was case-sensitive, but that's a rant for another day.

Facing Problem Installing prima in UBUNTU Can't locate Prima/sys/Gencls.pm in @inc (you may need to install the Prima::sys::Gencls module)

perl Makefile.PL
Can't locate Prima/sys/Gencls.pm in @inc (you may need to install the Prima::sys::Gencls module) (@inc contains: . /home/a/anaconda3/lib/perl5/5.32/site_perl /home/a/anaconda3/lib/perl5/site_perl /home/a/anaconda3/lib/perl5/5.32/vendor_perl /home/a/anaconda3/lib/perl5/vendor_perl /home/a/anaconda3/lib/perl5/5.32/core_perl /home/a/anaconda3/lib/perl5/core_perl) at Makefile.PL line 20.
BEGIN failed--compilation aborted at Makefile.PL line 20.

Postscript output differs when using subcanvas/paint_with_widgets

I have encountered a discrepancy between the postscript output when using, or not using, subcanvas. Here is an image generated from Prima (as of commit 6d7386e) when painting directly to the postscript subcanvas:
pathological-direct

and here is the output when painted using paint_with_widgets:
pathological-subcanvas

(Note the name "pathological" is because the test itself is a pathological axis scaling test, not a pathological postscript output test.)

The two discrepancies to notice is that (1) the font in the subcanvas output is rasterized and (2) the top, right, and bottom axis ticks and borders are clipped.

Prima fails test on Debian Bullseye

Hi @dk

I am running the github version of Prima from Issue #75 .

I have all the following installed: libgtk-3-dev libgktmm-3.0-dev libheif-dev libwebp-dev libxpm-dev libjpeg-dev libpng-dev libtiff-dev gnuplot

Then I download the Github code, run perl Makefile.PL and make and make test.

The test that fails is t/Widget/Window.t and it says Failed test 'show' and Failed test 'hide'. The window that gets opened does not hide and I think that's the issue.

I have XFCE as my window manager, although I do not think it matters. Any GUI windowing system should work.

Please advise.

Malloc error pointer being freed was not allocated

Hi,

Make test fails for Prima 1.37 with:

PERL_DL_NONLAZY=1 /Users/teslos/perl5/perlbrew/perls/perl-5.16.0/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
Fontconfig warning: ignoring UTF-8: not a valid region tag
Fontconfig warning: ignoring UTF-8: not a valid region tag
Fontconfig warning: ignoring UTF-8: not a valid region tag
perl(33332) malloc: *** error for object 0x7fb944805bf0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
make: *** [test_dynamic] Abort trap: 6

This also happens with Prima 1.36. I think it is problem with Prima.bundle in
Prima/blib/arch/auto/Prima. After running otool -L:

otool -L Prima.bundle 
Prima.bundle:
    /opt/X11/lib/libXpm.4.dylib (compatibility version 16.0.0, current version 16.0.0)
    /usr/local/lib/libpng15.15.dylib (compatibility version 30.0.0, current version 30.0.0)
    /opt/X11/lib/libX11.6.dylib (compatibility version 10.0.0, current version 10.0.0)
    /opt/X11/lib/libXext.6.dylib (compatibility version 11.0.0, current version 11.0.0)
    /usr/local/lib/libfreetype.6.dylib (compatibility version 17.0.0, current version 17.2.0)
    /usr/local/lib/libfontconfig.1.dylib (compatibility version 9.0.0, current version 9.0.0)
    /opt/X11/lib/libXrender.1.dylib (compatibility version 5.0.0, current version 5.0.0)
    /opt/X11/lib/libXft.2.dylib (compatibility version 6.0.0, current version 6.1.0)
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)
    /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1669.0.0)

All libs are installed using the newest homebrew system. My system is:

12.5.0 Darwin Kernel Version 12.5.0: Mon Jul 29 16:33:49 PDT 2013; root:xnu-2050.48.11~1/RELEASE_X86_64 x86_64

and Homebrew version 0.9.5. I have tried to use lldb to find the leak but I get cryptic
message (with breakpoint set to malloc_error_break in .lldbinit):


lldb -- perl -Iblib/arch -Iblib/lib test.pl
Current executable set to 'perl' (x86_64).
(lldb) r
Process 33802 launched: '/Users/teslos/perl5/perlbrew/perls/perl-5.16.0/bin/perl' (x86_64)
Fontconfig warning: ignoring UTF-8: not a valid region tag
Fontconfig warning: ignoring UTF-8: not a valid region tag
Fontconfig warning: ignoring UTF-8: not a valid region tag
perl(33802) malloc: *** error for object 0x1011b0ae0: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Process 33802 stopped
* thread #1: tid = 0x108a6d, 0x00007fff8b138d46 libsystem_kernel.dylib`__kill + 10, queue = 'com.apple.main-thread, stop reason = signal SIGABRT
    frame #0: 0x00007fff8b138d46 libsystem_kernel.dylib`__kill + 10
libsystem_kernel.dylib`__kill + 10:
-> 0x7fff8b138d46:  jae    0x7fff8b138d4d            ; __kill + 17
   0x7fff8b138d48:  jmpq   0x7fff8b13a4d4            ; cerror_nocancel
   0x7fff8b138d4d:  ret    
   0x7fff8b138d4e:  nop    

The malloc error is probably some incompatibility issues with the libraries but I was not able to change the libraries in bundle using install_name_tool due to compatibility version issues.
Interestingly on my older mac with macport I don't have this problem.
Best regards,
∃teslos

Compilation with MSVC >= 2015

Since these versions of MSVC using a macro to define vsnprintf or snprintf is not allowed:

Running Mkbootstrap for Prima ()
        "C:\cl-perl-5.37.5-32bit\bin\perl.exe" -MExtUtils::Command -e chmod -- 644 "Prima.bs"
        "C:\cl-perl-5.37.5-32bit\bin\perl.exe" -MExtUtils::Command::MM -e cp_nonempty -- Prima.bs blib\arch\auto\Prima\Prima.bs 644
        cl -c  -Iinclude -Iinclude/generic -IC:/cl-perl-5.37.5-32bit/c/include/fribidi -IC:/cl-perl-5.37.5-32bit/site/lib/Prima/codecs/win32/include  /openmp  -nologo -GF -W3 -MD -DWIN32 -D_CONSOLE -DNO_STRICT -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -D_WINSOCK_DEPRECATED_NO_WARNINGS -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUSTOMIZE -DMULTIPLICITY -DPERL_IMPLICIT_SYS -O1 -Zi -GL -D_CRT_SECURE_NO_WARNINGS /wd4244 /wd4267 /wd4018    -DVERSION=\"1.66\"  -DXS_VERSION=\"1.66\"  "-IC:\cl-perl-5.37.5-32bit\lib\CORE"   -Fdapi/api.pdb api/api.c -Foapi/api.obj
api.c
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\stdio.h(1422): warning C4005: 'vsnprintf' : redéfinition de macro
C:\Users\jddfr\git\perlbuildwindows-build\.cpan\build\Prima-1.66-0\include\apricot.h(25): note: voir la définition précédente de 'vsnprintf'
C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt\stdio.h(1424): fatal error C1189: #error:  Macro definition of vsnprintf conflicts with Standard Library function declaration
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX86\x86\cl.EXE"' : code retour '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX86\x86\nmake.EXE"' : code retour '0x2'
Stop.

Origin in MSVC's stdio.h:

    #if defined vsnprintf
        // This definition of vsnprintf will generate "warning C4005: 'vsnprintf': macro
        // redefinition" with a subsequent line indicating where the previous definition
        // of vsnprintf was.  This makes it easier to find where vsnprintf was defined.
        #pragma warning(push, 1)
        #pragma warning(1: 4005) // macro redefinition
        #define vsnprintf Do not define vsnprintf as a macro
        #pragma warning(pop)
        #error Macro definition of vsnprintf conflicts with Standard Library function declaration
    #endif
   ...
    #if defined snprintf
        // This definition of snprintf will generate "warning C4005: 'snprintf': macro
        // redefinition" with a subsequent line indicating where the previous definition
        // of snprintf was.  This makes it easier to find where snprintf was defined.
        #pragma warning(push, 1)
        #pragma warning(1: 4005) // macro redefinition
        #define snprintf Do not define snprintf as a macro
        #pragma warning(pop)
        #error Macro definition of snprintf conflicts with Standard Library function declaration
    #endif

Failure of t/Object/Fonts.t on MacOS at Apple Color Emoji font

Hi Dmitry,

I am unable to install Prima from CPAN due a test failure. This does not appear to be a serious failure that should prevent me from force-installing Prima. But it does seem to be the source of most of the Darwin install failures that are reported for recent Perl versions on CPAN Testers. The test failure is of t/Object/Fonts.t for the "Apple Color Emoji" font, and it looks like the following. I'm not too familiar with Prima, but am happy to help debug. I am running perl 5.26.2 on MacOS 10.12.6 (Sierra). perl -V follows the test output.

ok 2339 - height / Copperplate
ok 2340 - size / Copperplate
ok 2341 - direction / Copperplate
ok 2342 - width by height / Copperplate
ok 2343 - width by size / Copperplate
ok 2344 - style / Copperplate
ok 2345 - text wrap Copperplate
ok 2346 - height / Apple Color Emoji
not ok 2347 - size / Apple Color Emoji
#   Failed test 'size / Apple Color Emoji'
#   at t/Object/Fonts.t line 33.
#          got: '15'
#     expected: '12'
ok 2348 - direction / Apple Color Emoji
not ok 2349 - width by height / Apple Color Emoji
#   Failed test 'width by height / Apple Color Emoji'
#   at t/Object/Fonts.t line 51.
#          got: '18'
#     expected: '15'
ok 2350 - width by size / Apple Color Emoji
ok 2351 - style / Apple Color Emoji
ok 2352 # skip text wrap Apple Color Emoji
xft: want 20x0.0.fixed.Apple Color Emoji/fontspecific^0
xft: want 72x0.0.fixed.Apple Color Emoji/fontspecific^0
xft: want 20x0.0.fixed.Apple Color Emoji/fontspecific^0
ok 2353 - height / Apple Color Emoji
xft: want -48x0.0.fixed.Apple Color Emoji/fontspecific^0
xft: want -12x0.0.fixed.Apple Color Emoji/fontspecific^0
not ok 2354 - size / Apple Color Emoji
#   Failed test 'size / Apple Color Emoji'
#   at t/Object/Fonts.t line 33.
#          got: '15'
#     expected: '12'
xft: want 20x0.0.default.Apple Color Emoji/fontspecific^12
xft: want 20x0.0.default.Apple Color Emoji/fontspecific^0
ok 2355 - direction / Apple Color Emoji
xft: want 20x0.0.fixed.Apple Color Emoji/fontspecific^0
xft: want 20x57.0.default.Apple Color Emoji/fontspecific^0
xft: want 20x15.0.default.Apple Color Emoji/fontspecific^0
not ok 2356 - width by height / Apple Color Emoji
#   Failed test 'width by height / Apple Color Emoji'
#   at t/Object/Fonts.t line 51.
#          got: '18'
#     expected: '15'
xft: want -15x0.0.fixed.Apple Color Emoji/fontspecific^0
xft: want -15x69.0.default.Apple Color Emoji/fontspecific^0
xft: want -15x19.0.default.Apple Color Emoji/fontspecific^0
ok 2357 - width by size / Apple Color Emoji
xft: want 26x0.BTI.default.Apple Color Emoji/fontspecific^0
xft: want 26x0.0.default.Apple Color Emoji/fontspecific^0
ok 2358 - style / Apple Color Emoji
xft: want 16x0.0.fixed.Apple Color Emoji/fontspecific^0
ok 2359 # skip text wrap Apple Color Emoji
ok 2360 - height / FreeSerif
ok 2361 - size / FreeSerif
ok 2362 - direction / FreeSerif
ok 2363 - width by height / FreeSerif
ok 2364 - width by size / FreeSerif
ok 2365 - style / FreeSerif
ok 2366 - text wrap FreeSerif
$ perl -V
Summary of my perl5 (revision 5 version 26 subversion 2) configuration:
   
  Platform:
    osname=darwin
    osvers=16.7.0
    archname=darwin-thread-multi-2level
    uname='darwin sierra.internal.macports.net 16.7.0 darwin kernel version 16.7.0: tue jan 30 11:27:06 pst 2018; root:xnu-3789.73.11~1release_x86_64 x86_64 '
    config_args='-des -Dprefix=/opt/local -Dscriptdir=/opt/local/bin -Dvendorprefix=/opt/local -Dusemultiplicity=y -Dusethreads -Duseshrplib -Dcc=/usr/bin/clang -Dman1ext=1pm -Dman3ext=3pm -Dinstallstyle=lib/perl5 -Dman1dir=/opt/local/share/man/man1p -Dman3dir=/opt/local/share/man/man3p -Dsitebin=/opt/local/libexec/perl5.26/sitebin -Dsiteman1dir=/opt/local/share/perl5.26/siteman/man1 -Dsiteman3dir=/opt/local/share/perl5.26/siteman/man3 -Dvendorbin=/opt/local/libexec/perl5.26 -Dvendorman1dir=/opt/local/share/perl5.26/man/man1 -Dvendorman3dir=/opt/local/share/perl5.26/man/man3 -Dpager=/usr/bin/less -sR -Dperlpath=/opt/local/bin/perl5.26 -Dstartperl=#!/opt/local/bin/perl5.26 -Acppflags=-I/opt/local/include -Accflags=-pipe -Os  -Alddlflags=-L/opt/local/lib -Wl,-headerpad_max_install_names  -Aldflags=-L/opt/local/lib -Wl,-headerpad_max_install_names '
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='/usr/bin/clang'
    ccflags ='-fno-common -DPERL_DARWIN -mmacosx-version-min=10.12 -pipe -Os  -fno-strict-aliasing -fstack-protector-strong -I/opt/local/include -DPERL_USE_SAFE_PUTENV'
    optimize='-O3'
    cppflags='-I/opt/local/include -fno-common -DPERL_DARWIN -mmacosx-version-min=10.12 -pipe -Os  -fno-strict-aliasing -fstack-protector-strong -I/opt/local/include'
    ccversion=''
    gccversion='4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='/usr/bin/clang'
    ldflags =' -mmacosx-version-min=10.12 -L/opt/local/lib -Wl,-headerpad_max_install_names  -fstack-protector-strong'
    libpth=/opt/local/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib /usr/lib
    libs=-lpthread -lgdbm -ldbm -ldl -lm -lutil -lc
    perllibs=-lpthread -ldl -lm -lutil -lc
    libc=
    so=dylib
    useshrplib=true
    libperl=libperl.dylib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -mmacosx-version-min=10.12 -bundle -undefined dynamic_lookup -L/opt/local/lib -Wl,-headerpad_max_install_names  -fstack-protector-strong'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_IMPLICIT_CONTEXT
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
    USE_REENTRANT_API
  Built under darwin
  Compiled at Apr 23 2018 05:20:45
  %ENV:
    PERL5LIB="/Users/derek/local/lib/perl5"
  @INC:
    /Users/derek/local/lib/perl5/darwin-thread-multi-2level
    /Users/derek/local/lib/perl5
    /opt/local/lib/perl5/site_perl/5.26/darwin-thread-multi-2level
    /opt/local/lib/perl5/site_perl/5.26
    /opt/local/lib/perl5/vendor_perl/5.26/darwin-thread-multi-2level
    /opt/local/lib/perl5/vendor_perl/5.26
    /opt/local/lib/perl5/5.26/darwin-thread-multi-2level
    /opt/local/lib/perl5/5.26

podview Ctrl-+ doesn't work with [+=] key

With Prima 1.45 on both Strawberry Perl and cygwin perl, holding the Ctrl key and then the [+=] key does not increase the font size. Ctrl + Shift + [+=] doesn't work either. The only thing that works is to use the + from the number pad area.

t/Image/Transform.t aborts on memmove() in img_2d_transform() if compiled with -D_FORTIFY_SOURCE=3 and glibc-2.36.9000

When building Prima with -D_FORTIFY_SOURCE=3:

$ perl Makefile.PL OPTIMIZE='-Wp,-D_FORTIFY_SOURCE=3 -g -O2'

t/Image/Transform.t test aborts:

$ perl -Iblib/{lib,arch} t/Image/Transform.t
ok 1 - rotate(90) width ok
ok 2 - rotate(90) height ok
ok 3 - rotate(90) data ok
ok 4 - rotate(270) width ok
ok 5 - rotate(270) height ok
ok 6 - rotate(270) data ok
ok 7 - rotate(180) width ok
ok 8 - rotate(180) height ok
ok 9 - rotate(180) data ok
ok 10 - short: rotate(90) data ok
ok 11 - short: rotate(270) data ok
ok 12 - short: rotate(180) data ok
ok 13 - byte: vertical mirroring ok
ok 14 - byte: horizontal mirroring ok
ok 15 - short: vertical mirroring ok
ok 16 - short: horizontal mirroring ok
ok 17 - rotation 360 seems performing
ok 18 - rotation 360 is correct
ok 19 - rotation 360 by transform2d seems performing
ok 20 - rotation 360 transform2d is correct
ok 21 - xshear(2) integral data
ok 22 - xshear(2) integral mask
*** buffer overflow detected ***: terminated
Aborted (core dumped)

This can be reduced to:

$ cat /tmp/test.t 
#!/usr/bin/perl
use Prima::sys::Test qw(noX11);
my $p = Prima::Image->create(
        width    => 2,
        height   => 2,
        type     => im::Byte,
        data     => "\1\4..\3\6");
$p->shear(0,0.5);
$ perl -Iblib/{lib,arch} /tmp/test.t 
*** buffer overflow detected ***: terminated
Aborted (core dumped)

Valgrind reports:

$ valgrind -- perl -Iblib/{lib,arch} /tmp/test.t 
==50828== Memcheck, a memory error detector
==50828== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==50828== Using Valgrind-3.20.0 and LibVEX; rerun with -h for copyright info
==50828== Command: perl -Iblib/lib -Iblib/arch /tmp/test.t
==50828== 
==50828== Source and destination overlap in memcpy_chk(0x1ffeffd574, 0x1ffeffd580, 24)
==50828==    at 0x484C332: __memcpy_chk (vg_replace_strmem.c:1741)
==50828==    by 0x572FF3D: UnknownInlinedFun (string_fortified.h:36)
==50828==    by 0x572FF3D: img_2d_transform (rotate.c:1171)
==50828==    by 0x56DC6F1: Image_matrix_transform (conv.c:943)
==50828==    by 0x56D9BC4: Image_transform (conv.c:992)
==50828==    by 0x566FDA0: template_xs_Bool_Handle_HVPtr (thunks.tinc:3788)
==50828==    by 0x497BECF: Perl_pp_entersub (pp_hot.c:5352)
==50828==    by 0x496D84F: Perl_runops_standard (run.c:41)
==50828==    by 0x48DDFA0: UnknownInlinedFun (perl.c:2721)
==50828==    by 0x48DDFA0: perl_run (perl.c:2644)
==50828==    by 0x109349: main (perlmain.c:110)
==50828== 
**50828** *** memcpy_chk: buffer overflow detected ***: program terminated
==50828==    at 0x48470AC: VALGRIND_PRINTF_BACKTRACE (valgrind.h:6815)
==50828==    by 0x484C3BC: __memcpy_chk (vg_replace_strmem.c:1741)
==50828==    by 0x572FF3D: UnknownInlinedFun (string_fortified.h:36)
==50828==    by 0x572FF3D: img_2d_transform (rotate.c:1171)
==50828==    by 0x56DC6F1: Image_matrix_transform (conv.c:943)
==50828==    by 0x56D9BC4: Image_transform (conv.c:992)
==50828==    by 0x566FDA0: template_xs_Bool_Handle_HVPtr (thunks.tinc:3788)
==50828==    by 0x497BECF: Perl_pp_entersub (pp_hot.c:5352)
==50828==    by 0x496D84F: Perl_runops_standard (run.c:41)
==50828==    by 0x48DDFA0: UnknownInlinedFun (perl.c:2721)
==50828==    by 0x48DDFA0: perl_run (perl.c:2644)
==50828==    by 0x109349: main (perlmain.c:110)
==50828== 

It is this code:

    SKIP:
        if ( step < iop.n_steps - 1)
→           memmove( io, io + 1, (iop.n_steps - step - 1) * sizeof(ImgOp) );
        iop.n_steps--;
        step--;
        io--; 
    }

This happens both with Prima-1.67 as well as with current head (8a0c8bc).

memove() is requires that source and target memory areas cannot overlap. Modern glibc scrutinizes the calls if a program is compiled with -D_FORTIFY_SOURCE=3 -O2 cflags and aborts the program when it detects overlapping memory areas.

Please note that I have not yet verified that this is a genuine bug in Prima and not a bug in glibc.

undefined symbol: DGifOpen in Mageia

Hello,

Unter Mageia Linux 5.1 I get the following error, when trying the examples (fonntdlg.pl, keys.pl, label.pl):

perl: symbol lookup error: /usr/lib/perl5/vendor_perl/5.20.1/x86_64-linux-thread-multi/auto/Prima/Prima.so: undefined symbol: DGifOpen

The problem occurs with the Prima version of Mageia, the newest CPAN version and the actual github branch.

Best wishes,
Max

POE::Loop::Prima, Prima and Signal handling

Hi @dk
I want to capture signals like SEGV, INT and QUIT in my GUI that I built almost 9 years go using Prima. I am porting the GUI to the latest Prima 1.67 version and need to be able to trap SEGV, and maybe other signals, to prevent the UI from crashing outright. Maybe it can also dump a call-stack somehow ?

The issue I am facing is that one of my child windows that uses Prima::Edit is segfaulting when I try to expand the menu, causing the whole application to crash and I need to figure out what is happening.

Is there a debug flag that can be set within Prima to see some more deeper low level details ? Would love some advice here.

For reference, the code which used to work with Prima 1.44 is here.

Compilation error on older Debian systems

On older Debian systems (e.g. jessie) Prima does not compile anymore:

...
cc -c  -Iinclude -Iinclude/generic -I/usr/include/freetype2 -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixma
n-1 -I/usr/include/libpng12 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng12 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/x86_64-linux-gnu  -fopenmp
 -fPIC -D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -O2 -Wall   -DVERSION=\"1.53\" -DXS_VERSION=\"1.53\" -fPIC "-I/opt/perl-5.29.4t/lib/5.29
.4/x86_64-linux-thread-multi/CORE"   img/codec_gif.c -o img/codec_gif.o
img/codec_gif.c: In function 'init':
img/codec_gif.c:109:39: error: 'vd' undeclared (first use in this function)
  sscanf( GIF_LIB_VERSION, "%s %d.%d", vd, &codec_info.versionMaj, &codec_info.versionMin);
                                       ^
img/codec_gif.c:109:39: note: each undeclared identifier is reported only once for each function it appears in
Makefile:765: recipe for target 'img/codec_gif.o' failed
make: *** [img/codec_gif.o] Error 1

fixing the examples

use strict, use warnings, make the pods work and add links to the modules they show.

podview window opens too wide on dual monitors

I have a dual monitor setup and the initial window size selected running "podview Prima" or whatever always spans 1 1/2 monitors in width. This blocks my other windows and is wasteful since about 1/2 the width of either monitor by itself is more than sufficient to display the POD documentation.

Is there a way to control the window size (I didn't find one searching the manual)? Is there a reason that the default cannot be "smarter" by setting an upper bound on the width of the text displayed?

t/Object/Shaping.t fails with Unifont font and harfbuzz ≥ 4.4.0

After installing Unifont 14.0.01 (I know, it's not the latest version), t/Object/Shaping.t fails like this:

not ok 104 - (--no-fribidi)  - arabic ligation (glyphs) {/|}
#   Failed test '(--no-fribidi)  - arabic ligation (glyphs) {/|}'
#   at t/Object/Shaping.t line 651.
#   Failed test 'arabic ligation (glyphs) {/|}'
#   at t/Object/Shaping.t line 79.
# got [dd91 db42], expected [ddfe] font=Unifont
[...]
1..416
# Looks like you failed 14 tests of 416.

There many more failed tests:

Test Summary Report
-------------------
t/Object/Shaping.t (Wstat: 3584 (exited 14) Tests: 416 Failed: 14)
  Failed tests:  29-30, 67-71, 104-105, 132-136
  Non-zero exit status: 14

When I uninstall that font, the test run reports less, 371, tests. All passing.

I guess that Unifont does not support all features required by the test, but provides enough glyphs not to skip the tests.

Would it it be possible, for the sake of the test, to recommend a font which supports the tested features and change the test to use that font instead of one which blindly returns the operating system (e.g. fontconfig on Linux)?

Prima Cairo backend

Dear Dimtry,

I am trying to implement Cairo backend for PDL::Graphics::Prima library.
Current implementation of Prima::Cairo::Drawable is on my repo:
https://github.com/Teslos/Prima/blob/master/Prima/Cairo/Drawable.pm
I started with the Prima::PS::Drawable and used Cairo library to implement some of functionality of PS::Drawable.
I have several questions concerning the implementation:
1.) I am not really sure how to implement the font capabilities of Prima in Cairo.
Currently, most of the fonts functionality is copied from PS::Drawable so I think it would
be better to eliminate the code duplication by subclassing the PS::Drawable in some way...
2.) How to test the code to get same results as PS::Drawable? I think that standard
Test::More etc.. can't guaranty pixel for pixel testing of the Canvas surface.
3.) I think it is also easy to add Cairo backend for rendering the widgets in PDL::Graphics::Prima. The small example of
analog clock implemented with Gtk and Cairo is here:
https://github.com/Teslos/Cairo-Perl/blob/master/analog_clock.pl
But I don't know how to implement that in Prima, maybe you have some suggestions.

Thank you very much for your help!

Best regards,
∃t.

Build fails on Windows 10

#   Failed test 'send'
#   at t/Widget/Mouse.t line 35.

#   Failed test 'post'
#   at t/Widget/Mouse.t line 43.

#   Failed test 'click'
#   at t/Widget/Mouse.t line 57.

#   Failed test 'doubleclick'
#   at t/Widget/Mouse.t line 63.

#   Failed test 'simulated movement'
#   at t/Widget/Mouse.t line 84.

GUI font ratio doesn't work right for large fonts

Summary

There appears to be an error in the calculation of gui font scaling for GUI -> Postscript font that manifests itself for larger fonts. Basically, the postscript font with is far, far too small for big fonts. Even when using a Postscript font (Helvetica), there are also subtle discrepancies in the placement of individual characters. The spacing between the two o characters is wider on the Postscript than it is on the Window.

Additionally, it seems that a canvas size scaling factor of 65.25 / 100 gives identical postscript dimensions, not 72.27 / 100. This may simply be over-tweaking on my part, or it may have to do with what my screen thinks an inch is. Is there a way in Prima for me to query the number of pixels in an inch so that I can correctly set the canvas size?

Usage

The following script demonstrates the problem. You can modify the behavior of the script by calling it with various arguments.

  • \d+ gives the size of the window you want to produce. The font size is scaled to be 1/3 the window size. This makes it easy to try different font sizes.
  • subcanvas causes the script to use paint_with_widgets; default behavior just passes the postscript canvas to the window's paint notification
  • helvetica causes the window to use the Helvetica font, side-stepping the GUI -> Postscrip font conversion issue. There are still subtle differences in the placement of the font elements

For example, to call the script with a 500x500 window that uses gui fonts and subcanvas, you would say perl postscript-subcanvas-test.pl 500 subcanvas.

Script

use strict;
use warnings;
use Prima qw(Application);
use Prima::PS::Drawable;
use Prima::Drawable::Subcanvas;

################
# Process Args #
################
# Make subcanvas drawing contingent on an argument 'subcanvas'
my $subcanvas = grep /subcanvas/i, @ARGV;
# Let the user specify a window size
my ($size) = grep /^\d+$/, @ARGV;
$size ||= 50;
# Let the user specify to use Helvetica or the default
my $use_helvetica = grep /helvetica/i, @ARGV;

###################
# File management #
###################
# Build a file name and remove an pre-existing file by the same name
my $base_filename = 'font-dimensions';
$base_filename .= '-helvetica' if $use_helvetica;
$base_filename .= '-subcanvas' if $subcanvas;
$base_filename .= '.eps';
unlink $base_filename;

###############
# Diagnostics #
###############
# Monkey patch text_out to get an idea of the factors effecting font drawing
my $old_text_out = \&Prima::PS::Drawable::text_out;
*Prima::PS::Drawable::text_out = sub {
    my $self = $_[0];
    print "Just before text out operation, font width is $self->{font}{width}, and font width divisor is $self->{fontWidthDivisor}\n";
    goto &$old_text_out;
};

########################
# Build the GUI window #
########################
my $window = Prima::MainWindow->new(
    size => [$size, $size],
    onPaint => sub {
        my ($self, $canvas) = @_;
        $canvas->text_out('foo', $size/5, $size/5);
    },
    font => {
        ($use_helvetica ? (name => 'Helvetica') : ()),
        size => $size/3,
    },
);

########################
# Build the eps canvas #
########################
my $scaling_ratio = 65.25 / 100;
my $width = $window->width * $scaling_ratio;
my $height = $window->height * $scaling_ratio;
my $ps = Prima::PS::Drawable-> create( onSpool => sub {
        open my $fh, ">>", $base_filename;
        print $fh $_[1];
        close $fh;
    },
    pageSize => [$width, $height],
    pageMargins => [0, 0, 0, 0],
    isEPS => 1,
    useDeviceFontsOnly => 1,
);
$ps->resolution($window->resolution);
$ps->font(height => $window->font->height);
$ps->begin_doc or die "Error generating Postscript output: $@";

########################
# Paint the postscript #
########################
if ($subcanvas) {
    $window->paint_with_widgets($ps);
}
else {
    $window->push_event;
    $window->begin_paint_info;
    $window->notify('Paint', $ps);
    $window->end_paint_info;
    $window->pop_event;

}

$ps->end_doc;

##################################
# Show the window for comparison #
##################################
run Prima;

multiple failures in t/Image/Bitmap.t

At the current HEAD dc0eb83, I am getting multiple failures in t/Image/Bitmap.t. At version 1.47 these failures are not present. Specifically, make test gives:

t/Image/Bitmaps.t ....... 1/886 panic: no argb visual at /Users/derek/Build/Prima/blib/lib/Prima/Classes.pm line 367.
panic: no argb visual at /Users/derek/Build/Prima/blib/lib/Prima/Classes.pm line 367.

#   Failed test 'put 1-bit grayscale image / 8-bit alpha on pixmap'
#   at t/Image/Bitmaps.t line 70.

#   Failed test '1-bit grayscale image / 8-bit alpha on pixmap (1 & 0 ^ 0 == 1)'
#   at t/Image/Bitmaps.t line 29.
#          got: '0'
#     expected: '16777215'

and so on until:

Test Summary Report
-------------------
t/Image/Bitmaps.t     (Wstat: 25600 Tests: 850 Failed: 100)
  Failed tests:  222, 225-227, 230-231, 234-236, 239-240
                243-245, 248-249, 252-254, 257-258, 261-263
                266, 470, 473-475, 478-479, 482-484, 487-488
                491-493, 496-497, 500-502, 505-506, 509-511
                514, 594, 597-599, 602-603, 606-608, 611-612
                615-617, 620-621, 624-626, 629-630, 633-635
                638, 718, 721-723, 726-727, 730-732, 735-736
                739-741, 744-745, 748-750, 753-754, 757-759
                762
  Non-zero exit status: 100
  Parse errors: Bad plan.  You planned 886 tests but ran 850.

My platform is Mac OSX Yosemite, Perl 5.22.1 from MacPorts. perl -V attached.
perl-V.txt

Prima eats options in @ARGV

This feels weird. The attached test fails as soon as the use Prima; statement is active. It passes when use Prima; is commented out. There seems to be a conflict between Getopt::Long and Prima, as Getopt::Long does not see all contents of @argv if Prima is loaded before it. For example the --help command gets eaten by Prima and it outputs:

   --openmp_threads - sets number of openmp threads
   --debug      - turns on debugging

which is unexpected

Prima-GetOptions.t.txt

Prima fails to build at least on GitHub Actions under PDL CI

Not sure if you can read this log, unfortunately it's not in any case very verbose: https://github.com/PDLPorters/pdl/runs/5957121872?check_suite_focus=true

Extract (it did used to work, and I note you've just pushed out a new release) - sorry, the referred build.log is not available:

[...]
strict is up to date. (1.12)
! Installing Prima failed. See /root/.cpanm/work/1649537624.25/build.log for details. Retry with --force to force install it.
! Installing the dependencies failed: Module 'Prima' is not installed
! Bailing out the installation for PDL-Drawing-Prima-0.14.
The command '/bin/sh -c if [ -n "$START_XVFB" ]; then Xvfb $DISPLAY & sleep 5; fi; 	cpanm -nq $CPANM_CONFIGURE_DEPS 		&& cpanm -nq --installdeps --dev $CPANM_ARGS 		&& cpanm --verbose --dev $CPANM_ARGS' returned a non-zero code: 1
Could not build PDL-Drawing-Prima at /home/runner/work/pdl/pdl/.github/devops/docker/lib/PDL/Devops/Process/Docker.pm line 20.
make: Leaving directory '/home/runner/work/pdl/pdl/.github/devops/docker'

grey noise when using pack gm in $frameset->insert_to_frame

Dear Dimitry,
Sorry for posting so much bug reports, but I noticed again a little problem in Linux and Windows.

The following frameset code causes grey noise in Windows and Linux. After Resizing the main window the labels and framesets are shown correctely:


use Prima;
use Prima::Application;
use Prima::Label;
use Prima::IntUtils;
use Prima::FrameSet;

# Füge dem Program ein Icon hinzu
#my $icon = Prima::Icon->load('camel.png');
#$::application->icon($icon);

# Erstelle das HauptFenster
my $mw = Prima::MainWindow->new(
		size => [300, 200],
		text => 'Grid example');

my $fs = Prima::FrameSet->create(
	owner => $mw,
	size => [300, 200],
	arrangement => fra::Vertical,
	frameSizes => [("50%", "50%")],
	pack => {expand => 1, fill => both}
);

my $label = $fs->insert_to_frame(
	1,
	Label,
	text => 'This is top',
	pack => {expand => 1, fill => both}
	
);

my $label2 = $fs->insert_to_frame(
	0,
	Label,
	text => 'This is bottom',
	pack => {expand => 1, fill => both}
);

run Prima;

Furthermore when frameSize in the Prima::Frameset->create method is not set, I get the following error:

Can't use an undefined value as an ARRAY reference at /usr/local/lib/x86_64-linux-gnu/perl/5.22.2/Prima/FrameSet.pm line 409.

But perhaps this is normal?

Trouble with libjpeg on Mac

I seem to vaguely recall this being a problem in the past, but then I thought it was squashed. At any rate, I get the following error when compiling the latest git on Perl 5.18 on a Mac OS X Lion that has libjpeg.

PERL_DL_NONLAZY=1 /Users/dcmertens/perl5/perlbrew/perls/perl-5.18.1-thread-multi/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
Can't load 'blib/arch/auto/Prima/Prima.bundle' for module Prima: dlopen(blib/arch/auto/Prima/Prima.bundle, 2): Symbol not found: _jpeg_resync_to_restart
  Referenced from: /Users/dcmertens/projects/Perl/Prima/blib/arch/auto/Prima/Prima.bundle
  Expected in: dynamic lookup
 at test/Tester.pl line 34.
Compilation failed in require at test/Tester.pl line 34.`

VB problem on Strawberry Perl 5.20.0

Hi,
I successfully installed Prima 1.39 on Strawberry Perl 5.20.0 32bit/64bit.
but when i select General, Additional, Sliders, Abstract tabs, it doesn't change sub available component list.

Leak at exit

Minor bug, but may be good to investigate, observed doing perl -I blib\lib -I blib\arch t\Object\TextWrap.t :

Error #2: POSSIBLE LEAK 200 direct bytes 0x08001a00-0x08001ac8 + 0 indirect bytes
# 0 replace_RtlAllocateHeap                [d:\a\drmemory\drmemory\common\alloc_replace.c:3772]
# 1 gdi32full.dll!CreateFontIndirectExW   +0xd9     (0x7615fcea <gdi32full.dll+0x4fcea>)
# 2 gdi32full.dll!CreateFontIndirectA     +0x48     (0x76145e19 <gdi32full.dll+0x35e19>)
# 3 GDI32.dll!CreateFontIndirectA         +0x1e     (0x75c24d0f <GDI32.dll+0x4d0f>)
# 4 Prima.dll!window_subsystem_init        [C:\Users\jddfr\git\Prima\win32\global.c:286]
# 5 Prima.dll!Prima_init                   [C:\Users\jddfr\git\Prima\api\boot.c:130]
# 6 perl537.dll!Perl_pp_entersub           [C:\Users\jddfr\git\perlbuildwindows-build\perl-core-prefix\src\perl-core\pp_hot.c:5457]
# 7 perl537.dll!Perl_runops_standard       [C:\Users\jddfr\git\perlbuildwindows-build\perl-core-prefix\src\perl-core\run.c:41]
# 8 perl537.dll!Perl_call_sv               [C:\Users\jddfr\git\perlbuildwindows-build\perl-core-prefix\src\perl-core\win32\perl.c:3148]
# 9 perl537.dll!Perl_call_sv               [C:\Users\jddfr\git\perlbuildwindows-build\perl-core-prefix\src\perl-core\win32\perl.c:3143]
#10 perl537.dll!Perl_call_list             [C:\Users\jddfr\git\perlbuildwindows-build\perl-core-prefix\src\perl-core\win32\perl.c:5222]
#11 perl537.dll!S_process_special_blocks   [C:\Users\jddfr\git\perlbuildwindows-build\perl-core-prefix\src\perl-core\win32\op.c:10860]

SEGV from PDL::Graphics::Simple Prima tests with backtrace

I installed CPAN-latest PDL::Drawing::Prima and PDL::Graphics::Prima. I built and installed git-latest Prima with debugging symbols (by adding -g to the OPTIMIZE = line in the generated Makefile), then ran this in a checkout of PDL::Graphics::Simple:

$ perl Makefile.PL; make
$ AUTOMATED_TESTING=1 gdb perl -ex 'run -Mblib t/simple.t'
[snip]
ok 62 - PDL::Graphics::Simple::Prima::check() ran OK

Thread 1 "perl" received signal SIGSEGV, Segmentation fault.
___pthread_mutex_lock (mutex=0x0) at ./nptl/pthread_mutex_lock.c:80
80	./nptl/pthread_mutex_lock.c: No such file or directory.
(gdb) bt
#0  ___pthread_mutex_lock (mutex=0x0) at ./nptl/pthread_mutex_lock.c:80
#1  0x00007ffff6afc50f in XrmQGetResource ()
    at /lib/x86_64-linux-gnu/libX11.so.6
#2  0x00007ffff62d570e in apc_fetch_resource
    (className=<optimised out>, name=name@entry=0x5555598cbc00 "window1", resClass=resClass@entry=0x5555598796f0 "Foreground", res=res@entry=0x555559911db0 "color", owner=owner@entry=93825028420368, resType=resType@entry=1, result=0x7fffffffcf94) at unix/misc.c:165
#3  0x00007ffff622ce54 in Widget_fetch_resource
    (className=<optimised out>, name=<optimised out>, classRes=<optimised out>, res=<optimised out>, owner=owner@entry=93825028420368, resType=resType@entry=1)
    at class/Widget.c:476
#4  0x00007ffff622d0c0 in Widget_fetch_resource_FROMPERL (cv=<optimised out>)
    at include/generic/Widget.inc:397
#5  0x000055555565bfca in Perl_pp_entersub ()
#6  0x0000555555651df3 in Perl_runops_standard ()
#7  0x00005555555c1c5f in Perl_call_sv ()
#8  0x00007ffff61fba1c in clean_perl_call_pv
    (subname=subname@entry=0x7ffff62fa5de "Prima::Object::profile_add", flags=flags@entry=4) at api/perl.c:39
#9  0x00007ffff61e1ccd in template_imp_void_Handle_SVPtr
    (subName=0x7ffff62fa5de "Prima::Object::profile_add", self=93825060130016, profile=0x55555985b680) at include/generic/thunks.tinc:150
#10 0x00007ffff622042b in Object_create
    (className=<optimised out>, profile=profile@entry=0x555559866490)
    at class/Object.c:42
#11 0x00007ffff61d511b in create_from_Perl (cv=<optimised out>) at api/api.c:78
#12 0x000055555565bfca in Perl_pp_entersub ()
#13 0x0000555555651df3 in Perl_runops_standard ()
#14 0x00005555555c9c05 in perl_run ()
#15 0x00005555555a11ea in main ()
(gdb) frame 2
#2  0x00007ffff62d570e in apc_fetch_resource (className=<optimised out>, 
    name=name@entry=0x5555598cbc00 "window1", 
    resClass=resClass@entry=0x5555598796f0 "Foreground", 
    res=res@entry=0x555559911db0 "color", owner=owner@entry=93825028420368, 
    resType=resType@entry=1, result=0x7fffffffcf94) at unix/misc.c:165
165		if ( XrmQGetResource( guts.db,
(gdb) print guts.db
$8 = (XrmDatabase) 0x5555573f6730
(gdb) list
160				_debug( "%s ", XrmQuarkToString( classes[i]));
161			}
162			_debug( "\n");
163		}
164	
165		if ( XrmQGetResource( guts.db,
166					instances,
167					classes,
168					&type, &value)) {
169			if ( type == guts.qString) {

The actual SEGV almost certainly comes from this call: https://github.com/freedesktop/xorg-lib-libX11/blob/master/src/Xrm.c#L2549 but it's not clear to me at all why &db->linfo would be 0x0 as gdb shows it. Perhaps some cleanup is being done assuming some initialisation was done, but the initialisation wasn't in fact done.

Support for EPS output?

PDL::Graphics::Prima produces figures using the PS drawable interface. Most viewers incorrectly render the figures. Some experimentation on my part seems to suggest that changing the opening line of the file from

%!PS-Adobe-2.0

to

%!PS-Adobe-3.0 EPSF-3.0

is sufficient. By sufficient, I mean that the files are correctly rendered by Mac's Preview, LyX's in-document preview, and many LaTeX renders such as dvips and pdflatex (as run on a Mac). Historically, I have had to monkey with the figure bounding box to get things to display correctly, but I recently discovered (in my tests of Prima::Drawable::Subcanvas) that images larger than a page size were not being properly displayed even with my attempted fixes.

Multiple discrepancies between Subcanvas wrapped vs non-Subcanvas wrapped in postscript output

I have been looking into font setting issues and have come across a few discrepancies in font widths and positioning for postscript rendered under Subcanvas vs not under Subcanvas. This script reproduces the discrepancies. It also monkey-patches some Prima::PS::Drawable methods to print diagnostic output. The patch to emit gives a stack trace when it sees a zoom that's not simply 1 1 Z. The patch to text_out prints the font width and fontWidthDivisor just before performing the text_out, and indicates if the canvas being drawn things it has textOutBaseline set to true.

In short

  • Postscript drawables seem to have a true textOutBaseline, which disagrees with the documentation in Prima::Drawable (and is not mentioned in Prima::PS::Drawable). I don't mind adapting to this, but it should probably be documented.
  • Font configuration by Subcanvas seems to mess up the width of the font.

There are other interesting discrepancies, such as an additional font encoding in the Subcanvas produced output, and the use of Helvetica-Narrow by the non-Subcanvas vs Helvetica by the Subcanvas. I think those are optimizations, however, and are not major concerns of mine for this issue.

use strict;
use warnings;
use Prima qw(Application);
use Prima::PS::Drawable;
use Prima::Drawable::Subcanvas;
use Carp qw(cluck);

my $old_emit = \&Prima::PS::Drawable::emit;
*Prima::PS::Drawable::emit = sub {
    my $to_print = $_[1];
    cluck() if $to_print =~ /0.\d+ 1 Z/;
    goto &$old_emit;
};

my $old_text_out = \&Prima::PS::Drawable::text_out;
*Prima::PS::Drawable::text_out = sub {
    my $self = $_[0];
    print "Just before text out operation, font width is $self->{font}{width}, and font width divisor is $self->{fontWidthDivisor}\n";
    print "baseline is true\n" if $self-> textOutBaseline;
    goto &$old_text_out;
};

my $subcanvas = grep { /subcanvas/i } @ARGV;
my $base_filename = 'font-dimensions';
$base_filename .= '-subcanvas' if $subcanvas;
$base_filename .= '.eps';

my $window = Prima::MainWindow->new(
    size => [50, 50],
    onPaint => sub {
        my ($self, $canvas) = @_;
        $canvas->text_out('foo', 10, 10);
    },
);

my $scaling_ratio = 72.27 / 100;
my $width = $window->width * $scaling_ratio;
my $height = $window->height * $scaling_ratio;
my $ps = Prima::PS::Drawable-> create( onSpool => sub {
        open my $fh, ">>", $base_filename;
        print $fh $_[1];
        close $fh;
    },
    pageSize => [$width, $height],
    pageMargins => [0, 0, 0, 0],
    isEPS => 1,
    useDeviceFontsOnly => 1,
);
$ps->resolution($window->resolution);
$ps->font(height => $window->font->height);
# Set the font, set the baseline, etc

$ps->begin_doc or die "Error generating Postscript output: $@";

if ($subcanvas) {
    $window->paint_with_widgets($ps);
}
else {
    $window->push_event;
    $window->begin_paint_info;
    $window->notify('Paint', $ps);
    $window->end_paint_info;
    $window->pop_event;

}

$ps->end_doc;

print "Window has baseline\n" if $window->textOutBaseline;

run Prima;

When run with no arguments, the script gives the following output:

$ perl ps-subcanvas-font-dimensions.pl
Subroutine Prima::PS::Drawable::emit redefined at ps-subcanvas-font-dimensions.pl line 13.
Subroutine Prima::PS::Drawable::text_out redefined at ps-subcanvas-font-dimensions.pl line 21.
Just before text out operation, font width is 16, and font width divisor is 16
baseline is true

and produces this eps file:

%!PS-Adobe-2.0 EPSF-2.0
%%Title: Prima
%%Creator: Prima::PS::Drawable
%%CreationDate: Wed Jun 11 16:49:30 2014
%%Pages: (atend)
%%BoundingBox: 0 0 36 36

%%LanguageLevel: 2
%%DocumentNeededFonts: (atend)
%%DocumentSuppliedFonts: (atend)
%%EndComments

/d/def load def/,/load load d/~/exch , d/S/show , d/:/gsave , d/;/grestore ,
d/N/newpath , d/M/moveto , d/L/rlineto , d/X/closepath , d/C/clip ,
d/T/translate , d/R/rotate , d/P/showpage , d/Z/scale , d/I/imagemask ,
d/@/dup , d/G/setgray , d/A/setrgbcolor , d/l/lineto , d/F/fill ,
d/FF/findfont , d/XF/scalefont , d/SF/setfont , 
d/O/stroke , d/SD/setdash , d/SL/setlinecap , d/SW/setlinewidth , 
d/SJ/setlinejoin , d/E/eofill , 
d/SS/setcolorspace , d/SC/setcolor , d/SM/setmatrix , d/SPD/setpagedevice ,
d/SP/setpattern , d/CP/currentpoint , d/MX/matrix , d/MP/makepattern , 
d/b/begin , d/e/end , d/t/true , d/f/false , d/?/ifelse , d/a/arc ,
d/dummy/_dummy

%%BeginSetup

%%EndSetup

%%Page: 1 1

/reencode_font { ~ /enco ~ d
@ @ FF @ length dict b { 1 index 
/FID ne{d}{pop pop}?} forall /Encoding 
enco d currentdict e definefont } bind d

/Encoding_Latin1 [
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quotesingle/parenleft/parenright/asterisk/plus/comma/minus/period/slash
/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon/less/equal/greater/question
/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore
/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o
/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/dotlessi/grave/acute/circumflex/tilde/macron/breve/dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut/ogonek/caron
/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/hyphen/registered/macron
/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine/guillemotright/onequarter/onehalf/threequarters/questiondown
/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis
/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis
] d

0 0 T
N 0 0 M 0 36.135 L 36.135 0 L 0 -36.135 L X C

:
1 1 Z
Encoding_Latin1 /Helvetica-Narrow reencode_font
/Helvetica-Narrow FF 14 XF SF
: 7.53 7.45 T
0 0 M
0 0 0 A
(f) S
3.24 0 M
(o) S
9.74 0 M
(o) S
;
; P

%%Trailer
%%DocumentNeededFonts:
%%DocumentSuppliedFonts:
%%Pages: 1
%%EOF

which looks like this:
font-dimensions


When run with the subcanvas argument, it prints the following output:

$ perl ps-subcanvas-font-dimensions.pl subcanvas
Subroutine Prima::PS::Drawable::emit redefined at ps-subcanvas-font-dimensions.pl line 13.
Subroutine Prima::PS::Drawable::text_out redefined at ps-subcanvas-font-dimensions.pl line 21.
Just before text out operation, font width is 10, and font width divisor is 19
 at ps-subcanvas-font-dimensions.pl line 11.
    main::__ANON__('Prima::PS::Drawable=HASH(0x7f84694d9c78)', '0.526315789473684 1 Z') called at /Users/dcmertens/perl5/perlbrew/perls/perl-5.18.1-thread-multi/lib/site_perl/5.18.1/darwin-thread-multi-2level/Prima/PS/Drawable.pm line 926
    Prima::PS::Drawable::text_out('Prima::PS::Drawable=HASH(0x7f84694d9c78)', 'foo', 10, 10) called at /Users/dcmertens/perl5/perlbrew/perls/perl-5.18.1-thread-multi/lib/site_perl/5.18.1/darwin-thread-multi-2level/Prima/Drawable/Subcanvas.pm line 124
    Prima::Drawable::Subcanvas::text_out('Prima::Drawable::Subcanvas=HASH(0x7f846956f788)', 'foo', 10, 10) called at ps-subcanvas-font-dimensions.pl line 32
    main::__ANON__('Prima::MainWindow=HASH(0x7f84694d2548)', 'Prima::Drawable::Subcanvas=HASH(0x7f846956f788)') called at /Users/dcmertens/perl5/perlbrew/perls/perl-5.18.1-thread-multi/lib/site_perl/5.18.1/darwin-thread-multi-2level/Prima/Drawable/Subcanvas.pm line 265
    eval {...} called at /Users/dcmertens/perl5/perlbrew/perls/perl-5.18.1-thread-multi/lib/site_perl/5.18.1/darwin-thread-multi-2level/Prima/Drawable/Subcanvas.pm line 265
    Prima::Drawable::Subcanvas::paint_widgets('Prima::Drawable::Subcanvas=HASH(0x7f846956f788)', 'Prima::MainWindow=HASH(0x7f84694d2548)', 0, 0) called at /Users/dcmertens/perl5/perlbrew/perls/perl-5.18.1-thread-multi/lib/site_perl/5.18.1/darwin-thread-multi-2level/Prima/Drawable/Subcanvas.pm line 293
    Prima::Drawable::paint_with_widgets('Prima::MainWindow=HASH(0x7f84694d2548)', 'Prima::PS::Drawable=HASH(0x7f84694d9c78)') called at ps-subcanvas-font-dimensions.pl line 55

and produces this eps file:

%!PS-Adobe-2.0 EPSF-2.0
%%Title: Prima
%%Creator: Prima::PS::Drawable
%%CreationDate: Wed Jun 11 16:49:11 2014
%%Pages: (atend)
%%BoundingBox: 0 0 36 36

%%LanguageLevel: 2
%%DocumentNeededFonts: (atend)
%%DocumentSuppliedFonts: (atend)
%%EndComments

/d/def load def/,/load load d/~/exch , d/S/show , d/:/gsave , d/;/grestore ,
d/N/newpath , d/M/moveto , d/L/rlineto , d/X/closepath , d/C/clip ,
d/T/translate , d/R/rotate , d/P/showpage , d/Z/scale , d/I/imagemask ,
d/@/dup , d/G/setgray , d/A/setrgbcolor , d/l/lineto , d/F/fill ,
d/FF/findfont , d/XF/scalefont , d/SF/setfont , 
d/O/stroke , d/SD/setdash , d/SL/setlinecap , d/SW/setlinewidth , 
d/SJ/setlinejoin , d/E/eofill , 
d/SS/setcolorspace , d/SC/setcolor , d/SM/setmatrix , d/SPD/setpagedevice ,
d/SP/setpattern , d/CP/currentpoint , d/MX/matrix , d/MP/makepattern , 
d/b/begin , d/e/end , d/t/true , d/f/false , d/?/ifelse , d/a/arc ,
d/dummy/_dummy

%%BeginSetup

%%EndSetup

%%Page: 1 1

/reencode_font { ~ /enco ~ d
@ @ FF @ length dict b { 1 index 
/FID ne{d}{pop pop}?} forall /Encoding 
enco d currentdict e definefont } bind d

/Encoding_Latin1 [
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quotesingle/parenleft/parenright/asterisk/plus/comma/minus/period/slash
/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon/less/equal/greater/question
/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore
/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o
/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/dotlessi/grave/acute/circumflex/tilde/macron/breve/dotaccent/dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut/ogonek/caron
/.notdef/exclamdown/cent/sterling/currency/yen/brokenbar/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/hyphen/registered/macron
/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine/guillemotright/onequarter/onehalf/threequarters/questiondown
/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis
/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis
] d

0 0 T
N 0 0 M 0 36.135 L 36.135 0 L 0 -36.135 L X C

:
1 1 Z
;
:
1 1 Z
/Encoding_iso8859-1 [
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quotesingle/parenleft/parenright/asterisk/plus/comma/minus/period/slash
/zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon/less/equal/greater/question
/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore
/grave/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o
/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
/space/exclamdown/cent/sterling/currency/yen/brokenbar/section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot/hyphen/registered/macron
/degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine/guillemotright/onequarter/onehalf/threequarters/questiondown
/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis
/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis
] d

;
:
1 1 Z
;
:
N 0 0 M 0 36.51 L 36.89 0 L 0 -36.51 L X C

1 1 Z
Encoding_iso8859-1 /Helvetica reencode_font
/Helvetica FF 14 XF SF
: 7.53 10.43 T
0.526315789473684 1 Z
0 0 M
0 0 0 A
(f) S
3.96 0 M
(o) S
11.9 0 M
(o) S
;
; P

%%Trailer
%%DocumentNeededFonts:
%%DocumentSuppliedFonts:
%%Pages: 1
%%EOF

which looks like this;
font-dimensions-subcanvas

SIGABRT from CPANTesters

I see you've added CI, great stuff! See https://www.cpantesters.org/cpan/report/d4ae9744-c98e-11ec-95f8-e64f08875e30, excerpt:

t/Object/Application.t .. ok
perl: unix/clipboard.c:167: prima_clipboard_kill_item: Assertion `PL_valid_types_RV[SvTYPE(_svrv) & SVt_MASK]' failed.
t/Object/Clipboard.t .... 
Failed 3/11 subtests 
# ...
Test Summary Report
-------------------
t/Object/Clipboard.t  (Wstat: 134 (Signal: ABRT, dumped core) Tests: 8 Failed: 0)
  Non-zero wait status: 134
  Parse errors: Bad plan.  You planned 11 tests but ran 8.

UTF8 Issue in Ubuntu 16.10

Dear Mr Karasiak,
Thank you for your work. The prima GUI toolkit is incredible fast!
I noticed an (I think) issue with UTF8 on Linux. Perhaps I dont understand the usage of Prima at the moment not good enough, but in the following basic code the umlauts are shown wrongly:

use utf8;

use Prima;
use Prima::Application;

my $mw = Prima::MainWindow->new(text => "Halölä");
run Prima;

I am on Linux and the system encoding is utf8.

Thanks in advance,
Max

Question on test suite v.s. libthai

Hello,

After having compiled all the dependencies of Prima on Windows and the cl compiler, in particular libthai version 0.1.29 for which the test suite is successful, Prima test suite fails only thai breaks IMHO:

C:\Users\jddfr\git\Prima>nmake test

Microsoft (R) Program Maintenance Utility Version 14.32.31332.0
Copyright (C) Microsoft Corporation. Tous droits réservés.

        "C:\cl-perl-5.37.6-32bit\bin\perl.exe" -MExtUtils::Command::MM -e cp_nonempty -- Prima.bs blib\arch\auto\Prima\Prima.bs 644
        "C:\cl-perl-5.37.6-32bit\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t\*\*.t
t\Image\Bar.t ........... ok
t\Image\Basic.t ......... ok
t\Image\Bitmaps.t ....... ok
t\Image\Codec.t ......... ok
t\Image\Colormap.t ...... ok
t\Image\Conversion.t .... ok
t\Image\Extract.t ....... ok
t\Image\FloodFill.t ..... ok
t\Image\Import.t ........ ok
t\Image\Path.t .......... ok
t\Image\ROP.t ........... ok
t\Image\Stream.t ........ ok
t\Image\Stretch.t ....... ok
t\Image\Tile.t .......... ok
t\Image\Transform.t ..... ok
t\misc\cpan.t ........... ok
t\misc\fs.t ............. ok
t\misc\pod.t ............ skipped: Test::Pod 1.00 required for testing POD
t\misc\syntax.t ......... ok
t\Object\Application.t .. ok
t\Object\Array.t ........ ok
t\Object\Clipboard.t .... ok
t\Object\Component.t .... ok
t\Object\File.t ......... ok
t\Object\Fonts.t ........ ok
t\Object\GP.t ........... ok
t\Object\GPExtra.t ...... ok
t\Object\GPState.t ...... ok
t\Object\Object.t ....... ok
t\Object\Polyfont.t ..... ok
t\Object\Region.t ....... ok
t\Object\Shaping.t ...... ok
t\Object\TextWrap.t ..... 1/? libthai error, disabling at t\Object\TextWrap.t line 35.

#   Failed test 'thai breaks: length'
#   at t\Object\TextWrap.t line 46.
#     Structures begin differing at:
#          $got->[0] = '8'
#     $expected->[0] = '6'

#   Failed test 'thai breaks: chunks'
#   at t\Object\TextWrap.t line 48.
#     Structures begin differing at:
#          $got->[1] = '8'
#     $expected->[1] = '6'
# WANTED: 0 6 6 6
# GOT:0 8 8 4

#   Failed test 'thai breaks: text'
#   at t\Object\TextWrap.t line 52.
Wide character in print at C:/cl-perl-5.37.6-32bit/lib/Test2/Formatter/TAP.pm
        line 125 (#1)
    (S utf8) Perl met a wide character (ordinal >255) when it wasn't
    expecting one.  This warning is by default on for I/O (like print).

    If this warning does come from I/O, the easiest
    way to quiet it is simply to add the :utf8 layer, e.g.,
    binmode STDOUT, ':utf8'.  Another way to turn off the warning is
    to add no warnings 'utf8'; but that is often closer to
    cheating.  In general, you are supposed to explicitly mark the
    filehandle with an encoding, see open and "binmode" in perlfunc.

    If the warning comes from other than I/O, this diagnostic probably
    indicates that incorrect results are being obtained.  You should examine
    your code to determine how a wide character is getting to an operation
    that doesn't handle them.

#     Structures begin differing at:
#          $got->[0] = 'สวัสดีชา'
#     $expected->[0] = 'สวัสดี'

#   Failed test 'thai breaks: G(0)'
#   at t\Object\TextWrap.t line 58.
#     Structures begin differing at:
#          $got->[0][6] = '1'
#     $expected->[0][6] = Does not exist
# WANTED:
# 6 glyphs: 1 1 1 1 1 1
# indexes: 0 1 2 3 4 5 : 12
# advances: 10 10 10 10 10 10
# positions: (0,0) (0,0) (0,0) (0,0) (0,0) (0,0)
# GOT:
# 8 glyphs: 1 1 1 1 1 1 1 1
# indexes: 0 1 2 3 4 5 6 7 : 12
# advances: 10 10 10 10 10 10 10 10
# positions: (0,0) (0,0) (0,0) (0,0) (0,0) (0,0) (0,0) (0,0)

#   Failed test 'thai breaks: G(1)'
#   at t\Object\TextWrap.t line 58.
#     Structures begin differing at:
#          $got->[0][4] = Does not exist
#     $expected->[0][4] = '1'
# WANTED:
# 6 glyphs: 1 1 1 1 1 1
# indexes: 6 7 8 9 10 11 : 12
# advances: 10 10 10 10 10 10
# positions: (0,0) (0,0) (0,0) (0,0) (0,0) (0,0)
# GOT:
# 4 glyphs: 1 1 1 1
# indexes: 8 9 10 11 : 12
# advances: 10 10 10 10
# positions: (0,0) (0,0) (0,0) (0,0)
# Looks like you failed 5 tests of 9.
t\Object\TextWrap.t ..... Dubious, test returned 5 (wstat 1280, 0x500)
Failed 5/9 subtests
t\Object\Timer.t ........ ok
t\Widget\Basic.t ........ ok
t\Widget\Desktop.t ...... ok
t\Widget\Key.t .......... ok
t\Widget\leshed.t ....... ok
t\Widget\Lock.t ......... ok
t\Widget\Map.t .......... ok
t\Widget\Mouse.t ........ ok
t\Widget\Move.t ......... ok
t\Widget\Paint.t ........ ok
t\Widget\Position.t ..... ok
t\Widget\Size.t ......... ok
t\Widget\SizeLimits.t ... ok
t\Widget\Window.t ....... ok
t\Widget\ZOrder.t ....... ok

Test Summary Report
-------------------
t\Object\TextWrap.t   (Wstat: 1280 (exited 5) Tests: 9 Failed: 5)
  Failed tests:  4-6, 8-9
  Non-zero exit status: 5
Files=48, Tests=11110, 37 wallclock secs ( 1.06 usr +  0.14 sys =  1.20 CPU)
Result: FAIL
Uncaught exception from user code:
        Failed 1/48 test programs. 5/11110 subtests failed.
        Test::Harness::runtests("t\\Image\\Bar.t", "t\\Image\\Basic.t", "t\\Image\\Bitmaps.t", "t\\Image\\Codec.t", "t\\Image\\Colormap.t", "t\\Image\\Conversion.t", "t\\Image\\Extract.t", "t\\Image\\FloodFill.t", ...) called at C:/cl-perl-5.37.6-32bit/lib/ExtUtils/Command/MM.pm line 72
        ExtUtils::Command::MM::test_harness(0, "blib\\lib", "blib\\arch") called at -e line 1
NMAKE : fatal error U1077: 'C:\cl-perl-5.37.6-32bit\bin\perl.exe' : code retour '0xff'
Stop.

My question is if you know if libthai is stable concerning the notion of breaks. If yes, I suppose my libthai is wrong (and this is strange since its test suite is ok...), if no then the thai breaks part of Prima test suite should not be compulsory.

Prima::Application + threads segfault

Prima-threads.t.txt

This is a weird interaction between Prima and threads, but it only manifests itself when just compiling things, not when running a program. See the attached test file which shows that:

  1. Running a program that consists of

use Prima 'Application';
use threads;

exits without problem

  1. Compiling such a program with "perl -wc" crashes at the end on Perl 5.22, Windows.

I'm not sure where/how to track down the reason - I guess it has something to do with a resource that is not allocated at compile time and then freed in global cleanup, and usually is initialized. I don't know where/how threads.pm comes into play or if that is just bad luck.

Word and text wrap can cause Prima to hang

Here is a simple demonstration. Run this script and move the cursor to the right end of the space after test, and Prima will hang.

use strict;
use warnings;
use Prima qw(Edit Application);

my $w = Prima::MainWindow->new;
my $edit = $w->insert(Edit =>
    wordWrap => 1,
    cursorWrap => 1,
    text => "a test \nb\n",
);
my $text_width = $edit->get_text_width('test ');
$edit->width($text_width - 1);

run Prima;

The program hangs on line 1645 of Edit.pm, because text_wrap does not produce a chunk map entry for the location after the space at the end of the line.

This can probably be fixed by making sure that the while loop on line 1645 does not go out of the current paragraph ($$cm[$i+2] does not change) with something like this:

    my $j = $$cm[ $i + 2];
    while ( $x > $$cm[ $i] + $$cm[ $i + 1] and $$cm[ $i + 2] == $j) {
        $i+= 3;
        $y++;
    }
    $y--, $i-= 3 if $$cm[ $i + 2] != $j;

While this removes the hang, it leads to a situation in which the cursor does not get painted.

Mac OSX PNG load errors

Hi Dmitry
Prima was able to load PNG images earlier on Mac OSX but now something has changed and it is not loading any images as part of the Prima::Icon class.

I use MacPorts on OSX 10.7. libpng, libjpeg and libgif are installed on MacPorts but yet the PNG loading is not happening. My libpng version is 1.6.8

I cannot figure out why and I am using the latest Prima from github even.

I get no errors from the icon loading except the fact that the load has failed.

How can this be fixed ?

In other news, libjpeg has to be forced to be an older version to allow for use on the Mac. I think libjpeg version 6 as opposed to the more recent 8, otherwise Prima doesn't even compile.

Please advise.
Thanks.

Question on Prima::Config

During the install, Prima seems to manipulate Prima/Config.pm that will then contain explicit paths related to the current perl, I wonder if this will cause a problem in case we want the perl install to be relocatable. Cases I have identified are:

/C/cl-perl-5.37.6-32bit/site/lib/Prima/Config.pm:my $bin = q(C:\cl-perl-5.37.6-32bit\bin);
/C/cl-perl-5.37.6-32bit/site/lib/Prima/Config.pm:       incpaths              => [ "$lib/Prima/CORE","$lib/Prima/CORE/generic","C:/cl-perl-5.37.6-32bit/c/lib/pkgconfig/../../include/fribidi","C:/cl-perl-5.37.6-32bit/c/lib/pkgconfig/../../include","C:/cl-perl-5.37.6-32bit/c/include" ],
/C/cl-perl-5.37.6-32bit/site/lib/Prima/Config.pm:       ldpaths               => ["C:/cl-perl-5.37.6-32bit/c/lib/pkgconfig/../../lib","C:/cl-perl-5.37.6-32bit/c/lib","$lib/auto/Prima"],
/C/cl-perl-5.37.6-32bit/site/lib/Prima/Config.pm:       inc                   => "-I$lib/Prima/CORE -I$lib/Prima/CORE/generic -IC:/cl-perl-5.37.6-32bit/c/lib/pkgconfig/../../include/fribidi -IC:/cl-perl-5.37.6-32bit/c/lib/pkgconfig/../../include -IC:/cl-perl-5.37.6-32bit/c/include",

The first one, IMHO, may use %Config or another hack like it is done for $lib ? The others, I guess, are side effects of compilation flags and it is probably harmless to find them here - I can manage that myself in my scripts if needed.

I would be glad if you can confirm the impact of Config.pm v.s. perl relocatibility.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.