Discussion:
Font names shown in the respective font
George Birbilis
2006-12-07 20:42:36 UTC
Permalink
It would be nice if the "font/name" property editor (dropdown list) would
show the font names written in the respective font. That could be an
optional IDE setting (probably disabled or enabled by default depending on
how heavy or light it would be in resources at runtime).

Same could be done at the Font selection dialog (the dialog could have such
property and the IDE could set that from the value of the above mentioned
IDE setting) if it's not a standard system dialog that cannot be changed to
do so.

That is cause most people aren't graphic designers to know from a font name
what a font looks like. At the font dialog there is a preview text shown,
but you have to select the fonts one-by-one to see it (not very helpful for
a quick overview).

Else at least there could be some IDE tool to show a given phrase (the same
one so that one can compare how it looks) in all the different fonts in a
rich text box [or SynEdit] or something, maybe with a gap line in between
(or less gap if some panel+scrollpane is used instead of a textbox). The
default phrase could be ABC...Z0...9 and also maybe contain other standard
characters.

----------------
George Birbilis (***@kagi.com)
Computer & Informatics Engineer
Microsoft MVP J# for 2004-2006
Borland "Spirit of Delphi"
++ QuickTime, Delphi, ActiveX, .NET components ++
http://www.kagi.com/birbilis
++ Robotics ++
http://www.mech.upatras.gr/~Robotics
http://www.mech.upatras.gr/~robgroup





_____

avast! Antivirus <http://www.avast.com> : Outbound message clean.


Virus Database (VPS): 0653-5, 05/12/2006
Tested on: 7/12/2006 10:42:36 ??
avast! - copyright (c) 1988-2006 ALWIL Software.
Graeme Geldenhuys
2006-12-08 07:12:52 UTC
Permalink
[I agree with others, your Reply-To address is getting annoying!]
Post by George Birbilis
Same could be done at the Font selection dialog (the dialog could have such
property and the IDE could set that from the value of the above mentioned
IDE setting) if it's not a standard system dialog that cannot be changed to
do so.
Doesn't Lazarus just call the Font selection dialog of the underlying
widget set, which means that it is out of Lazarus controls. To get
what you want, we would have to create our own custom Font Selection
Dialog. Though not hard to do, but more effort.
--
Graeme Geldenhuys

There's no place like S34° 03.168' E018° 49.342'
George Birbilis
2006-12-08 19:59:08 UTC
Permalink
Post by Graeme Geldenhuys
[I agree with others, your Reply-To address is getting annoying!]
Let's see if this fixes the problem (do you reply to ***@kagi.com with
this e-mail ok or to other one)?
Post by Graeme Geldenhuys
Post by George Birbilis
Same could be done at the Font selection dialog (the dialog
could have
Post by George Birbilis
such property and the IDE could set that from the value of
the above
Post by George Birbilis
mentioned IDE setting) if it's not a standard system dialog that
cannot be changed to do so.
Doesn't Lazarus just call the Font selection dialog of the
underlying widget set, which means that it is out of Lazarus
controls. To get what you want, we would have to create our
own custom Font Selection Dialog. Though not hard to do, but
more effort.
Ignoring the font dialog since it's another thing (it has preview which
covers the needs of the user a bit), the font name property editor (it shows
a drop-down list, could show an owner-drawn one instead) would be the thing
to change (once for all platforms I suppose). BTW, speaking of many
platforms, how does Lazarus support "fonts" crossplatform? (does it delegate
the burden onto the OS ? [since there is raster/bitmap fonts, TrueType,
OpenType, PostScript etc. fonts that one could support)

----------------
George Birbilis (***@kagi.com)
Computer & Informatics Engineer
Microsoft MVP J# for 2004-2006
Borland "Spirit of Delphi"
++ QuickTime, Delphi, ActiveX, .NET components ++
http://www.kagi.com/birbilis
++ Robotics ++
http://www.mech.upatras.gr/~Robotics
http://www.mech.upatras.gr/~robgroup




_____

avast! Antivirus <http://www.avast.com> : Outbound message clean.


Virus Database (VPS): 0653-5, 05/12/2006
Tested on: 8/12/2006 9:59:08 ??
avast! - copyright (c) 1988-2006 ALWIL Software.
Felipe Monteiro de Carvalho
2006-12-08 20:11:41 UTC
Permalink
Post by George Birbilis
BTW, speaking of many
platforms, how does Lazarus support "fonts" crossplatform? (does it delegate
the burden onto the OS ? [since there is raster/bitmap fonts, TrueType,
OpenType, PostScript etc. fonts that one could support)
Each widgetset implements a function called CreateFontIndirect. This
together with SelectObject and adequate code on the DC functions forms
Font support. So basically font support is written as a
reimplementation of several winapi functions that become available on
LCLIntf unit.

Those functions map font handling to the underlying widgetset, so it´s
up to him to actually do the drawing. So Lazarus supports whichever
fonts the underlying widgetset supports.
--
Felipe Monteiro de Carvalho
Graeme Geldenhuys
2006-12-11 06:59:43 UTC
Permalink
Post by George Birbilis
Post by Graeme Geldenhuys
[I agree with others, your Reply-To address is getting annoying!]
this e-mail ok or to other one)?
It works perfectly now. :-)
--
Graeme Geldenhuys

