Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-02

Synedit: background colours and f(o)nts

8 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Morgan Lloyd

I've got a Synedit here which uses code as below to rule alternate background lines to a light colour:

procedure TListForm.PaneMainEditSpecialLineColors(Sender: TObject; Line:
integer;
                                         var Special: boolean; var FG,
BG: TColor);
begin
   MusicRuleColour(line, FG, BG)
end { TListForm.PaneMainEditSpecialLineColors } ;
PROCEDURE MusicRuleColour(line: INTEGER; VAR FG, BG: TColor);
CONST	lightRed= $00F0F0FF;
	lightGreen= $00E0FFE0;
	lightBlue= $00FFF0F0;
BEGIN
   FG:= ListForm.PaneMainEdit.Font.Color;
   IF ListForm.MenuMainViewMusicRuled.Checked AND Odd(Line) THEN
     CASE ListForm.GlobalState.MusicRuleColour OF
       RuledLightBlue: BG:= lightBlue;
       RuledLightRed:  BG:= lightRed
     ELSE
       BG:= lightGreen
     END
   ELSE
     BG:= ListForm.PaneMainEdit.Color
END { MusicRuleColour } ;

This works well with both GTK and GTK2 up to around 0.9.26, but at some point after that the event continues being called but the background is entirely the default colour. Is there an accessible property that will restore the original behaviour?

In the same program (running on Linux), the Synedit font appears to force itself to a generic Sans at runtime, irrespective of what is actually selected (e.g. Monospace). Again, this is OK up to around 0.9.26.

The application is a fairly simple file viewer, available on a wide range of systems and starting as rapidly as possible- usually when somebody's on the 'phone hassling me for info. As such, I'm trying to keep it compiling on GTK and a rather elderly Delphi, which means that I try to be careful what goes into the .lfm files.

Finally and as a subsidiary question: if I've got a local svn to help moving projects between machines I try to keep them tested on, what files should go into it? Specifically, should I be storing .lrs or are these better recreated on demand?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Martin
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 11 lines
I've got a Synedit here which uses code as below to rule alternate background lines to a light colour: procedure TListForm.PaneMainEditSpecialLineColors(Sender: TObject; Line: integer; var Special: boolean; var FG, BG: TColor); begin MusicRuleColour(line, FG, BG) end { TListForm.PaneMainEditSpecialLineColors } ;
Add
     Special := true;

The event is called for all lines, color is only taken, if Special is set

Reply by email

Mark Morgan Lloyd
to Martin
Martin wrote 17 lines
On 20/02/2012 09:24, Mark Morgan Lloyd wrote: > I've got a Synedit here which uses code as below to rule alternate > background lines to a light colour: > > procedure TListForm.PaneMainEditSpecialLineColors(Sender: TObject; > Line: integer; > var Special: boolean; var FG, > BG: TColor); > > begin > MusicRuleColour(line, FG, BG) > end { TListForm.PaneMainEditSpecialLineColors } ; Add Special := true; The event is called for all lines, color is only taken, if Special is set

Thanks Martin, I think I was reading that the wrong way round (i.e. the special overruled colour).

Any thoughts on what could be messing up the font?

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Martin
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote
Any thoughts on what could be messing up the font?

Sorry missed that part

Mark Morgan Lloyd wrote
In the same program (running on Linux), the Synedit font appears to force itself to a generic Sans at runtime, irrespective of what is actually selected (e.g. Monospace). Again, this is OK up to around 0.9.26.

No idea... You set the font via the object inspector?

If you put a label in with the same font. does that work? Have you tried other fonts?
Are they in that name-15-*-* format ?

Try compiling with SYNFONTDEBUG defined

also add a debugln to SynEdit.FontChanged
and SynEdit.RecalcCharExtend

and output the fontname there please

Show quoted text 6 lines
Finally and as a subsidiary question: if I've got a local svn to help moving projects between machines I try to keep them tested on, what files should go into it? Specifically, should I be storing .lrs or are these better recreated on demand?

Not sure about that. Afaik newer Lazarus does no longer need lfr. But better ask in a none SynEdit thread

Reply by email

Mark Morgan Lloyd
to Martin
Martin wrote 7 lines
On 20/02/2012 09:24, Mark Morgan Lloyd wrote: > In the same program (running on Linux), the Synedit font appears to > force itself to a generic Sans at runtime, irrespective of what is > actually selected (e.g. Monospace). Again, this is OK up to around > 0.9.26. No idea... You set the font via the object inspector?

Yes.

If you put a label in with the same font. does that work?

Yes.

Have you tried other fonts?

Yes, it's a general problem.

Are they in that name-15-*-* format ?

That was available in gtk1, but appears to not be in gtk2 or Qt's font dialog (although it would be nice to have it as an option).

Using 0.9.30.3, Qt appears to work as expected but gtk2 is a mess. I can't easily try other widget sets on that version, both gtk and gtk2 are and possibly some later versions.

