D5DG中有字体旋转的例子,我将其中的片断Paste出来。 FLogFont: TLogFont;
FHFont: HFont;procedure TMainForm.MakeFont;
begin
// Clear the contents of FLogFont
FillChar(FLogFont, sizeof(TLogFont), 0);
// Set the TLOGFONT's fields
with FLogFont do
begin
lfHeight := StrToInt(seHeight.Text);
lfWidth := StrToInt(seWidth.Text);
lfEscapement := StrToInt(cbEscapement.Items[cbEscapement.ItemIndex]);
lfOrientation := StrToInt(cbOrientation.Items[cbOrientation.ItemIndex]);
lfWeight := WeightArray[cbWeight.ItemIndex];
lfItalic := ord(cbxItalic.Checked);
lfUnderline := ord(cbxUnderLine.Checked);
lfStrikeOut := ord(cbxStrikeOut.Checked);
lfCharSet := CharSetArray[cbCharset.ItemIndex];
lfOutPrecision := OutPrecArray[cbOutPrec.ItemIndex];
lfClipPrecision := ClipPrecArray[cbClipPrec.ItemIndex];
lfQuality := QualityArray[rgQuality.ItemIndex];
lfPitchAndFamily := PitchArray[rgPitch.ItemIndex] or FamilyArray[cbFamily.ItemIndex];
StrPCopy(lfFaceName, cbFontFace.Items[cbFontFace.ItemIndex]);
end;
// Retrieve the requested font
FHFont := CreateFontIndirect(FLogFont);
// Assign to the Font.Handle
pbxFont.Font.Handle := FHFont;
pbxFont.Refresh;
end;
FHFont: HFont;procedure TMainForm.MakeFont;
begin
// Clear the contents of FLogFont
FillChar(FLogFont, sizeof(TLogFont), 0);
// Set the TLOGFONT's fields
with FLogFont do
begin
lfHeight := StrToInt(seHeight.Text);
lfWidth := StrToInt(seWidth.Text);
lfEscapement := StrToInt(cbEscapement.Items[cbEscapement.ItemIndex]);
lfOrientation := StrToInt(cbOrientation.Items[cbOrientation.ItemIndex]);
lfWeight := WeightArray[cbWeight.ItemIndex];
lfItalic := ord(cbxItalic.Checked);
lfUnderline := ord(cbxUnderLine.Checked);
lfStrikeOut := ord(cbxStrikeOut.Checked);
lfCharSet := CharSetArray[cbCharset.ItemIndex];
lfOutPrecision := OutPrecArray[cbOutPrec.ItemIndex];
lfClipPrecision := ClipPrecArray[cbClipPrec.ItemIndex];
lfQuality := QualityArray[rgQuality.ItemIndex];
lfPitchAndFamily := PitchArray[rgPitch.ItemIndex] or FamilyArray[cbFamily.ItemIndex];
StrPCopy(lfFaceName, cbFontFace.Items[cbFontFace.ItemIndex]);
end;
// Retrieve the requested font
FHFont := CreateFontIndirect(FLogFont);
// Assign to the Font.Handle
pbxFont.Font.Handle := FHFont;
pbxFont.Refresh;
end;
// Array to represent the TLOGFONT.lfCharSet values
CharSetArray: array[0..4] of byte = (ANSI_CHARSET, DEFAULT_CHARSET,
SYMBOL_CHARSET, SHIFTJIS_CHARSET, OEM_CHARSET);// Array to represent the TLOGFONT.lfWeight values
WeightArray: array[0..9] of integer =
(FW_DONTCARE, FW_THIN, FW_EXTRALIGHT, FW_LIGHT, FW_NORMAL, FW_MEDIUM,
FW_SEMIBOLD, FW_BOLD, FW_EXTRABOLD, FW_HEAVY);// Array to represent the TLOGFONT.lfOutPrecision values
OutPrecArray: array[0..7] of byte = (OUT_DEFAULT_PRECIS,
OUT_STRING_PRECIS, OUT_CHARACTER_PRECIS, OUT_STROKE_PRECIS,
OUT_TT_PRECIS, OUT_DEVICE_PRECIS, OUT_RASTER_PRECIS,
OUT_TT_ONLY_PRECIS);// Array to represent the TLOGFONT.lfPitchAndFamily higher four-bit values
FamilyArray: array[0..5] of byte = (FF_DONTCARE, FF_ROMAN,
FF_SWISS, FF_MODERN, FF_SCRIPT, FF_DECORATIVE);// Array to represent the TLOGFONT.lfPitchAndFamily lower two-bit values
PitchArray: array[0..2] of byte = (DEFAULT_PITCH, FIXED_PITCH,
VARIABLE_PITCH);// Array to represent the TLOGFONT.lfClipPrecision values
ClipPrecArray: array[0..6] of byte = (CLIP_DEFAULT_PRECIS,
CLIP_CHARACTER_PRECIS, CLIP_STROKE_PRECIS, CLIP_MASK, CLIP_LH_ANGLES,
CLIP_TT_ALWAYS, CLIP_EMBEDDED);// Array to represent the TLOGFONT.lfQuality values
QualityArray: array[0..2] of byte = (DEFAULT_QUALITY, DRAFT_QUALITY,
PROOF_QUALITY);