There's no place like S34° 03.168' E018° 49.342'
George Birbilis
2006-12-11 19:44:29 UTC
Permalink
Post by George Birbilis
Ignoring the font dialog since it's another thing (it has
preview which covers the needs of the user a bit), the font
name property editor (it shows a drop-down list, could show
an owner-drawn one instead) would be the thing to change
(once for all platforms I suppose). BTW, speaking of many
platforms, how does Lazarus support "fonts" crossplatform?
(does it delegate the burden onto the OS ? [since there is
raster/bitmap fonts, TrueType, OpenType, PostScript etc.
fonts that one could support)
I know in Delphi one uses owner-drawn list to draw their own items (in fact
I had suggested Delphi Object Inspector do that many years ago at Delphi
newsgroups, when we had plain text dropdown lists even for color names), but
what is used in Lazarus? Is it the same scheme or something that is maybe
more crossplatform? Any online text about it?

----------------
George Birbilis (***@kagi.com)
Computer & Informatics Engineer
Microsoft MVP J# for 2004-2006
Borland "Spirit of Delphi"
++ QuickTime, Delphi, ActiveX, .NET components ++
http://www.kagi.com/birbilis
++ Robotics ++
http://www.mech.upatras.gr/~Robotics
http://www.mech.upatras.gr/~robgroup




_____

avast! Antivirus <http://www.avast.com> : Outbound message clean.


Virus Database (VPS): 0653-5, 05/12/2006
Tested on: 11/12/2006 9:44:29 ??
avast! - copyright (c) 1988-2006 ALWIL Software.
Mattias Gaertner
2006-12-12 21:27:00 UTC
Permalink
On Mon, 11 Dec 2006 21:44:29 +0200
Post by George Birbilis
Post by George Birbilis
Ignoring the font dialog since it's another thing (it has
preview which covers the needs of the user a bit), the font
name property editor (it shows a drop-down list, could show
an owner-drawn one instead) would be the thing to change
(once for all platforms I suppose). BTW, speaking of many
platforms, how does Lazarus support "fonts" crossplatform?
(does it delegate the burden onto the OS ? [since there is
raster/bitmap fonts, TrueType, OpenType, PostScript etc.
fonts that one could support)
I know in Delphi one uses owner-drawn list to draw their own items
(in fact I had suggested Delphi Object Inspector do that many years
ago at Delphi newsgroups, when we had plain text dropdown lists even
for color names), but what is used in Lazarus? Is it the same scheme
or something that is maybe more crossplatform? Any online text about
it?
The LCL provides a Delphi compatible TFont.
The widgetsets searches the nearest font.
The gtk interface also understands XLD font names, where the
font name is a 15 attribute filter.
So, basically you can select every available font under windows and
under gtk/X. But they are not cross platform.

The OI combobox is custom drawn, so it would be possible to draw every
font. But afaik this would be quite slow and needs a lot of resources.

I'm not an font expert, so I don't know, what properties are needed by
TFont to make it cross platform (if this is possible).

Mattias
Michael Van Canneyt
2006-12-12 22:06:30 UTC
Permalink
Post by Mattias Gaertner
On Mon, 11 Dec 2006 21:44:29 +0200
Post by George Birbilis
Post by George Birbilis
Ignoring the font dialog since it's another thing (it has
preview which covers the needs of the user a bit), the font
name property editor (it shows a drop-down list, could show
an owner-drawn one instead) would be the thing to change
(once for all platforms I suppose). BTW, speaking of many
platforms, how does Lazarus support "fonts" crossplatform?
(does it delegate the burden onto the OS ? [since there is
raster/bitmap fonts, TrueType, OpenType, PostScript etc.
fonts that one could support)
I know in Delphi one uses owner-drawn list to draw their own items
(in fact I had suggested Delphi Object Inspector do that many years
ago at Delphi newsgroups, when we had plain text dropdown lists even
for color names), but what is used in Lazarus? Is it the same scheme
or something that is maybe more crossplatform? Any online text about
it?
The LCL provides a Delphi compatible TFont.
The widgetsets searches the nearest font.
The gtk interface also understands XLD font names, where the
font name is a 15 attribute filter.
So, basically you can select every available font under windows and
under gtk/X. But they are not cross platform.
The OI combobox is custom drawn, so it would be possible to draw every
font. But afaik this would be quite slow and needs a lot of resources.
I'm not an font expert, so I don't know, what properties are needed by
TFont to make it cross platform (if this is possible).
You would need a font mapper. X (2 kinds of fonts), PostScript (also 2 kinds),
LateX and friends (many kinds), Motif layer, TTF font server, FreeType.
they all use some kind of font mapper, mapping name x to name y.
Usually they work with some text file containing the mapping.

But that is as far as you'll get. I think it's an illusion trying to get this
to work 100% cross-platform.

In my opinon, you can install a global hook:
TransformFont
Which can be set by some extra component which does font mapping; Prior to
selecting a system font, this hook can be called if it's set. it's then
up to the user to drop such a fontmapper on one of his forms.
You could implement a default one which does some basic translations
based on some known map files.

Michael.
Graeme Geldenhuys
2006-12-13 06:50:49 UTC
Permalink
Post by Mattias Gaertner
I'm not an font expert, so I don't know, what properties are needed by
TFont to make it cross platform (if this is possible).
I have to agree, that it is quite difficult to handle fonts on
multiple platforms. fpGUI handles this in a very rudimentary way doing
some basic mapping.

TGfxFontClass = (fcSerif, fcSansSerif, fcTypewriter, fcDingbats);

Querying the font based in any of these 4 font classes, will work fine
cross-platform. Specifying a specific font will not be 100%
cross-platform.

... Each platform will implement how the font class maps to a font.
Here is the X11 code ...

class function TX11Font.GetDefaultFontName(const AFontClass:
TGfxFontClass): String;
const
FontNames: array[TGfxFontClass] of String = (
'times', 'bitstream vera sans', 'courier', 'symbol');
begin
Result := FontNames[AFontClass];
end;


Fonts seem to be a tricky thing to handle. I haven't looked yet, but
anybody know how Qt handles this on multiple platforms?
--
Graeme Geldenhuys

There's no place like S34° 03.168' E018° 49.342'
George Birbilis
2006-12-13 10:23:34 UTC
Permalink
This post might be inappropriate. Click to display it.
Mattias Gaertner
2006-12-13 20:15:44 UTC
Permalink
On Wed, 13 Dec 2006 12:23:34 +0200
Post by George Birbilis
Post by Mattias Gaertner
Post by Mattias Gaertner
I'm not an font expert, so I don't know, what properties
are needed by
Post by Mattias Gaertner
TFont to make it cross platform (if this is possible).
I have to agree, that it is quite difficult to handle fonts
on multiple platforms. fpGUI handles this in a very
rudimentary way doing some basic mapping.
TGfxFontClass = (fcSerif, fcSansSerif, fcTypewriter, fcDingbats);
Only enums?
How can a user define a font not in the enums?
Post by George Birbilis
Post by Mattias Gaertner
Querying the font based in any of these 4 font classes, will
work fine cross-platform. Specifying a specific font will
not be 100% cross-platform.
... Each platform will implement how the font class maps to a font.
Here is the X11 code ...
TGfxFontClass): String;
const
FontNames: array[TGfxFontClass] of String = (
'times', 'bitstream vera sans', 'courier', 'symbol'); begin
Result := FontNames[AFontClass];
end;
Fonts seem to be a tricky thing to handle. I haven't looked
yet, but anybody know how Qt handles this on multiple platforms?
What I need to do is
1) get list of available font names (this seems to already be done by
the TFont property editor used at the Object Inspector)
Yes. This can be quite slow.
Post by George Birbilis
2) create onwer drawn drop-down list (instead of the standard one
used now at Tfont property editor)
Easy. See the TColorPropertyEditor for an example.
Post by George Birbilis
3) when dropdown list / combobox calls me back to draw an item (it
should do that not for all its items, but only for the visible ones
AFAIK this is the case the gtk and the win32 interface.
Post by George Birbilis
3.1) given that item text (which is a font name), and a font size
(say 8 [whatever size the rest of the OI text uses at that time -
maybe this is an IDE option?]),
Nah. The IDE uses the current theme. The text size on a button can be
different than the title or the size in a TMemo or TLabel.
Post by George Birbilis
measure the text with that font and
size the item or the whole list (if dd list supports changing its
dropdown size to fit the biggest item or in generally be wider than
the edit box / label that is placed above the dropdown [recent dd
lists in Windows GUI seem to do that, but not sure if they're the
classic combobox windows control or other new impl by MS])
Resizing the combobox dropdown works under gtk not very well, but it
works.
Post by George Birbilis
3.2) draw the item (will result in cropping it if at 3.1 no resize of
list was done)
For 3.1 & 3.2 I could use an autosizing TLabel (is it
cross-platform?) I suppose if TFont class doesn't have measure method
No. Just use the Canvas methods to measure and paint the font name.
Post by George Birbilis
Will also need to look the Tcolor property editor to do how it does
the owner-drawn dropdown list
Mattias

