我在程序中,用win32 API 自定义了 瘦字体,然后输出到C1PrintDocument上。我想要的效果是显示成 瘦字体,但现在显示成正常的字体了。
我的测试代码如下:
Declare Function CreateFont Lib "gdi32" Alias "CreateFontA" (ByVal H As Integer, ByVal W As Integer, ByVal E As Integer, ByVal O As Integer, ByVal W As Integer, ByVal i As Integer, ByVal U As Integer, ByVal S As Integer, ByVal c As Integer, ByVal OP As Integer, ByVal CP As Integer, ByVal Q As Integer, ByVal PAF As Integer, ByVal F As String) As Integer
Public Const PD_RETURNDEFAULT As Integer = &H400
Public Const PD_RETURNDC As Integer = &H100
Public Const HORZRES As Short = 8 ' Horizontal width in pixels
Public Const VERTRES As Short = 10 ' Vertical width in pixels
Public Const FW_THIN As Short = 100
Public Const FW_MEDIUM As Short = 500
Public Const SHIFTJIS_CHARSET As Short = 128
Public Const OUT_DEFAULT_PRECIS As Short = 0
Public Const CLIP_DEFAULT_PRECIS As Short = 0
Public Const DRAFT_QUALITY As Short = 1
Public Const DEFAULT_PITCH As Short = 0
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim nFont As Integer
CType(Me.C1PrintPreviewControl1.Document, C1.C1Preview.C1PrintDocument).StartDoc()
nFont = CreateFont(40, 60, 0, 0, FW_THIN, False, False, False, SHIFTJIS_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY, DEFAULT_PITCH, "Times New Roman")
Dim a As Font = Drawing.Font.FromHfont(nFont)
Dim tmpPara1 As New C1.C1Preview.RenderParagraph(a, Color.Red)
tmpPara1.Content.AddText("测试文字")
CType(Me.C1PrintPreviewControl1.Document, C1.C1Preview.C1PrintDocument).Body.Children.Add(tmpPara1)
CType(Me.C1PrintPreviewControl1.Document, C1.C1Preview.C1PrintDocument).EndDoc()
CType(Me.C1PrintPreviewControl1.Document, C1.C1Preview.C1PrintDocument).Generate()
End Sub
麻烦帮忙看下,谢谢啦。 |
|