Recent

Author Topic: Cross compiling and fonts  (Read 13614 times)

patyi

  • Full Member
  • ***
  • Posts: 168
Cross compiling and fonts
« on: December 15, 2007, 10:15:31 am »
Hi !

I made a small project on Win32, port it to Linux (Ubuntu 7.10),
made some modifications on Linux, dhen go back to Win32.

It is almost fine, but I see big difference visualy on fonts.
Wen I corrected this on Win, Linux lock ugly, and viceversa ...

What is the metodology or what is the best practice to do
cross platform programs, without changing font settings for
actual platform ? It is posible to set fonts universaly ?

Thanks.

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: Cross compiling and fonts
« Reply #1 on: December 15, 2007, 11:15:49 am »
You can set fonts for each widgetset using compiler directives. For example:

Code: [Select]

{$ifdef Windows}
// font for Windows
{$else}
// font for Linux
{$endif}
{


If I can remeber correctly.

Dr.Theopolis

  • Jr. Member
  • **
  • Posts: 69
Default font
« Reply #2 on: December 15, 2007, 05:57:01 pm »
I have the same problem as patyi.  :?

Antonio, are you saying that every parent control in a project needs to have its font set at runtime using the method above? And unless there are fonts that are pretty much exact size on both platforms, one might also have to adjust left and top properties for labels and such.

So what fonts are good to use as default fonts on Windows & Linux that are the same size?

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: Default font
« Reply #3 on: December 15, 2007, 06:57:04 pm »
No, I am not saying that. It seems that patyi knows what fonts he want to have on each OS, so I say it is possible to set for an application a different font for each OS it will be compiled to.

Choosing a font to an application is up to developer, even to know what font is visually the same is a subjective problem.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Default font
« Reply #4 on: December 15, 2007, 09:01:11 pm »
Quote from: "antonio"
Choosing a font to an application is up to developer, even to know what font is visually the same is a subjective problem.


In general, forms using commonly-used TrueType fonts like Arial, Times New Roman and Courier can be used interchangeably with win32 and carbon widgetsets since these fonts are included with both Windows and OS X. The problem is with the gtk fonts. It might be worth creating a little console converter app that maps the TrueType fonts to and from, say, the gtk helvetica, times and courier (adobe) fonts. Then just run this converter on your forms in a script file before compiling.

Thanks.

-Phil

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: Re: RE: Default font
« Reply #5 on: December 16, 2007, 02:00:45 am »
"Write once and compile everywhere."

duncanparsons

  • Jr. Member
  • **
  • Posts: 83
RE: Re: RE: Default font
« Reply #6 on: December 17, 2007, 10:23:19 am »
..thing is, it does compile - this isn't really an FPC or a Laz problem, it's a platform problem!

DSP

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2671
RE: Re: RE: Default font
« Reply #7 on: December 17, 2007, 11:37:31 am »
lazarus only helps in generating executables. External dependencies like fonts you have to provide yourself.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

patyi

  • Full Member
  • ***
  • Posts: 168
Cross compiling and fonts
« Reply #8 on: December 17, 2007, 12:11:34 pm »
I made some experiment, this example could solves the font problem
nearly satisfactorily :

procedure TFPrijava.FormCreate(Sender: TObject);
var
  fn : string;
  fs, i : integer;
  co : TComponent;
begin
  {$IFDEF WINDOWS}
    fn := 'Arial';
    fs := 9;
  {$ELSE}
    fn := 'Sans';
    fs := 8;
  {$ENDIF}

  for i := 0 to ComponentCount-1 do begin
    co := Components;
    if co is TControl then begin
      TControl(co).Font.Name := fn;
      TControl(co).Font.Size := fs;     // global settings om form
      if (co is TBitBtn) or
         (co is TEdit) or
         (co is TComboBox) then
        TControl(co).Font.Style:= [fsBold];  // special if neaded
    end;
  end;    

It is very nice but, Lazarus has another problem: position and size of components at design time is not correct specially when I use right alignment for example in Label component. Vertical size of edit box, combo box is also incorrect.

I know that is platform problem, it is differences between GTK2 and
Windows widgets. Because of this almost is impossible to
do cross platform development in way I want. Better way is to chose the primary platform where is the development and modifications was made,
an second platform is for only recompile and testing (eventually correct the visual problems). Moving source code back to primary platform may
take big problems for whole project in esthetic's meaner ! :shock:

Sorry for my English ! I hope the world understand what i mean ... :lol:

antonio

  • Hero Member
  • *****
  • Posts: 605
Cross compiling and fonts
« Reply #9 on: December 17, 2007, 02:36:52 pm »
Quote from: "patyi"
position and size of components at design time is not correct specially when I use right alignment for example in Label component. Vertical size of edit box, combo box is also incorrect.

You could report a bug.

Dr.Theopolis

  • Jr. Member
  • **
  • Posts: 69
How do you solve this problem?
« Reply #10 on: December 20, 2007, 11:16:54 pm »
If anyone has made a nice multi-platform app and you came up with a good way to deal with differing font sizes between platforms, how did you do it? Thanks. :)

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: How do you solve this problem?
« Reply #11 on: December 20, 2007, 11:53:01 pm »
Was it not the question? Do you think I did'nt understand the question?

Dr.Theopolis

  • Jr. Member
  • **
  • Posts: 69
Huh
« Reply #12 on: December 21, 2007, 04:21:48 am »
Should I ask your permission before I post on this forum?

Anyway...I am simply asking for others who have not yet participated in this topic to share a bit about the solutions that worked for them.

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: Huh
« Reply #13 on: December 21, 2007, 06:38:59 am »
You are saying I diidn't understand _your_ question. Sorry.

windy

  • Full Member
  • ***
  • Posts: 186
RE: Huh
« Reply #14 on: December 26, 2007, 07:48:40 pm »
Hi
the way I deal with problem, for between linux and the mac, is when updating /changing code on the linux pc, I then just copy across the .pas files needed that have changed,to the mac pc ( after first setting the needed fonts to look ok on the Mac (and re positioning and resizing the objects on the forms), a one time change only (unless things added or need changing)
...just my 2 cents worth
Hope everyone had a good xmas!

 

TinyPortal © 2005-2018