Font Drop List

Started by honkinberry, October 13, 2011, 10:15:51 AM

Previous topic - Next topic

honkinberry

I'm having a doozy of a time trying to work with a ComboBox with Style 8 - Font Drop List.
(And on a tangent note, Style 9 - Font Simple List doesn't seem to work at all).

While it's a wonderful idea and looks cool, I'm having incredible difficulty using it for actually selecting a font.
Further, I'd like the ability to trim the list a bit, removing fonts such as the @-preceded ones.

But for instance fonts with the Swiss721 family that ship with AutoCAD:
The entries in the list do not correspond with the entries in HKLM/Software/Microsoft/Windows NT/Fonts, where I might be able to look up the TTF filename.
They do seem to match up with the entries in HKCU/Software/Microsoft/Shared Tools/Panose.
But the AutoCAD Style command doesn't like these values -- for instance "Swis721 Blk BT".

Is there something I'm missing?  It sure would be cool if the ItemData for the selected item had the font filename all ready for me, oh that would be so sweet!

Many thanks for any help on this!

--J

velasquez

Very good idea to remove fonts from the list.
Mainly type shx fonts that are not shown as they are.

owenwengerd

What exactly do you mean by "@-preceded" fonts?  Which versions of OpenDCL, AutoCAD, and Windows are you using?  Do you notice the same problems on another system?  Do you notice the same problems with the fonts list in the Misc sample?

Fred Tomke

Hello. honkinberry meant fonts starting with an @-character in their names. I know them, too. But since I have a new notebook I have no such of these fonts.

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

honkinberry

I'm sorry, I don't know where this Misc sample is located.

The @-preceded fonts are visible when Asian character sets are installed.
I just mentioned them as a good example of a font I would like to remove from the list.
But the font drop control doesn't seem to respond to changing it's list property.
But that is secondary to my primary issue:

The problem is that I don't see what I'm supposed to do with a font drop list.
If the misc sample shows what to do with it, then if you could direct me there, sorry for your time.
But I'm not seeing how to correlate the selected font name with an ability to create a text style in AutoCAD.

--J

owenwengerd

The Misc sample is one of the sample programs installed in the <Language>\Samples subfolder of your OpenDCL Studio installation.  The font combos are on the Combos2 tab.  The sample doesn't do anything with the font selection either, but it will help rule out a problem caused by your event handler code.  I'm not sure why you have trouble using the font to create a text style, but it may depend on which AutoCAD version you're using.  Please answer the questions about your environment and upload sample code if possible.

honkinberry

This machine is currently on 6.0.2.2, AutoCAD 2012, Windows 7.

Thanks for pointing me to the Misc sample.

As for the sample, yes, that displays the fonts the same as in my dialog box.
My question remains the same -- what am I supposed to do with it???
I'd like to use it to create a text style in AutoCAD, as I assume that's its purpose?
In which case, the AutoCAD Style command wants either a font filename, or a full font name.
Meanwhile, the list contains the filename of SHX fonts, but for TrueType fonts, such as those in the Swiss 721 family, does not list their full name, but their abbreviated name, which the Style command does not like.

So as for example code, the Misc sample will work fine.
Select "Swis721 Blk BT" from the list.  How do I then derive either "Swiss 721 Black BT" or "swissk.ttf" which the AutoCAD Style command wants?

--J

owenwengerd

I see what you're saying about the font name in the combo not being accepted by the -STYLE command.  I agree with you, it would seem these should match.  Have you searched past messages for example of someone using the font combo?  It should be possible to translate, but I don't know how.  In any case, I'd be interested in hearing how others use the font combo.  Maybe your idea of using ItemData to save the "long" name could be implemented as a solution without breaking existing code.

honkinberry

I did many searching on here, and couldn't find anything.
Also had no luck searching the internet or the registry for any way to translate the font names.

--J

owenwengerd

I took a look at the font combo code in OpenDCL. The font combo uses the Windows SDK function EnumFontFamiliesEx() to enumerate all installed Windows fonts.  It looks like AutoCAD uses the list of font names in HKLM\Software\Microsoft\Windows NT\CurrentVersion\Fonts as a lookup table when entering a font name for the -STYLE command.  To meet your needs, I suppose the OpenDCL code should be changed to enumerate fonts based on thelist in the registry instead of using the EnumFontFamiliesEx() function.  Unfortunately that would break existing code that expects names as they are currently returned, so I don't think it is feasible.

It would not be quite as sexy, but you could easily build your own font combo by filling a standard combo with the fonts from the registry plus any .shx fonts found in the AutoCAD support path.  It's also worth noting that OpenDCL removes from the list any Windows fonts that have been marked as hidden in the Windows control panel Fonts folder (hidden fonts are listed in CurrentVersion\Font Management\Inactive Fonts).  The fact that hidden fonts are omitted from the list means that the user can control which fonts are displayed by hiding/showing them.

honkinberry

You're right, I can accomplish it otherwise.  And in fact, I'd rather have it in a listbox, with a more integrated looking preview.
So I am padding my listbox with this:

(setq fontlist
    (vl-registry-descendents "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts" t)

    fontlist (mapcar (function (lambda (x)
         (vl-string-subst "" " (TrueType)" x)
      )) ; lambda function
      fontlist
   ) ; mapcar
   
    fontlist (acad_strlsort fontlist)
) ; setq

(dcl_Control_SetList fontlistbox fontlist)


Then I have a label on the form, with about a 28pt size.
And my listbox onSelChanged is like so:

(defun c:dclFontChanged (ItemIndexOrCount Value /)
   (dcl_Control_SetFont lblFontPreview Value)
) ; FontChanged


Which gives me an ability to select a font from a listbox (and full control of the list), see a preview, and even access the truetype filename if necessary.

As for changing the font drop list to do something like this, I'd certainly say at a minimum the ItemData should have the font filename.  But as for breaking any existing code, I'm just not seeing what code could possibly be broken, as the the only use I can see of the existing font drop list is just the whiz-bang look in the Misc sample.  If I can't actually connect it to AutoCAD text styles, what could someone possibly be using it for?

--J

owenwengerd

Quote from: honkinberry on October 18, 2011, 09:47:32 AM
If I can't actually connect it to AutoCAD text styles, what could someone possibly be using it for?

I don't know, but one thing is certain: if it's possible, then someone is doing it.