怎么给添加的多行文字的字体加黑?
我在添加多行文字时,想给文字加黑显示(也就是文字编辑中的B功能:粗体显示),可是用了textfontstyle方法也不好使,试了其它方法比如linewidth也不行,我现在已经是哪位高手能帮兄弟一把?不胜感激! 是不是“黑体”啊? 他是说粗体,而不是黑体。
Sub TextB()
Dim ent As AcadEntity
Dim pnt As Variant
On Error Resume Next
Do
ThisDrawing.Utility.GetEntity ent, pnt, "选择多行文字:"
Dim txt As AcadMText
Set txt = ent
If Err Then
Err.Clear
Else
Exit Do
End If
Loop
Dim str As String
str = txt.TextString
'加粗,其中SimSun为宋体,b1为加粗
str = "{\fSimSun|b1;" & str & "}"
txt.TextString = str
ThisDrawing.Regen acActiveViewport
End Sub
也可以使用TextStyle对象的SetFont方法给文字加粗,它将对所有设置该文字样式的文字生效。
语法:RetVal = object.SetFont(Typeface, Bold, Italic, CharSet, PitchAndFamily)
例子:Sub Example_SetFont()
' This example finds the font information for the active text style.
' It then changes the font to bold.
Dim typeFace As String
Dim Bold As Boolean
Dim Italic As Boolean
Dim charSet As Long
Dim PitchandFamily As Long
ThisDrawing.ActiveTextStyle.GetFont typeFace, Bold, Italic, charSet, PitchandFamily
MsgBox "The current text style has the following font properties:" & vbCrLf _
& "Typeface: " & typeFace & vbCrLf _
& "Bold: " & Bold & vbCrLf _
& "Italic: " & Italic & vbCrLf _
& "Character set: " & charSet & vbCrLf _
& "Pitch and Family: " & PitchandFamily
' Change the bold property
Bold = Not Bold
ThisDrawing.ActiveTextStyle.SetFont typeFace, Bold, Italic, charSet, PitchandFamily
MsgBox "The current text style has the following font properties:" & vbCrLf _
& "Typeface: " & typeFace & vbCrLf _
& "Bold: " & Bold & vbCrLf _
& "Italic: " & Italic & vbCrLf _
& "Character set: " & charSet & vbCrLf _
& "Pitch and Family: " & PitchandFamily
' Reset the font
Bold = Not Bold
ThisDrawing.ActiveTextStyle.SetFont typeFace, Bold, Italic, charSet, PitchandFamily
End Sub 谢谢楼上二位的帮助,可是这两种方法我都试过了,可还是没有得到我想要的效果,这是不是跟我用的大字体有关呢? 其实我觉得工程师的建议更适合我的想法,因为我本身也用了格式化参数\w0.7,但是在有两个参数设置时是这样的:\w值\h值x后面加str,跟你的用法有所不同,更不幸的是\b1在我这儿没有任何作用,看不到效果,我用的是ACAD2000,这是原因吗?
版主的高招我也试了,也无济于事,为什么? 请注意加粗只对于TTF字体有效,对SHX字体是无效的。因为SHX字体没有加粗功能。
所以使用
str = "{\fSimSun|b1;" & str & "}"
方法中字体和加粗代码必须在一起使用,而不能拆分。 哦,原来如此,看来我这个想法没法实现了?
谢谢噢:) ........:(
页:
[1]