P.S.: Can you tell your virus scanner to write less spam?
George Birbilis
2006-12-14 08:28:01 UTC
Permalink
Post by Mattias Gaertner
Post by George Birbilis
Post by Graeme Geldenhuys
Fonts seem to be a tricky thing to handle. I haven't looked yet,
but anybody know how Qt handles this on multiple platforms?
What I need to do is
1) get list of available font names (this seems to already be done by
the TFont property editor used at the Object Inspector)
Yes. This can be quite slow.
I'll try to do it once at creation, instead of at each update (I hope the
Object Inspector doesn't recreate the property editors at each refresh, does
it?), a thing is though if I could hook into the system to get notification
for new fonts added (maybe even Windows doesn't provide such [unless
possibly one asks for a shell filesystem change notification for the windows
fonts folder - assuming one can ask the system where that "folder" is, if
it's not just some virtual folder view in explorer as afaik I think it is])
Post by Mattias Gaertner
Post by George Birbilis
Post by Graeme Geldenhuys
Post by Mattias Gaertner
I'm not an font expert, so I don't know, what properties
are needed by
Post by Mattias Gaertner
TFont to make it cross platform (if this is possible).
I have to agree, that it is quite difficult to handle fonts on
multiple platforms. fpGUI handles this in a very rudimentary way
doing some basic mapping.
TGfxFontClass = (fcSerif, fcSansSerif, fcTypewriter, fcDingbats);
Only enums?
How can a user define a font not in the enums?
Maybe one can just say what font family they want there? A bit limited
indeed
Post by Mattias Gaertner
Post by George Birbilis
3) when dropdown list / combobox calls me back to draw an item (it
should do that not for all its items, but only for the
visible ones if
AFAIK this is the case the gtk and the win32 interface.
I guess I can return immediately for items that our out of view (the
dropdown list should have a property saying how many items the drop-down
list shows I suppose) myself (will have to add a test check to see if they
callme back to draw each item [they might be calling me back the first time
to measure each item to make the dropdown list have enough width to fit all
items in case the user scrolls in it, but I might heuristically decide to
return the length of the biggest fontname times some fixed value - since the
biggest length is the one when you type something in monospace style])
Post by Mattias Gaertner
Post by George Birbilis
3.1) given that item text (which is a font name), and a
font size (say
Post by George Birbilis
8 [whatever size the rest of the OI text uses at that time - maybe
this is an IDE option?]),
Nah. The IDE uses the current theme. The text size on a
button can be different than the title or the size in a TMemo
or TLabel.
I'd expect the IDE options to also allow setting (or overriding the system
defaults) the font size for the IDE
Post by Mattias Gaertner
Post by George Birbilis
3.2) draw the item (will result in cropping it if at 3.1 no
resize of
Post by George Birbilis
list was done)
For 3.1 & 3.2 I could use an autosizing TLabel (is it
cross-platform?) I suppose if TFont class doesn't have
measure method
No. Just use the Canvas methods to measure and paint the font name.
Depends on how complex it will be, could instead copy the canvas of that
label into the ownerdrawn item if I see it's easier (if one reuses the same
Tlabel instance it should be quick and clean in resources)
Post by Mattias Gaertner
P.S.: Can you tell your virus scanner to write less spam?
Unfortunately I've forgotten its pwd, will try to uninstall/reinstall it :o(

