_WinAPI_CreateFont
Создает логический шрифт с указанными характеристиками
#include <WinAPI.au3>
_WinAPI_CreateFont($nHeight, $nWidth [, $nEscape = 0 [, $nOrientn = 0 [, $fnWeight = $FW_NORMAL [, $bItalic = False [, $bUnderline = False [, $bStrikeout = False [, $nCharset = $DEFAULT_CHARSET [, $nOutputPrec = $OUT_DEFAULT_PRECIS [, $nClipPrec = $CLIP_DEFAULT_PRECIS [, $nQuality = $DEFAULT_QUALITY [, $nPitch = 0 [, $szFace = 'Arial']]]]]]]]]]]])
Параметры
$nHeight | Высота шрифта |
$nWidth |
Усреднённая ширина символа |
$nEscape |
[необязательный] Угол наклона |
$nOrientn |
[необязательный] base-line orientation angle |
$fnWeight |
[необязательный] Жирность шрифта, одно из следующих значений: $FW_DONTCARE - 0 $FW_THIN - 100 $FW_EXTRALIGHT - 200 $FW_LIGHT - 300 $FW_NORMAL - 400 $FW_MEDIUM - 500 $FW_SEMIBOLD - 600 $FW_BOLD - 700 $FW_EXTRABOLD - 800 $FW_HEAVY - 900 |
$bItalic |
[необязательный] Курсив |
$bUnderline |
[необязательный] Подчеркнутый |
$bStrikeout |
[необязательный] Зачёркнутый |
$nCharset |
[необязательный] Кодировка. Следующие значения предопределены: $ANSI_CHARSET - 0 $BALTIC_CHARSET - 186 $CHINESEBIG5_CHARSET - 136 $DEFAULT_CHARSET - 1 $EASTEUROPE_CHARSET - 238 $GB2312_CHARSET - 134 $GREEK_CHARSET - 161 $HANGEUL_CHARSET - 129 $MAC_CHARSET - 77 $OEM_CHARSET - 255 $RUSSIAN_CHARSET - 204 $SHIFTJIS_CHARSET - 128 $SYMBOL_CHARSET - 2 $TURKISH_CHARSET - 162 $VIETNAMESE_CHARSET - 163 |
$nOutputPrec |
[необязательный] Specifies the output precision, It can be one of the following values: $OUT_CHARACTER_PRECIS - Not used $OUT_DEFAULT_PRECIS - Specifies the default font mapper behavior $OUT_DEVICE_PRECIS - Instructs the font mapper to choose a Device font when the system contains multiple fonts with the same name $OUT_OUTLINE_PRECIS - Windows 2000/XP: This value instructs the font mapper to choose from TrueType and other outline-based fonts $OUT_PS_ONLY_PRECIS - Windows 2000/XP: Instructs the font mapper to choose from only PostScript fonts. If there are no PostScript fonts installed in the system, the font mapper returns to default behavior $OUT_RASTER_PRECIS - Instructs the font mapper to choose a raster font when the system contains multiple fonts with the same name $OUT_STRING_PRECIS - This value is not used by the font mapper, but it is returned when raster fonts are enumerated $OUT_STROKE_PRECIS - Windows 2000/XP: This value is not used by the font mapper, but it is returned when TrueType, other outline-based fonts, and vector fonts are enumerated $OUT_TT_ONLY_PRECIS - Instructs the font mapper to choose from only TrueType fonts. If there are no TrueType fonts installed in the system, the font mapper returns to default behavior $OUT_TT_PRECIS - Instructs the font mapper to choose a TrueType font when the system contains multiple fonts with the same name |
$nClipPrec |
[необязательный] Specifies the clipping precision, It can be one or more of the following values: $CLIP_CHARACTER_PRECIS - Not used $CLIP_DEFAULT_PRECIS - Specifies default clipping behavior $CLIP_EMBEDDED - You must specify this flag to use an embedded read-only font $CLIP_LH_ANGLES - When this value is used, the rotation for all fonts depends on whether the orientation of the coordinate system is left-handed or right-handed. If not used, device fonts always rotate counterclockwise, but the rotation of other fonts is dependent on the orientation of the coordinate system. $CLIP_MASK - Not used $CLIP_STROKE_PRECIS - Not used by the font mapper, but is returned when raster, vector, or TrueType fonts are enumerated Windows 2000/XP: For compatibility, this value is always returned when enumerating fonts $CLIP_TT_ALWAYS - Not used |
$nQuality |
[необязательный] Определяет качество, может быть одно из следующих значений: $ANTIALIASED_QUALITY - Windows 2000 and later: Font is antialiased, or smoothed, if the font supports it and the size of the font is not too small or too large. In addition, you must select a TrueType font into a screen DC prior to using it in a DIBSection, otherwise antialiasing does not happen $DEFAULT_QUALITY - Appearance of the font does not matter $DRAFT_QUALITY - Appearance of the font is less important than when the PROOF_QUALITY value is used. For GDI raster fonts, scaling is enabled, which means that more font sizes are available, but the quality may be lower. Bold, italic, underline, and strikeout fonts are synthesized, if necessary $NONANTIALIASED_QUALITY - Windows 2000 and later: Font is never antialiased, that is, font smoothing is not done $PROOF_QUALITY - Character quality of the font is more important than exact matching of the logical-font attributes. For GDI raster fonts, scaling is disabled and the font closest in size is chosen. Although the chosen font size may not be mapped exactly when PROOF_QUALITY is used, the quality of the font is high and there is no distortion of appearance. Bold, italic, underline, and strikeout fonts are synthesized, if necessary |
$nPitch |
[необязательный] Specifies the pitch and family of the font. The two low-order bits specify the pitch of the font and can be one of the following values: $DEFAULT_PITCH, $FIXED_PITCH, $VARIABLE_PITCH The four high-order bits specify the font family and can be one of the following values: $FF_DECORATIVE - Novelty fonts. Old English is an example $FF_DONTCARE - Use default font $FF_MODERN - Fonts with constant stroke width, with or without serifs. Pica, Elite, and Courier New are examples $FF_ROMAN - Fonts with variable stroke width and with serifs. MS Serif is an example $FF_SCRIPT - Fonts designed to look like handwriting. Script and Cursive are examples $FF_SWISS - Fonts with variable stroke width and without serifs. MS Sans Serif is an example |
$szFace |
[необязательный] Название шрифта |
Возвращаемое значение
Успех: | Возвращает дескриптор логического шрифта |
Ошибка: | Возвращает 0 |
Примечания
Когда шрифт больше не нужен вызовите функцию _WinAPI_DeleteObject(), чтобы удалить его.См. также
_WinAPI_SetFont, _WinAPI_CreateFontIndirectСм. также
Искать CreateFont в библиотеке MSDNПример
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <FontConstants.au3>
Global $tRECT, $hFont, $hOldFont, $hDC
HotKeySet("{ESC}", "_Exit")
$tRECT = DllStructCreate($tagRect)
DllStructSetData($tRECT, "Left", 5)
DllStructSetData($tRECT, "Top", 5)
DllStructSetData($tRECT, "Right", 270)
DllStructSetData($tRECT, "Bottom", 50)
$hDC = _WinAPI_GetDC(0)
$hFont = _WinAPI_CreateFont(50, 0, 0, 0, 400, False, False, False, $DEFAULT_CHARSET, _
$OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, 0, 'Arial')
$hOldFont = _WinAPI_SelectObject($hDC, $hFont)
_WinAPI_SetTextColor($hDC, 0x0000FF)
_WinAPI_SetBkColor($hDC, 0x000000)
; Закомментируй следующую строку, чтобы получить черный фон вместо прозрачного
_WinAPI_SetBkMode($hDC, $TRANSPARENT)
While 1
_WinAPI_DrawText($hDC, "Привет мир!", $tRECT, $DT_CENTER)
Sleep(100)
WEnd
Func _Exit()
_WinAPI_SelectObject($hDC, $hOldFont)
_WinAPI_DeleteObject($hFont)
_WinAPI_ReleaseDC(0, $hDC)
_WinAPI_InvalidateRect(0, 0)
$tRECT = 0
Exit
EndFunc ;==>_Exit