Show quoted text 6 lines
Try compiling with SYNFONTDEBUG defined also add a debugln to SynEdit.FontChanged and SynEdit.RecalcCharExtend and output the fontname there please

Starts off Courier New, switches to Monospace, reverts to Courier New.

./list3264-i386-linux-gtk2 ../list.txt >debug 2>&1

TheFontStock.CalcFontAdvance: Font=Courier New Size=10 TextMetrics tmHeight=15, tmAve=8, tmMax=8, tmOver=0
TheTextDrawer.SetBaseStyle =0 CharAdvance=8 CharHeight=15 FBaseCharWidth=8 FBaseCharHeight=15
MarkMLl: in PaneMainEdit.FontChanged(), font is Monospace MarkMLl: in PaneMainEdit.RecalcCharExtent(), font is Monospace TheTextDrawer.SetBaseFont Name=Monospace Size=10Style=0 TheTextDrawer.SetBaseStyle =0 CharAdvance=8 CharHeight=17 FBaseCharWidth=8 FBaseCharHeight=17
MarkMLl: in PaneMainEdit.FontChanged(), font is courier 10 pitch [bitstream] MarkMLl: in PaneMainEdit.RecalcCharExtent(), font is courier 10 pitch [bitstream]
TheTextDrawer.SetBaseFont Name=courier 10 pitch [bitstream] Size=10Style=0

I think I'd better email you the output to avoid problems caused by line breaks etc.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Unknown author
to Mark Morgan Lloyd

Quoting Mark Morgan Lloyd :

Show quoted text 24 lines
Martin wrote: > On 20/02/2012 09:24, Mark Morgan Lloyd wrote: >> In the same program (running on Linux), the Synedit font appears >> to force itself to a generic Sans at runtime, irrespective of what >> is actually selected (e.g. Monospace). Again, this is OK up to >> around 0.9.26. > > No idea... You set the font via the object inspector? Yes. > If you put a label in with the same font. does that work? Yes. > Have you tried other fonts? Yes, it's a general problem. > Are they in that name-15-*-* format ? That was available in gtk1, but appears to not be in gtk2 or Qt's font dialog (although it would be nice to have it as an option).

Since last week trunk gtk2 is fixed and it uses pango fonts everywhere. Fonts are consistent now (at least with qt under linux). 0.9.30.XX will stay as it is, don't think that it will be merged there.

zeljko

Reply by email

Mark Morgan Lloyd
to Unknown author
Show quoted text 30 lines
Quoting Mark Morgan Lloyd : > Martin wrote: > >> On 20/02/2012 09:24, Mark Morgan Lloyd wrote: >>> In the same program (running on Linux), the Synedit font appears to >>> force itself to a generic Sans at runtime, irrespective of what is >>> actually selected (e.g. Monospace). Again, this is OK up to around >>> 0.9.26. >> >> No idea... You set the font via the object inspector? > > Yes. > >> If you put a label in with the same font. does that work? > > Yes. > >> Have you tried other fonts? > > Yes, it's a general problem. > >> Are they in that name-15-*-* format ? > > That was available in gtk1, but appears to not be in gtk2 or Qt's font > dialog (although it would be nice to have it as an option). Since last week trunk gtk2 is fixed and it uses pango fonts everywhere. Fonts are consistent now (at least with qt under linux). 0.9.30.XX will stay as it is, don't think that it will be merged there.

Thanks, trunk with 2.7.1 compiling for gtk2 now looks OK. i can live with that :-)

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

zeljko
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 32 lines
wrote: > Quoting Mark Morgan Lloyd : >> Martin wrote: >>> On 20/02/2012 09:24, Mark Morgan Lloyd wrote: >>>> In the same program (running on Linux), the Synedit font appears to >>>> force itself to a generic Sans at runtime, irrespective of what is >>>> actually selected (e.g. Monospace). Again, this is OK up to around >>>> 0.9.26. >>> >>> No idea... You set the font via the object inspector? >> >> Yes. >> >>> If you put a label in with the same font. does that work? >> >> Yes. >> >>> Have you tried other fonts? >> >> Yes, it's a general problem. >> >>> Are they in that name-15-*-* format ? >> >> That was available in gtk1, but appears to not be in gtk2 or Qt's font >> dialog (although it would be nice to have it as an option). > > Since last week trunk gtk2 is fixed and it uses pango fonts everywhere. > Fonts are consistent now (at least with qt under linux). > 0.9.30.XX will stay as it is, don't think that it will be merged there. Thanks, trunk with 2.7.1 compiling for gtk2 now looks OK. i can live with that :-)

Also, note that it's not perfect because we still support gtk2-2.8. With post 1.0 we will move minimum gtk2 requirement to 2.10 or 2.16 ...

zeljko

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20120221/904af3ac/attachment-0001.html>

Reply by email