Jump to content
Sign in to follow this  
XylemFlow

Font Family selector component needed for FMX

Recommended Posts

I'm looking for a component or code sample that allows a user to select a font family. An example is shown attached, which is taken from Inkscape. I already have code to collect a list of the installed fonts from Windows. The selector should show the list of fonts as well as a sample using the actual font. It should also have a search functionality that allows you to type in and it will filter the list based on the input. I would have thought that something similar would be included. I've already made some progress with making my own using a TListBox with custom styles, but thought I would ask in case something is already available online?

FontFamilySelector.png

Share this post


Link to post

I've made some progress on this, which you can see in the attached demo. I've made my own font selector which automatically collects installed fonts from Windows, has autocomplete when typing and shows each font in its own font for preview.

 

However, there are a couple of issues that I could use some help with.

  1. There's quite a lot of lag sometimes when scrolling through the list using the scrollbar. It will often lock up and take several seconds to recover, during which time the CPU is fully occupied with something. I do have 528 fonts in the list, which is likely part of the issue, but similar font selectors in other apps, such as Inkscape don't have a similar issue. If I comment out the code for setting the font family of the list items (lines 109-111 of FontSelector.pas), then there's no such issue.
  2. I'd like the cursor to show crDefault when over the dropdown button instead of the text bar. I think this is due to the parent of the TButton being the TEdit.

Any suggestions for solving these issues or other general improvements are welcome.

FontSelector.zip

Edited by XylemFlow

Share this post


Link to post

I've solved some of the issues with the font selector. The cursor now changes correctly. I'm quite happy with it now. The locking issue still happens but I discovered that this was not due to the number of fonts in the list but a particular font that is slow to render that I have installed (Surfing Capital). If I remove that font from the list then all is fine. I found that this font is also causing issues with the font selectors in other apps such as MS Paint, so it may not be worth doing anything about.

FontSelector_v2.zip

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×