GetFont()
This function invokes FoxPro's Font dialog and returns information about the chosen font.
Usage |
cFontInfo = GETFONT( [ cFontName [, nFontSize [, cFontStyle [, nCharSet ] ] ] ] ) |
GETFONT() can't handle the empty string for the font name. It coughs up an error message. This is particularly strange, since it can deal with empty values for the other three parameters and stupid values for the font name. |
Example |
* ParsFont.PRG * VFP 7 version. See previous editions for a version of * this routine that works in VFP 6 and earlier. * Call GETFONT() and parse the return value into its four * components: name, size, style, charset * Sample Call: * DO ParsFont WITH cFontName, nFontSize, cFontStyle, nCharSet * or: * ParsFont(@cFontName, @nFontSize, @cFontStyle, @nCharSet) LPARAMETERS cFontName, nFontSize, cFontStyle, nCharSet LOCAL cFontInfo, aFontInfo[1], nLines * Call varies depending on parameters passed DO CASE CASE EMPTY(cFontName) OR TYPE("cFontName")<>"C" cFontInfo=GETFONT() CASE TYPE("nFontSize")<>"N" OR nFontSize = 0 cFontInfo = GETFONT(cFontName) CASE EMPTY(cFontStyle) OR TYPE("cFontStyle")<>"C" cFontInfo = GETFONT(cFontName, nFontSize) CASE TYPE("nCharSet") <> "N" OR nCharSet = 0 cFontInfo = GETFONT(cFontName, nFontSize, cFontStyle) OTHERWISE cFontInfo = GETFONT(cFontName, nFontSize, cFontStyle, ; nCharSet) ENDCASE IF NOT EMPTY(cFontInfo) nLines = ALINES( aFontInfo, cFontInfo, .T., ",") cFontName = aFontInfo[ 1 ] nFontSize = INT(VAL( aFontInfo[ 2 ] )) cFontStyle = aFontInfo[ 3 ] IF nLines = 4 nCharSet = INT(VAL( aFontInfo [ 4 ] )) ENDIF ENDIF RETURN |
See Also |