----------------
George Birbilis (***@kagi.com)
Computer & Informatics Engineer
Microsoft MVP J# for 2004-2006
Borland "Spirit of Delphi"
++ QuickTime, Delphi, ActiveX, .NET components ++
http://www.kagi.com/birbilis
++ Robotics ++
http://www.mech.upatras.gr/~Robotics
http://www.mech.upatras.gr/~robgroup




_____

avast! Antivirus <http://www.avast.com> : Outbound message clean.


Virus Database (VPS): 0657-0, 12/12/2006
Tested on: 14/12/2006 10:28:01 p?
avast! - copyright (c) 1988-2006 ALWIL Software.
Mattias Gaertner
2006-12-14 09:38:13 UTC
Permalink
On Thu, 14 Dec 2006 10:28:01 +0200
Post by George Birbilis
Post by Mattias Gaertner
Post by George Birbilis
Post by Graeme Geldenhuys
Fonts seem to be a tricky thing to handle. I haven't looked yet,
but anybody know how Qt handles this on multiple platforms?
What I need to do is
1) get list of available font names (this seems to already be done
by the TFont property editor used at the Object Inspector)
Yes. This can be quite slow.
I'll try to do it once at creation, instead of at each update (I hope
the Object Inspector doesn't recreate the property editors at each
refresh, does it?),
Not at every update, but frequently.
Post by George Birbilis
a thing is though if I could hook into the system
to get notification for new fonts added (maybe even Windows doesn't
provide such [unless possibly one asks for a shell filesystem change
notification for the windows fonts folder - assuming one can ask the
system where that "folder" is, if it's not just some virtual folder
view in explorer as afaik I think it is])
Post by Mattias Gaertner
Post by George Birbilis
Post by Graeme Geldenhuys
Post by Mattias Gaertner
I'm not an font expert, so I don't know, what properties
are needed by
Post by Mattias Gaertner
TFont to make it cross platform (if this is possible).
I have to agree, that it is quite difficult to handle fonts on
multiple platforms. fpGUI handles this in a very rudimentary way
doing some basic mapping.
TGfxFontClass = (fcSerif, fcSansSerif, fcTypewriter,
fcDingbats);
Only enums?
How can a user define a font not in the enums?
Maybe one can just say what font family they want there? A bit limited
indeed
Post by Mattias Gaertner
Post by George Birbilis
3) when dropdown list / combobox calls me back to draw an item (it
should do that not for all its items, but only for the
visible ones if
AFAIK this is the case the gtk and the win32 interface.
I guess I can return immediately for items that our out of view (the
dropdown list should have a property saying how many items the
drop-down list shows I suppose) myself (will have to add a test check
to see if they callme back to draw each item [they might be calling
me back the first time to measure each item to make the dropdown list
have enough width to fit all items in case the user scrolls in it,
but I might heuristically decide to return the length of the biggest
fontname times some fixed value - since the biggest length is the one
when you type something in monospace style])
Post by Mattias Gaertner
Post by George Birbilis
3.1) given that item text (which is a font name), and a
font size (say
Post by George Birbilis
8 [whatever size the rest of the OI text uses at that time - maybe
this is an IDE option?]),
Nah. The IDE uses the current theme. The text size on a
button can be different than the title or the size in a TMemo
or TLabel.
I'd expect the IDE options to also allow setting (or overriding the
system defaults) the font size for the IDE
Post by Mattias Gaertner
Post by George Birbilis
3.2) draw the item (will result in cropping it if at 3.1 no
resize of
Post by George Birbilis
list was done)
For 3.1 & 3.2 I could use an autosizing TLabel (is it
cross-platform?) I suppose if TFont class doesn't have
measure method
No. Just use the Canvas methods to measure and paint the font name.
Depends on how complex it will be, could instead copy the canvas of
that label into the ownerdrawn item if I see it's easier (if one
reuses the same Tlabel instance it should be quick and clean in
resources)
Copying canvas in this way is not supported under gtk.
Post by George Birbilis
Post by Mattias Gaertner
P.S.: Can you tell your virus scanner to write less spam?
Unfortunately I've forgotten its pwd, will try to uninstall/reinstall it :o(
Mattias
George Birbilis
2006-12-14 10:57:27 UTC
Permalink
Post by George Birbilis
Post by George Birbilis
Post by Mattias Gaertner
Post by George Birbilis
1) get list of available font names (this seems to
already be done
Post by George Birbilis
Post by Mattias Gaertner
Post by George Birbilis
by the TFont property editor used at the Object Inspector)
Yes. This can be quite slow.
I'll try to do it once at creation, instead of at each
update (I hope
Post by George Birbilis
the Object Inspector doesn't recreate the property editors at each
refresh, does it?),
Not at every update, but frequently.
Shouldn't the OI keep a live pool of property editors then? (since they're
created given a property classname [or was it class], not a certain
instance). That way the font property editor wouldn't have to be recreated
since the OI would grab the same instance from the pool.

