找回密码
 立即注册

QQ登录

只需一步,快速开始

harborzhb

高级会员

7

主题

18

帖子

1769

积分

高级会员

积分
1769

活字格认证

harborzhb
高级会员   /  发表于:2014-1-20 09:38  /   查看:5571  /  回复:2
我在程序中,用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
麻烦帮忙看下,谢谢啦。

2 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2014-1-20 14:30:00
沙发
回复 1楼harborzhb的帖子

感谢你的问题反馈。

目前我还不确定 C1PrintDocument 是否支持自定义字体,需要和开发组确认。目前已经发送问题,在得到反馈后我会通知你。

谢谢
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2014-4-3 10:33:00
板凳
回复 1楼harborzhb的帖子

不好意思,让您久等了。

能否把 自定义字体的 TTF 文件发送给我便于我们测试?
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部