Hackers Guide to Visual FoxPro 7.0
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. |
Since every command we can think of that needs font information wants the items separately, a routine to parse GETFONT()'s return value seems useful. That's the example below. The procedure calls GETFONT(), then sets its parameters to the four components of the return value.
| 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 | AFont(), FontMetric() |
View Updates
Copyright © 2002 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. All Rights Reserved.
Категории