The pool would be only for the OI to use (are other tools in the IDE that
might want to use property editors? Then that pool should be more generally
accessible by the IDE code)

Btw, do I guess wrong that only one OI can be visible? is there a
requirement for many simultaneous views of the OI in the future? [say like
how split window works in Word by dragging that small knob over the top
arrow of the scrollbar - imagine being able to split the OI in two or more
separately scrollable views]

The pool could contain more than one prop editor of the same type if there's
such need and used ones would be removed from the pool by the using code,
then returned back to the pool when done (that's better than locking used
itmes cause the pool size remains small for easier search - search only the
free ones to use - plus if using code forgets to unlock would keep the pool
big - instead if it forgets to return to pool not much harm done to the
pool). Initially the pool would start up empty. When asked for items it
would work like a class factory, allocate the prop editors asked for and
return them. When using code is done using them, will (most probably)
return'em back to the pool. The pool (a hashtable) would have a max buckets
(how many types of prop editors it can keep) setting maybe and maybe also a
max bucket size (how many live instances of the same prop editor it can
keep)

Or does it do already like above?

The pool logic could be made generic (via some interface and/or ancestor
class) to reuse at other places (say for reusing component editors [although
that's a bit more risky since not-well written comp editors might need to
destroy and recreate after setting another component instance to them to
edit] etc.). Is some hashtable class available at Laz now?

