Hi
I have been working a bit on some input routines and is looking for a way to establish information about the font currently in use. This is mainly to reestablish it as the current font if I have to modify a font locally in an input field. Of course hardcoding a default font for the program is possible, but I kind of like the approach of not messing with the default font unless I have to.
Anyway - To do this I have to find a way of asking for a 'current font' and a 'current font size'. As for the font size I think I have it in place using the bit of code included below. But does anyone have suggestions on how to extract information about the current font (like in "times.font"). Pleeeeeze....
regards Jesper
Code: Select all
Function p_GetCurrentFontSize()
/* This stuff in the first part is just to find a 'free' value to use
when creating */
/* a new temporary TextObject. You don't want to accidentally
overwrite an existing */
/* object. It establishes an index (i) not already used for
TextObjects */
/* If you have lots of TextObjects starting at index 1 you may of
course initilize */
/* the local value to.. say 500. Odds are the value 501 will be
free :-) */
local i=0
local code = 0
ExitOnError(False)
while code = 0
i=i+1
local attr = GetAttribute(#TEXTOBJECT,i,#ATTRHEIGHT)
code = GetLastError()
wend
ExitOnError(True)
/* This is the part that actually checks for the current font size */
/* by looking at a newly created TextObject and returning its height
*/
CreateTextObject(i,"X")
local fontsize=(GetAttribute(#TEXTOBJECT,i,#ATTRHEIGHT))
FreeTextObject(i)
Return(fontsize)
endfunction