Bir projenin FontList nesnelerini içerir. Bir projede birden çok yazı tipi listesi olabileceğinden, bunlara erişmek için kullanılan bir numaralandırıcı sınıfıdır.
| Ortam | Kullanılabilirlik |
|---|---|
| Engineering Studio | Kullanılabilir |
| Service Engine | Kullanılmaz |
| VBA | Kullanılabilir |
| VSTA | Kullanılabilir |
C#
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public class LogFont
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
private string _faceName;
public int Height { get; set; }
public int Width { get; set; }
public int Escapement { get; set; }
public int Orientation { get; set; }
public int Weight { get; set; }
public byte Italic { get; set; }
public byte Underline { get; set; }
public byte StrikeOut { get; set; }
public byte FontCharSet { get; set; }
public byte OutPrecision { get; set; }
public byte ClipPrecision { get; set; }
public byte Quality { get; set; }
public byte PitchAndFamily { get; set; }
public string FaceName
{
get
{
return _faceName;
}
set
{
if (value.Length > 32)
_faceName = value.Substring(0, 32);
else
_faceName = value;
}
}
public LogFont(int height, int width, int escape, int orient, int weight,
byte italic, byte underline, byte strikeout, byte charSet, byte outPrecision,
byte clipPrecision, byte quality, byte pitchAndFamily, string faceName)
{
this.Height = height;
this.Width = width;
this.Escapement = escape;
this.Orientation = orient;
this.Weight = weight;
this.Italic = italic;
this.Underline = underline;
this.StrikeOut = strikeout;
this.FontCharSet = charSet;
this.OutPrecision = outPrecision;
this.ClipPrecision = clipPrecision;
this.Quality = quality;
this.PitchAndFamily = pitchAndFamily;
this.FaceName = faceName;
}
public LogFont(string s)
{
string[] parseSplit = s.Split(' ');
this.Height = int.Parse(parseSplit[0]);
this.Width = int.Parse(parseSplit[1]);
this.Escapement = int.Parse(parseSplit[2]);
this.Orientation = int.Parse(parseSplit[3]);
this.Weight = int.Parse(parseSplit[4]);
this.Italic = byte.Parse(parseSplit[5]);
this.Underline = byte.Parse(parseSplit[6]);
this.StrikeOut = byte.Parse(parseSplit[7]);
this.FontCharSet = byte.Parse(parseSplit[8]);
this.OutPrecision = byte.Parse(parseSplit[9]);
this.ClipPrecision = byte.Parse(parseSplit[10]);
this.Quality = byte.Parse(parseSplit[11]);
this.PitchAndFamily = byte.Parse(parseSplit[12]);
this.FaceName = parseSplit[13];
}
public override string ToString()
{
return string.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12} {13}",
this.Height, this.Width, this.Escapement, this.Orientation, this.Weight,
this.Italic, this.Underline, this.StrikeOut, this.FontCharSet, this.OutPrecision,
this.ClipPrecision, this.Quality, this.PitchAndFamily, this.FaceName);
}
}
public void MacroFont()
{
IFontLists zenonFontLists = this.ActiveDocument.FontLists;
for (int i = 0; i < zenonFontLists.Count; ++i )
{
IFontList zenonFontList = zenonFontLists.Item(i);
//Loop through all fonts and set the height to 10
for (int j = 0; j < zenonFontList.Count; ++j)
{
IFontItem zenonFont = zenonFontList.Item(j);
//Parse the LogFont string of the font
LogFont lf = new LogFont((string)zenonFont.get_DynProperties("Font"));
lf.Height = -27;
//Change the height value and set the Font property again
zenonFont.set_DynProperties("Font", lf.ToString());
}
}
}
VB.NET
<StructLayout(LayoutKind.Sequential, CharSet := CharSet.Auto)> _
Public Class LogFont
<MarshalAs(UnmanagedType.ByValTStr, SizeConst := 32)> _
Private _faceName As String
Public Property Height() As Integer
Get
Return m_Height
End Get
Set
m_Height = Value
End Set
End Property
Private m_Height As Integer
Public Property Width() As Integer
Get
Return m_Width
End Get
Set
m_Width = Value
End Set
End Property
Private m_Width As Integer
Public Property Escapement() As Integer
Get
Return m_Escapement
End Get
Set
m_Escapement = Value
End Set
End Property
Private m_Escapement As Integer
Public Property Orientation() As Integer
Get
Return m_Orientation
End Get
Set
m_Orientation = Value
End Set
End Property
Private m_Orientation As Integer
Public Property Weight() As Integer
Get
Return m_Weight
End Get
Set
m_Weight = Value
End Set
End Property
Private m_Weight As Integer
Public Property Italic() As Byte
Get
Return m_Italic
End Get
Set
m_Italic = Value
End Set
End Property
Private m_Italic As Byte
Public Property Underline() As Byte
Get
Return m_Underline
End Get
Set
m_Underline = Value
End Set
End Property
Private m_Underline As Byte
Public Property StrikeOut() As Byte
Get
Return m_StrikeOut
End Get
Set
m_StrikeOut = Value
End Set
End Property
Private m_StrikeOut As Byte
Public Property FontCharSet() As Byte
Get
Return m_FontCharSet
End Get
Set
m_FontCharSet = Value
End Set
End Property
Private m_FontCharSet As Byte
Public Property OutPrecision() As Byte
Get
Return m_OutPrecision
End Get
Set
m_OutPrecision = Value
End Set
End Property
Private m_OutPrecision As Byte
Public Property ClipPrecision() As Byte
Get
Return m_ClipPrecision
End Get
Set
m_ClipPrecision = Value
End Set
End Property
Private m_ClipPrecision As Byte
Public Property Quality() As Byte
Get
Return m_Quality
End Get
Set
m_Quality = Value
End Set
End Property
Private m_Quality As Byte
Public Property PitchAndFamily() As Byte
Get
Return m_PitchAndFamily
End Get
Set
m_PitchAndFamily = Value
End Set
End Property
Private m_PitchAndFamily As Byte
Public Property FaceName() As String
Get
Return _faceName
End Get
Set
If value.Length > 32 Then
_faceName = value.Substring(0, 32)
Else
_faceName = value
End If
End Set
End Property
Public Sub New(height As Integer, width As Integer, escape As Integer, orient As Integer, weight As Integer, italic As Byte, _
underline As Byte, strikeout As Byte, charSet As Byte, outPrecision As Byte, clipPrecision As Byte, quality As Byte, _
pitchAndFamily As Byte, faceName As String)
Me.Height = height
Me.Width = width
Me.Escapement = escape
Me.Orientation = orient
Me.Weight = weight
Me.Italic = italic
Me.Underline = underline
Me.StrikeOut = strikeout
Me.FontCharSet = charSet
Me.OutPrecision = outPrecision
Me.ClipPrecision = clipPrecision
Me.Quality = quality
Me.PitchAndFamily = pitchAndFamily
Me.FaceName = faceName
End Sub
Public Sub New(s As String)
Dim parseSplit As String() = s.Split(" "C)
Me.Height = Integer.Parse(parseSplit(0))
Me.Width = Integer.Parse(parseSplit(1))
Me.Escapement = Integer.Parse(parseSplit(2))
Me.Orientation = Integer.Parse(parseSplit(3))
Me.Weight = Integer.Parse(parseSplit(4))
Me.Italic = Byte.Parse(parseSplit(5))
Me.Underline = Byte.Parse(parseSplit(6))
Me.StrikeOut = Byte.Parse(parseSplit(7))
Me.FontCharSet = Byte.Parse(parseSplit(8))
Me.OutPrecision = Byte.Parse(parseSplit(9))
Me.ClipPrecision = Byte.Parse(parseSplit(10))
Me.Quality = Byte.Parse(parseSplit(11))
Me.PitchAndFamily = Byte.Parse(parseSplit(12))
Me.FaceName = parseSplit(13)
End Sub
Public Overrides Function ToString() As String
Return String.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12} {13}", Me.Height, Me.Width, Me.Escapement, Me.Orientation, Me.Weight, _
Me.Italic, Me.Underline, Me.StrikeOut, Me.FontCharSet, Me.OutPrecision, Me.ClipPrecision, _
Me.Quality, Me.PitchAndFamily, Me.FaceName)
End Function
End Class
Public Sub MacroFont()
Dim zenonFontLists As IFontLists = Me.ActiveDocument.FontLists
For i As Integer = 0 To zenonFontLists.Count - 1
Dim zenonFontList As IFontList = zenonFontLists.Item(i)
'Loop through all fonts and set the height to 10
For j As Integer = 0 To zenonFontList.Count - 1
Dim zenonFont As IFontItem = zenonFontList.Item(j)
'Parse the LogFont string of the font
Dim lf As New LogFont(DirectCast(zenonFont.get_DynProperties("Font"), String))
lf.Height = -27
'Change the height value and set the Font property again
zenonFont.set_DynProperties("Font", lf.ToString())
Next
Next
End Sub
VBA
'Type definition of LOGFONT type (see MSDN)
Type LOGFONT
Height As Long
Width As Long
Escapement As Long
Orientation As Long
Weight As Long
Italic As Byte
Underline As Byte
StrikeOut As Byte
CharSet As Byte
OutPrecision As Byte
ClipPrecision As Byte
Quality As Byte
PitchAndFamily As Byte
FaceName As String * 32
End Type
Sub GetFontList()
Dim zPRJ As Project
Dim zFLs As FontLists
Dim zFL As FontList
Dim zFI As FontItem
Dim i As Integer
Dim n As Integer
Dim lf As LOGFONT
Set zPRJ = MyWorkspace.ActiveDocument
Set zFLs = zPRJ.FontLists
'enumerate all fontlists of the active project
For i = 0 To zFLs.Count - 1
Set zFL = zFLs.Item(i)
Debug.Print "Fontlist: " & zFL.DynProperties("Name")
'enumrate fonts of a fontlist
For n = 0 To zFL.Count - 1
Set zFI = zFL.Item(n)
Debug.Print zFI.DynProperties("Number")
Debug.Print zFI.DynProperties("Name")
Debug.Print zFI.DynProperties("Font")
'convert string to LOGFONT type in a function
lf = GetLogFontFromString(zFI.DynProperties("Font"))
Next n
Next i
End Sub
Sub CreateFontList()
Dim zPRJ As Project
Dim zFLs As FontLists
Dim zFL As FontList
Dim zFI As FontItem
Dim i As Integer
Dim lf As LOGFONT
Set zPRJ = MyWorkspace.ActiveDocument
Set zFLs = zPRJ.FontLists
'define font (LOGFONT)
lf.Height = 10
lf.Width = 0
lf.Escapement = 0
lf.Orientation = 0
lf.Weight = 400
lf.Italic = 0
lf.Underline = 0
lf.StrikeOut = 0
lf.CharSet = 0
lf.OutPrecision = 3
lf.ClipPrecision = 2
lf.Quality = 5
lf.PitchAndFamily = 34
lf.FaceName = String(25, " ") & "Courier" '32 - 7
'create new fontlist
Set zFL = zFLs.Create
With zFL
'set name of new fontlist
.DynProperties("Name") = "VBA_FontList3"
For i = 1 To 10
'create fonts in fontlist
Set zFI = zFL.Create(i)
zFI.DynProperties("Name") = "VBA_Font_" & Format(i, "00")
zFI.DynProperties("Font") = strFont
'modify LOGFONT definition
lf.Height = 10 + (i * 2)
'set font
zFI.DynProperties("Font") = GetStringFromLogFont(lf)
Next i
End With
End Sub
'CONVERT A STRING TO LOGFONT TYPE
Function GetLogFontFromString(strFont As String) As LOGFONT
Dim vSplit As Variant
Dim sFaceName As String
Dim i As Integer
vSplit = Split(strFont, " ")
GetLogFontFromString.Height = vSplit(0)
GetLogFontFromString.Width = vSplit(1)
GetLogFontFromString.Escapement = vSplit(2)
GetLogFontFromString.Orientation = vSplit(3)
GetLogFontFromString.Weight = vSplit(4)
GetLogFontFromString.Italic = vSplit(5)
GetLogFontFromString.Underline = vSplit(6)
GetLogFontFromString.StrikeOut = vSplit(7)
GetLogFontFromString.CharSet = vSplit(8)
GetLogFontFromString.OutPrecision = vSplit(9)
GetLogFontFromString.ClipPrecision = vSplit(10)
GetLogFontFromString.Quality = vSplit(11)
GetLogFontFromString.PitchAndFamily = vSplit(12)
For i = 13 To UBound(vSplit)
sFaceName = sFaceName & vSplit(i) & " "
Next i
sFaceName = RTrim(sFaceName)
sFaceName = String(32 - Len(sFaceName), " ") & sFaceName
GetLogFontFromString.FaceName = sFaceName
End Function
'CONVERT A LOGFONT TO STRING
Function GetStringFromLogFont(lfFont As LOGFONT) As String
GetStringFromLogFont = lfFont.Height & " " & _
lfFont.Width & " " & _
lfFont.Escapement & " " & _
lfFont.Orientation & " " & _
lfFont.Weight & " " & _
lfFont.Italic & " " & _
lfFont.Underline & " " & _
lfFont.StrikeOut & " " & _
lfFont.CharSet & " " & _
lfFont.OutPrecision & " " & _
lfFont.ClipPrecision & " " & _
lfFont.Quality & " " & _
lfFont.PitchAndFamily & " " & _
lfFont.FaceName
End FunctionBu konuda sorunuz mu var?SGE AI bu sayfaya ve ilgili yardım konularına dayanarak yanıtlar.
Bu bölümdeki konular
Bu sayfa, COPA-DATA zenon 16 çevrimiçi yardımının Türkçe çevirisidir. Menü ve ayar adları, programdaki gibi bulmanız için İngilizce bırakılmıştır.