Cheers,
George

----------------
George Birbilis (***@kagi.com)
Computer & Informatics Engineer
Microsoft MVP J# for 2004-2006
Borland "Spirit of Delphi"
++ QuickTime, Delphi, ActiveX, .NET components ++
http://www.kagi.com/birbilis
++ Robotics ++
http://www.mech.upatras.gr/~Robotics
http://www.mech.upatras.gr/~robgroup




_____

avast! Antivirus <http://www.avast.com> : Outbound message clean.


Virus Database (VPS): 0657-0, 12/12/2006
Tested on: 14/12/2006 12:57:27 ??
avast! - copyright (c) 1988-2006 ALWIL Software.
Mattias Gaertner
2006-12-14 20:49:12 UTC
Permalink
On Thu, 14 Dec 2006 12:57:27 +0200
Post by George Birbilis
Post by George Birbilis
Post by George Birbilis
Post by Mattias Gaertner
Post by George Birbilis
1) get list of available font names (this seems to
already be done
Post by George Birbilis
Post by Mattias Gaertner
Post by George Birbilis
by the TFont property editor used at the Object Inspector)
Yes. This can be quite slow.
I'll try to do it once at creation, instead of at each
update (I hope
Post by George Birbilis
the Object Inspector doesn't recreate the property editors at each
refresh, does it?),
Not at every update, but frequently.
Shouldn't the OI keep a live pool of property editors then? (since
they're created given a property classname [or was it class], not a
certain instance).
Property editors are created for instances, not classes. For example
everytime you add a component to the multi selection, some property
editors vanish from the list and the others can change their attributes.
Post by George Birbilis
That way the font property editor wouldn't have to
be recreated since the OI would grab the same instance from the pool.
At the moment all property editors are fast created/destroyed, so no
need for a pool. BTW, it would be more efficient if the property editor
code creates a global pool itself for its data.
Post by George Birbilis
The pool would be only for the OI to use (are other tools in the IDE
that might want to use property editors? Then that pool should be
more generally accessible by the IDE code)
In fact, the OI uses TPropertyGrids. They create the property editors.
And property editors are used by all RTTI controls and at other places
in the IDE.
Post by George Birbilis
Btw, do I guess wrong that only one OI can be visible?
The IDE only uses one OI.
But of course the OI form can be created as many times, as you want.
Just create one TPropertyHook instance per OI.
Post by George Birbilis
is there a
requirement for many simultaneous views of the OI in the future? [say
like how split window works in Word by dragging that small knob over
the top arrow of the scrollbar - imagine being able to split the OI
in two or more separately scrollable views]
At least I have no plans to do that.
Post by George Birbilis
The pool could contain more than one prop editor of the same type if
there's such need and used ones would be removed from the pool by the
using code, then returned back to the pool when done (that's better
than locking used itmes cause the pool size remains small for easier
search - search only the free ones to use - plus if using code
forgets to unlock would keep the pool big - instead if it forgets to
return to pool not much harm done to the pool). Initially the pool
would start up empty. When asked for items it would work like a class
factory, allocate the prop editors asked for and return them. When
using code is done using them, will (most probably) return'em back to
the pool. The pool (a hashtable) would have a max buckets (how many
types of prop editors it can keep) setting maybe and maybe also a max
bucket size (how many live instances of the same prop editor it can
keep)
Or does it do already like above?
No. It does not need yet such a pool, because the speed is ok and the
overhead of typinfo functions is still bigger than the
creation/destruction of property editors. So, before you start such a
generic pool, add a pool for typinfo functions.
Post by George Birbilis
The pool logic could be made generic (via some interface and/or
ancestor class) to reuse at other places (say for reusing component
editors [although that's a bit more risky since not-well written comp
editors might need to destroy and recreate after setting another
component instance to them to edit] etc.). Is some hashtable class
available at Laz now?
Yes, several. Depends on what you want to do.


