Font Names List handling in UI script

In order to avoid the request of the Font Name List in the parameterscript, from ARCHICAD 20 there is a possibility to handle the Font Name options in the User Interface script only. The following example provides a simple User Interface with the ui_custom_popup_infield command for the Font Name of the displayed text.

The custom popup does not work with parameters owning a value list, so use different parameter names for the Font Name (for example, ArchiCAD_Library_Master.gsm macro has the parameter “fontType” reserved for the same purpose, with an assigned value list, so choose something different for the custom popup).

! ------------------------------------------------------------------------------
! Input parameters controlled by the user:
! ------------------------------------------------------------------------------
! sampleName 		- (String) font family of the displayed text
! sampleSize 		- (RealNum) indicates the height of the font from the
! 		 	  baseline to the cap height, given in Paper size - mm
! sampleText 		- (String) the displayed text
! gs_ui_current_page	- (Integer) Unique parameter for the current tabpage

! ------------------------------------------------------------------------------
! 2D script
! ------------------------------------------------------------------------------
! Define Normal style with Left Upper anchor
define style "NormalStyle" sampleName, sampleSize, 1, 0
style "NormalStyle"

text2 0, 0, sampleText

Create an array (fontnames[]) for the Font Names List in the User Interface. Use the “FONTNAMES_LIST” request to get the available Font Names. If the “sampleName” parameter is set to an unknown Font Name, it can be appended to the end of the Font Names List as well.

! ------------------------------------------------------------------------------
! User Interface script
! ------------------------------------------------------------------------------
ui_page gs_ui_current_page

! Get the Font Type list
dim fontnames[]
n = REQUEST ("FONTNAMES_LIST", "", fontnames)

! If the Font Type is not recognized, append to the list
_bFoundInList 	= 0
_nTypes		= vardim1(fontnames)

for _type = 1 to _nTypes
	if sampleName = fontnames[_type] then
		_bFoundInList = 1
	endif
next _type

if not(_bFoundInList) then
	fontnames[_nTypes + 1] = sampleName
endif

The custom popup uses the array fontnames.
The Font Names are not in a hierarchical structure, therefore the treeDepth and the storeHiddenId are 0. The description of the selected value is the value itself, so the selectedValDescription is an empty string.

! Create Popup with the Font Type List
ui_outfield `Font Type`,		10, 14, 100, 15 
ui_custom_popup_infield "sampleName", 	115, 10, 150, 20,
	0, 0, 1, "", fontnames

ui_outfield `Font Size`, 10, 39, 100, 15 
ui_infield "sampleSize", 115, 35, 100, 20

ui_outfield `Text`, 	 10, 64, 100, 15 
ui_infield "sampleText", 115, 60, 100, 20

The scripts above results the following User Interface page:
TipsAndTricks_FontNamePopup_Ex1