Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
philjynx
Earned some good credits
Earned some good credits
Posts: 136
Joined: Tue Mar 06, 2018 6:00 pm

Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby philjynx » Sat Mar 17, 2018 11:05 pm

This follows on from https://forums.wxwidgets.org/viewtopic.php?f=1&t=44381 but, I think is a separate issue.
I build my fledgling app on my desktop. It displays just as it should, this is Linnux Mint 64bit on PC.
When I put the source into my RPi and build it there, the fonts are not showing as they should.

I've set the font on the frame, not the individual controls. Or I should say wxFormBuilder has written the code to do that, here's a snippet:

Code: Select all

TopFrame::TopFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
{
   this->SetSizeHints( wxDefaultSize, wxDefaultSize );
   this->SetFont( wxFont( 32, 70, 90, 90, false, wxEmptyString ) );
   
   wxGridSizer* gSizer1;
   gSizer1 = new wxGridSizer( 3, 3, 0, 0 );
   
   m_staticText2 = new wxStaticText( this, wxID_ANY, wxT("GR55"), wxDefaultPosition, wxDefaultSize, 0 );
   m_staticText2->Wrap( -1 );
   gSizer1->Add( m_staticText2, 0, wxALL, 5 );
   
   m_staticText4 = new wxStaticText( this, wxID_ANY, wxT("MyLabel"), wxDefaultPosition, wxDefaultSize, 0 );
   m_staticText4->Wrap( -1 );
   gSizer1->Add( m_staticText4, 0, wxALL, 5 );


Now, as I said this has the desired effect on my PC, those two static texts display at 32 point, but it has no effect at all when the same project is built and then run on the RPi.

I've never come across this sort of thing with any other programming tools that I've used, I have not a clue how to figure this out.

User avatar
doublemax
Moderator
Moderator
Posts: 12423
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby doublemax » Sun Mar 18, 2018 12:02 am

Can you show a screenshot of both versions?
Do you use the same wx version on both systems? Same GTK version?
Use wxFont::IsOk() to check if the font was successfully created before applying it.
Use the source, Luke!

philjynx
Earned some good credits
Earned some good credits
Posts: 136
Joined: Tue Mar 06, 2018 6:00 pm

Re: Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby philjynx » Sun Mar 18, 2018 11:12 am

GTK versions, using a command I found on the interweb

Code: Select all

dpkg -l libgtk* | grep -e '^i' | grep -e 'libgtk-*[0-9]'

I get these results:

Code: Select all

pi@raspberrypi:~ $ dpkg -l libgtk* | grep -e '^i' | grep -e 'libgtk-*[0-9]'
ii  libgtk-3-0:armhf   3.22.11-1+rpi3 armhf        GTK+ graphical user interface library
ii  libgtk-3-common    3.22.11-1+rpi3 all          common files for the GTK+ graphical user interface library
ii  libgtk-3-dev:armhf 3.22.11-1+rpi3 armhf        development files for the GTK+ library
ii  libgtk2.0-0:armhf  2.24.31-2      armhf        GTK+ graphical user interface library
ii  libgtk2.0-bin      2.24.31-2      armhf        programs for the GTK+ graphical user interface library
ii  libgtk2.0-common   2.24.31-2      all          common files for the GTK+ graphical user interface library

and

Code: Select all

phil@phil-Veriton-N280G ~ $ dpkg -l libgtk* | grep -e '^i' | grep -e 'libgtk-*[0-9]'
ii  libgtk-3-0:amd64             3.18.9-1ubuntu3.3         amd64        GTK+ graphical user interface library
ii  libgtk-3-0-dbg               3.18.9-1ubuntu3.3         amd64        GTK+ libraries and debugging symbols
ii  libgtk-3-bin                 3.18.9-1ubuntu3.3         amd64        programs for the GTK+ graphical user interface library
ii  libgtk-3-common              3.18.9-1ubuntu3.3         all          common files for the GTK+ graphical user interface library
ii  libgtk-3-dev:amd64           3.18.9-1ubuntu3.3         amd64        development files for the GTK+ library
ii  libgtk2-perl                 2:1.2498-1                amd64        Perl interface to the 2.x series of the Gimp Toolkit library
ii  libgtk2.0-0:amd64            2.24.30-1ubuntu1.16.04.2  amd64        GTK+ graphical user interface library
ii  libgtk2.0-0:i386             2.24.30-1ubuntu1.16.04.2  i386         GTK+ graphical user interface library
ii  libgtk2.0-0-dbg              2.24.30-1ubuntu1.16.04.2  amd64        GTK+ libraries and debugging symbols
ii  libgtk2.0-bin                2.24.30-1ubuntu1.16.04.2  amd64        programs for the GTK+ graphical user interface library
ii  libgtk2.0-cil                2.12.10-6                 amd64        CLI binding for the GTK+ toolkit 2.12
ii  libgtk2.0-common             2.24.30-1ubuntu1.16.04.2  all          common files for the GTK+ graphical user interface library
phil@phil-Veriton-N280G ~$


Wx version:

Code: Select all

pi@raspberrypi:~/ $ wx-config --version
3.0.3
pi@raspberrypi:~/RPiInterface/FormBuilder $

Code: Select all

phil@phil-Veriton-N280G ~/ $ wx-config --version
3.0.3
phil@phil-Veriton-N280G ~/$

rpi32.png
rpi32.png (14.49 KiB) Viewed 322 times

LinnuxMint64.png
LinnuxMint64.png (28.45 KiB) Viewed 322 times


At the moment, I am using Show, not ShowFullScreen.

I don't know how or where to use "Use wxFont::IsOk() to check if the font was successfully created before applying it."

User avatar
doublemax
Moderator
Moderator
Posts: 12423
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby doublemax » Sun Mar 18, 2018 12:23 pm

I don't know how or where to use "Use wxFont::IsOk() to check if the font was successfully created before applying it."

Instead of:

Code: Select all

this->SetFont( wxFont( 32, 70, 90, 90, false, wxEmptyString ) );

Try:

Code: Select all

wxFont f( 32, 70, 90, 90, false, wxEmptyString );
// alternatively, try:
// wxFont f = this->GetFont().SetPointSize( 32 );
if( !f.IsOk() )
{
  wxLogMessage( "font creation failed" );
}
else
{
  this->SetFont( f );
}
Use the source, Luke!

philjynx
Earned some good credits
Earned some good credits
Posts: 136
Joined: Tue Mar 06, 2018 6:00 pm

Re: Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby philjynx » Sun Mar 18, 2018 2:04 pm

Code: Select all

this->SetFont( wxFont( 32, 70, 90, 90, false, wxEmptyString ) );

Is from the code generated by wxFormBuilder, so any edits I put in there will be lost next time I generate code - which you have to do if and when you change your form design.

I put that code in and, of course, it doesn't compile.

Code: Select all

JynxII.cpp: In constructor ‘TopFrame::TopFrame(wxWindow*, wxWindowID, const wxString&, const wxPoint&, const wxSize&, long int)’:
JynxII.cpp:78:41: error: conversion from ‘void’ to non-scalar type ‘wxFont’ requested
  wxFont f = this->GetFont().SetPointSize( 32 );
                                         ^
JynxII.cpp:81:39: error: ‘wxLogMessage’ was not declared in this scope
  wxLogMessage( "font creation failed" );
                                       ^


Nearly two weeks ago I started trying to use wxWidgets & wxFormDesigner as a fast way of developing the UI for my app so I could concentrate on the functionality of my app. It's not going well.

philjynx
Earned some good credits
Earned some good credits
Posts: 136
Joined: Tue Mar 06, 2018 6:00 pm

Re: Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby philjynx » Sun Mar 18, 2018 2:17 pm

Ok, so I've discovered you have to include log.h and got a working app.
It has made no difference. Now, I didn't expect the font to work, but there's no message anyplace either - wxLogMessage has not told me anything.

User avatar
doublemax
Moderator
Moderator
Posts: 12423
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby doublemax » Sun Mar 18, 2018 2:20 pm

Is from the code generated by wxFormBuilder, so any edits I put in there will be lost next time I generate code - which you have to do if and when you change your form design.
I don't use any GUI editors, but the fact alone that it uses the decimal values instead of the named values like "wxFONTFAMILY_DEFAULT" in the wxFont creator tells me that wxFormBuilder is junk.

Code: Select all

error: ‘wxLogMessage’ was not declared in this scope
  wxLogMessage( "font creation failed" );
Add #include "wx/log.h" to the source file.
Use the source, Luke!

User avatar
doublemax
Moderator
Moderator
Posts: 12423
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby doublemax » Sun Mar 18, 2018 2:27 pm

wxLogMessage has not told me anything.
It told you that the font is fine, so that's not the problem.

I don't have any RPi for testing, so you have to get creative and make some experiments yourself.

E.g.
Build the "font" sample that comes with wxWidget and check if that works. Especially the function to increase/decrease the font size.

If that doesn't work, the problem is most likely not in your code.
Use the source, Luke!

philjynx
Earned some good credits
Earned some good credits
Posts: 136
Joined: Tue Mar 06, 2018 6:00 pm

Re: Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby philjynx » Sun Mar 18, 2018 2:49 pm

I think I'll have to find another way of creating my UI, I'll take another look at QT and see how that goes.
Cheers.

philjynx
Earned some good credits
Earned some good credits
Posts: 136
Joined: Tue Mar 06, 2018 6:00 pm

Re: Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby philjynx » Sun Mar 18, 2018 10:50 pm

So, well, ok having a look at QT just gave me a headache (as it did last time I looked at it)!.

It does look as though this is an issue with Stretch. If I change the SYSTEM font in this
Screenshot from 2018-03-18 22-46-03.png
Screenshot from 2018-03-18 22-46-03.png (37.08 KiB) Viewed 288 times
, then my App Displays as per that setting (as does the entire RPi).

It seems that Stretch is not allowing my App's fonts to override its system setting.

I've googled that as an RPi / Stretch issue but nothing's come up for it.

User avatar
doublemax
Moderator
Moderator
Posts: 12423
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby doublemax » Sun Mar 18, 2018 10:59 pm

I don't know much about Linux, so i can't say anything about this.

But i still don't trust that formbuilder code, so please try to build and run the "font" sample that comes with wxWidgets and confirm that changing the font size doesn't work there either.
Use the source, Luke!

philjynx
Earned some good credits
Earned some good credits
Posts: 136
Joined: Tue Mar 06, 2018 6:00 pm

Re: Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby philjynx » Sun Mar 18, 2018 11:10 pm

I clean forgot that suggestion, I'll do it now.

philjynx
Earned some good credits
Earned some good credits
Posts: 136
Joined: Tue Mar 06, 2018 6:00 pm

Re: Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby philjynx » Sun Mar 18, 2018 11:37 pm

Ok, tried that, it does work, however so do all the Libre Office apps.
Oddly, when I launch the font demo from the command line on the RPi I get a lot of flak, there's no flak when I do the same thing on Mint on the PC.
Here's the flak....

Code: Select all

pi@raspberrypi:~/wxWidgets-3.0.3/samples/font $ dir
descrip.mms  font.dsp         font_vc9.vcproj  Makefile.in   makefile.wat
font.bkl     font_vc7.vcproj  makefile.bcc     makefile.unx  MyApp
font.cpp     font_vc8.vcproj  makefile.gcc     makefile.vc
pi@raspberrypi:~/wxWidgets-3.0.3/samples/font $ ./MyApp

** (MyApp:2337): WARNING **: Error retrieving accessibility bus address: org.freedesktop.DBus.Error.ServiceUnknown: The name org.a11y.Bus was not provided by any .service files

(MyApp:2337): Gtk-CRITICAL **: gtk_distribute_natural_allocation: assertion 'extra_space >= 0' failed

(MyApp:2337): Gtk-CRITICAL **: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkScrollbar

(MyApp:2337): Gtk-CRITICAL **: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkScrollbar

User avatar
doublemax
Moderator
Moderator
Posts: 12423
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby doublemax » Mon Mar 19, 2018 6:20 am

Ok, tried that, it does work
Does it just run (which was to be expected), or does the included function to change the font size work, too?
(In the menu, Font -> Increase / Decrease font size)
Use the source, Luke!

DavidHart
Site Admin
Site Admin
Posts: 3741
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Font size shows as it should on Linnux Mint 64 bit but not on RPi Stretch

Postby DavidHart » Mon Mar 19, 2018 7:53 am

Hi,
(MyApp:2337): Gtk-CRITICAL **: gtk_distribute_natural_allocation: assertion 'extra_space >= 0' failed
etc

That's gtk+ spam. Different distros/versions supply different versions of gtk+, and unfortunately the gtk+ people don't seem to value stability very highly. So code that runs cleanly on top of one gtk+ version will produce that sort of message on another. It's usually nothing to worry about.

BTW if you do ctrl-alt-middleclick on any wx app, the resulting dialog says which wx version the app was built against, and both the compile-time and runtime gtk+ version.

Regards,

David


Return to “Platform Related Issues”

Who is online

Users browsing this forum: No registered users and 2 guests