Mattias
Micha Nelissen
2006-12-14 20:45:18 UTC
Permalink
Post by Graeme Geldenhuys
TGfxFontClass = (fcSerif, fcSansSerif, fcTypewriter, fcDingbats);
I think a higher abstraction will be better. Something like a list of
names that map to (font name, size, style, charset) per widgetset. We
currently have one: "default". But it would be nice if the user could
add something like "header" (bigger), or "error" (which would be red),
etc. Then TControl.Font.Name := 'header' would set all font properties,
and the application user may override this name to have a better font
name / size / style for him (if the default for this name does not
exist, for example).

Micha
Mattias Gaertner
2006-12-14 20:51:48 UTC
Permalink
On Thu, 14 Dec 2006 21:45:18 +0100
Post by Micha Nelissen
Post by Graeme Geldenhuys
TGfxFontClass = (fcSerif, fcSansSerif, fcTypewriter, fcDingbats);
I think a higher abstraction will be better. Something like a list of
names that map to (font name, size, style, charset) per widgetset. We
currently have one: "default". But it would be nice if the user could
add something like "header" (bigger), or "error" (which would be red),
etc. Then TControl.Font.Name := 'header' would set all font
properties, and the application user may override this name to have a
better font name / size / style for him (if the default for this name
does not exist, for example).
About 'header': Most often the font name will be the same, but the size
or the style will be different.
Maybe better:
AControl.Font.Assign(GetDefaultHeaderFont)

Mattias
Micha Nelissen
2006-12-14 21:08:31 UTC
Permalink
Post by Mattias Gaertner
About 'header': Most often the font name will be the same, but the size
or the style will be different.
AControl.Font.Assign(GetDefaultHeaderFont)
Yes, ok, but my point was that the user could make up his own needs for
his/her application and use those. 'header' was just an example, and
defining a function like this seems like a hardcoded way.

Maybe GetDefaultFont(dfHeader), with additionally RegisterFont(....)
which returns an integer to you can pass to GetDefaultFont.

Not sure where this 'mapping' could be stored, maybe in the project
(unit) resources ?

Micha
Graeme Geldenhuys
2006-12-15 07:47:38 UTC
Permalink
I suppose you could have something like this....

TNamedFontItem = class
private
....
public
constructor Create(AFontID, AFontDesc : string);
property FontID : string ....
property FontDesc : string ....
end;

The above class is used for the mappings. You need to store a list of
mappings somewhere. In fpGUI I could to this in the Style class. In
Lazarus this would maybe live in TApplication or TScreen. For
example: FNamedFonts : TList;

You would also need some methods to work with the mappings... and
return a TFont.

function GetNamedFontDesc(AFontID : string) : string;
function CreateNamedFont(AFontID : string) : TFont;
procedure SetNamedFont(AFontID, AFontDesc : string);

You can then register whatever font mappings (Named Fonts) you need.

eg:
SetNamedFont('Label1', 'Arial-10');
SetNamedFont('Label2', 'Arial-10:bold');
SetNamedFont('Edit1', 'Arial-10');
SetNamedFont('Edit2', 'Courier New-10');
SetNamedFont('List', 'Arial-10');
SetNamedFont('Grid', 'Arial-9');
SetNamedFont('GridHeader', 'Arial-9:bold');
SetNamedFont('Menu', 'Arial-10');


Then in the application do this...

AControl.Font.Assign(gGetFont('#Label1'));

The '#' indicates the Named Font. Without a '#' would indicate the
exact font name and no lookup would be needed (tip thanks to LPTK
project).
I guess you could remove the '#' bit as well, but I think it is a good
idea, so you can differentiate between named fonts and actual font
names - and use a consistent method (gGetFont) throughout your
application for assigning fonts.

Regards,
- Graeme -
Post by Micha Nelissen
Post by Mattias Gaertner
About 'header': Most often the font name will be the same, but the size
or the style will be different.
AControl.Font.Assign(GetDefaultHeaderFont)
Yes, ok, but my point was that the user could make up his own needs for
his/her application and use those. 'header' was just an example, and
defining a function like this seems like a hardcoded way.
Maybe GetDefaultFont(dfHeader), with additionally RegisterFont(....)
which returns an integer to you can pass to GetDefaultFont.
Not sure where this 'mapping' could be stored, maybe in the project
(unit) resources ?
Micha
_________________________________________________________________
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives
--
Graeme Geldenhuys

There's no place like S34° 03.168' E018° 49.342'
George Birbilis
2006-12-13 10:05:44 UTC
Permalink
Post by Mattias Gaertner
The LCL provides a Delphi compatible TFont.
The widgetsets searches the nearest font.
The gtk interface also understands XLD font names, where the
font name is a 15 attribute filter.
So, basically you can select every available font under
windows and under gtk/X. But they are not cross platform.
The OI combobox is custom drawn, so it would be possible to
draw every font. But afaik this would be quite slow and needs
a lot of resources.
I'm not an font expert, so I don't know, what properties are
needed by TFont to make it cross platform (if this is possible).
The thing is that you have to "measure" the string to calculate its
dimensions given the font family, text size, font style etc. which I don't
remember if TFont class provides itself in Delphi or if one had to use
Windows calls for it (maybe it does provide). I was also thinking that I
could reuse in the background an autosizing TLabel (there was such I think
in Delphi) and set the text to it (=the font name itself) and the font name
and keep some same font size, then tell it to size itself (without adding it
to a parent - hope it doesn't play it clever in that case and do nothing),
then ask it it's dimensions (so that I avoid messing with the font measuring
calls if they're complex)

I wonder why it should be a resource hog if fonts are implemented ok in Laz
and in the OS or window manager. I've done it in JFC/Swing many years ago
and it played very nice (JFC/Swing wasn't the most optimized lib back then
[it still itsn't]). Also, old Macs were doing that (back in 1997) and didn't
have problems. Anyway it will be a property to turn on/off. Think it's
interesting exercise for me to get more comfortable with Laz object
inspector code, so I'll try to give it a try

Another thing I'd like to add is wiring option on the form designer, maybe
similar to IBM's VisualAge or even simpler

Cheers,
George

----------------
George Birbilis (***@kagi.com)
Computer & Informatics Engineer
Microsoft MVP J# for 2004-2006
Borland "Spirit of Delphi"
++ QuickTime, Delphi, ActiveX, .NET components ++
http://www.kagi.com/birbilis
++ Robotics ++
http://www.mech.upatras.gr/~Robotics
http://www.mech.upatras.gr/~robgroup




_____

avast! Antivirus <http://www.avast.com> : Outbound message clean.


Virus Database (VPS): 0657-0, 12/12/2006
Tested on: 13/12/2006 12:05:43 ??
avast! - copyright (c) 1988-2006 ALWIL Software.
Marc Weustink
2006-12-13 10:33:57 UTC
Permalink
Post by Mattias Gaertner
On Mon, 11 Dec 2006 21:44:29 +0200
Post by George Birbilis
Post by George Birbilis
Ignoring the font dialog since it's another thing (it has
preview which covers the needs of the user a bit), the font
name property editor (it shows a drop-down list, could show
an owner-drawn one instead) would be the thing to change
(once for all platforms I suppose). BTW, speaking of many
platforms, how does Lazarus support "fonts" crossplatform?
(does it delegate the burden onto the OS ? [since there is
raster/bitmap fonts, TrueType, OpenType, PostScript etc.
fonts that one could support)
I know in Delphi one uses owner-drawn list to draw their own items
(in fact I had suggested Delphi Object Inspector do that many years
ago at Delphi newsgroups, when we had plain text dropdown lists even
for color names), but what is used in Lazarus? Is it the same scheme
or something that is maybe more crossplatform? Any online text about
it?
The LCL provides a Delphi compatible TFont.
The widgetsets searches the nearest font.
The gtk interface also understands XLD font names, where the
font name is a 15 attribute filter.
So, basically you can select every available font under windows and
under gtk/X. But they are not cross platform.
The OI combobox is custom drawn, so it would be possible to draw every
font. But afaik this would be quite slow and needs a lot of resources.
I think only the fonts displayed need to be drawn (so max 8 ?) :)

But these things should be well thought when implemented.

I've installed over 1000 fonts and not all software displaying fonts has
implemented this properly (IE, they try to load them all)

Marc
l***@star-dev.com
2006-12-13 16:01:33 UTC
Permalink
Post by Mattias Gaertner
I'm not an font expert, so I don't know, what properties are needed by
TFont to make it cross platform (if this is possible).
Mattias
Hope it helps:

http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&cat_id=FontDownloads
http://www.openfontlibrary.org/
http://unifont.org/fontguide/

mramirez
Loading...