home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / ppfont10 / ppfont.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  11.1 KB  |  347 lines

  1. VERSION 2.00
  2. Begin Form fontform 
  3.    Caption         =   "PPFont Demo"
  4.    ClientHeight    =   5490
  5.    ClientLeft      =   135
  6.    ClientTop       =   1455
  7.    ClientWidth     =   9375
  8.    Height          =   5895
  9.    Left            =   75
  10.    LinkTopic       =   "Form2"
  11.    ScaleHeight     =   5490
  12.    ScaleWidth      =   9375
  13.    Top             =   1110
  14.    Width           =   9495
  15.    Begin ListBox List5 
  16.       Height          =   3150
  17.       Left            =   6960
  18.       TabIndex        =   8
  19.       Top             =   600
  20.       Width           =   2355
  21.    End
  22.    Begin ListBox List4 
  23.       Height          =   3150
  24.       Left            =   4920
  25.       TabIndex        =   6
  26.       Top             =   600
  27.       Width           =   1995
  28.    End
  29.    Begin ListBox List3 
  30.       Height          =   1395
  31.       Left            =   3480
  32.       TabIndex        =   5
  33.       Top             =   2280
  34.       Width           =   1395
  35.    End
  36.    Begin ListBox List2 
  37.       Height          =   1395
  38.       Left            =   3480
  39.       TabIndex        =   1
  40.       Top             =   600
  41.       Width           =   1395
  42.    End
  43.    Begin ListBox List1 
  44.       Height          =   3150
  45.       Left            =   60
  46.       Sorted          =   -1  'True
  47.       TabIndex        =   0
  48.       Top             =   600
  49.       Width           =   3375
  50.    End
  51.    Begin Label Label6 
  52.       Alignment       =   2  'Center
  53.       Caption         =   "AaBbCcDdEeFfGgHhIiJjKkLlMm NnOoPpQqRrSsTtUuVvWwXxYyZz 1234567890"
  54.       FontBold        =   -1  'True
  55.       FontItalic      =   0   'False
  56.       FontName        =   "MS Sans Serif"
  57.       FontSize        =   18
  58.       FontStrikethru  =   0   'False
  59.       FontUnderline   =   0   'False
  60.       Height          =   1635
  61.       Left            =   60
  62.       TabIndex        =   10
  63.       Top             =   3840
  64.       Width           =   9135
  65.    End
  66.    Begin Label Label5 
  67.       Alignment       =   2  'Center
  68.       Caption         =   "TEXTMETRIC (physical)"
  69.       Height          =   375
  70.       Left            =   7560
  71.       TabIndex        =   9
  72.       Top             =   180
  73.       Width           =   1275
  74.    End
  75.    Begin Label Label4 
  76.       Alignment       =   2  'Center
  77.       Caption         =   "LOGFONT (logical)"
  78.       Height          =   375
  79.       Left            =   5100
  80.       TabIndex        =   7
  81.       Top             =   180
  82.       Width           =   1575
  83.    End
  84.    Begin Label Label3 
  85.       Caption         =   "Style"
  86.       Height          =   315
  87.       Left            =   3480
  88.       TabIndex        =   4
  89.       Top             =   2040
  90.       Width           =   1515
  91.    End
  92.    Begin Label Label2 
  93.       Caption         =   "Full Name"
  94.       Height          =   195
  95.       Left            =   3480
  96.       TabIndex        =   3
  97.       Top             =   360
  98.       Width           =   1575
  99.    End
  100.    Begin Label Label1 
  101.       Caption         =   "Family"
  102.       Height          =   315
  103.       Left            =   60
  104.       TabIndex        =   2
  105.       Top             =   300
  106.       Width           =   1515
  107.    End
  108. Declare Function PPFontFam Lib "PPFONT.DLL" (ByVal hwnd As Integer, alf As NEWLOGFONT, atm As NEWTEXTMETRIC, aft As Integer) As Integer
  109. Declare Function PPFontFamNum Lib "PPFONT.DLL" (ByVal hwnd As Integer) As Integer
  110. Declare Function PPFont Lib "PPFONT.DLL" (ByVal hwnd As Integer, alf As NEWLOGFONT, atm As NEWTEXTMETRIC, aft As Integer, ByVal acharset As String) As Integer
  111. Declare Function PPFontNum Lib "PPFONT.DLL" (ByVal hwnd As Integer, ByVal acharset As String) As Integer
  112. Function chst (testitem As String)
  113.     Select Case Asc(testitem)
  114.            Case 0
  115.                 chst = "ANSI"
  116.            Case 1
  117.                 chst = "Default"
  118.            Case 2
  119.                 chst = "Symbol"
  120.            Case 128
  121.                 chst = "SHIFTJIS"
  122.            Case 129
  123.                 chst = "HANGEUL"
  124.            Case 136
  125.                 chst = "ChineseBig5"
  126.            Case 255
  127.                 chst = "OEM"
  128.            Case Else
  129.                 chst = "Unknown"
  130.     End Select
  131. End Function
  132. Function clipprecision (testitem As String)
  133.     Select Case Asc(testitem)
  134.            Case 0
  135.                 clipprecision = "Default"
  136.            Case 1
  137.                 clipprecision = "Character"
  138.            Case 2
  139.                 clipprecision = "Stroke"
  140.            Case &HF
  141.                 clipprecision = "Mask"
  142.            Case &H10
  143.                 clipprecision = "LH Angles"
  144.            Case &H20
  145.                 clipprecision = "TT Angles"
  146.            Case &H80
  147.                 clipprecision = "Embedded"
  148.            Case Else
  149.                 clipprecision = "Unknown"
  150.     End Select
  151. End Function
  152. Function family (testitem As String)
  153.     f% = Asc(testitem) / 16
  154.     Select Case f%
  155.            Case 0
  156.                 family = "Don't Care"
  157.            Case 1
  158.                 family = "Roman"
  159.            Case 2
  160.                 family = "Swiss"
  161.            Case 3
  162.                 family = "Modern"
  163.            Case 4
  164.                 family = "Script"
  165.            Case 5
  166.                 family = "Decorative"
  167.            Case Else
  168.                 family = "Unknown"
  169.     End Select
  170. End Function
  171. Sub Form_Load ()
  172.     Static lf() As NEWLOGFONT
  173.     Static tm() As NEWTEXTMETRIC
  174.     Static ftype() As Integer
  175.     n = PPFontFamNum(hwnd)
  176.     ReDim lf(n), tm(n), ftype(n)
  177.     i = PPFontFam(hwnd, lf(1), tm(1), ftype(1))
  178.     For j = 1 To i
  179.         If ftype(j) And DEVICE_FONTTYPE Then
  180.            ft$ = "Device  "
  181.         Else
  182.            ft$ = "GDI  "
  183.         End If
  184.         If ftype(j) And TRUETYPE_FONTTYPE Then
  185.            ft$ = ft$ + "TrueType"
  186.         Else
  187.            If ftype(j) And RASTER_FONTTYPE Then
  188.               ft$ = ft$ + "Raster"
  189.            Else
  190.               ft$ = ft$ + "Vector"
  191.            End If
  192.         End If
  193.         font$ = lf(j).lfFacename
  194.         For k = 1 To LF_FACESIZE
  195.             If Asc(Mid$(font$, k, 1)) = 0 Then
  196.                Exit For
  197.             End If
  198.         Next
  199.         font$ = Mid$(font$, 1, k - 1)
  200.         l = Len(ft$)
  201.         list1.AddItem font$ + "   * " + ft$
  202.     Next
  203.     list1.ListIndex = 4
  204.     List1_Click
  205. End Sub
  206. Sub List1_Click ()
  207.     Static lf() As NEWLOGFONT
  208.     Static tm() As NEWTEXTMETRIC
  209.     Static ftype() As Integer
  210.     list2.Clear
  211.     list3.Clear
  212.     list4.Clear
  213.     list5.Clear
  214.     selfont$ = list1.List(list1.ListIndex)
  215.     n = InStr(selfont$, "*")
  216.     selfont$ = Trim(Mid$(selfont$, 1, n - 4))
  217.     n = PPFontNum(hwnd, selfont$)
  218.     ReDim lf(n), tm(n), ftype(n)
  219.     i = PPFont(hwnd, lf(1), tm(1), ftype(1), selfont$)
  220.     If ftype(1) And TRUETYPE_FONTTYPE Then
  221.        For j = 1 To i
  222.            list2.AddItem lf(j).lfFacename
  223.            list3.AddItem lf(j).lfStyle
  224.        Next
  225.     End If
  226.     ' display logical info
  227.     list4.AddItem "Height:  " + Str$(lf(1).lfHeight)
  228.     list4.AddItem "Width:  " + Str$(lf(1).lfWidth)
  229.     list4.AddItem "Escapement:  " + Str$(lf(1).lfEscapement)
  230.     list4.AddItem "Orientation:  " + Str$(lf(1).lfOrientation)
  231.     list4.AddItem "Weight:  " + weight(lf(1).lfWeight)
  232.     list4.AddItem "Italic:  " + yn(lf(1).lfItalic)
  233.     list4.AddItem "Underline:  " + yn(lf(1).lfUnderline)
  234.     list4.AddItem "Strike-out:  " + yn(lf(1).lfStrikeOut)
  235.     list4.AddItem "Pitch:  " + pitch(lf(1).lfPitchAndFamily)
  236.     list4.AddItem "Family:  " + family(lf(1).lfPitchAndFamily)
  237.     list4.AddItem "CharSet:  " + chst(lf(1).lfCharSet)
  238.     list4.AddItem "OutPrecision:  " + outprecision(lf(1).lfOutPrecision)
  239.     list4.AddItem "ClipPrecision:  " + clipprecision(lf(1).lfClipPrecision)
  240.     list4.AddItem "Quality:  " + quality(lf(1).lfQuality)
  241.     list5.AddItem "Height:  " + Str$(tm(1).tmHeight)
  242.     list5.AddItem "Ascent:  " + Str$(tm(1).tmAscent)
  243.     list5.AddItem "Descent:  " + Str$(tm(1).tmDescent)
  244.     list5.AddItem "Int. Leading:  " + Str$(tm(1).tmInternalLeading)
  245.     list5.AddItem "Ext. Leading:  " + Str$(tm(1).tmExternalLeading)
  246.     list5.AddItem "Ave. Width:  " + Str$(tm(1).tmAveCharWidth)
  247.     list5.AddItem "Max. Width:  " + Str$(tm(1).tmMaxCharWidth)
  248.     list5.AddItem "Weight:  " + Str$(tm(1).tmWeight)
  249.     list5.AddItem "Italic:  " + yn(tm(1).tmItalic)
  250.     list5.AddItem "Underline:  " + yn(tm(1).tmUnderlined)
  251.     list5.AddItem "Strike-out:  " + yn(tm(1).tmStruckOut)
  252.     list5.AddItem "First Char:  " + Str$(Asc(tm(1).tmFirstChar))
  253.     list5.AddItem "Last Char:  " + Str$(Asc(tm(1).tmLastChar))
  254.     list5.AddItem "Default Char:  " + Str$(Asc(tm(1).tmDefaultChar))
  255.     list5.AddItem "Break Char:  " + Str$(Asc(tm(1).tmBreakChar))
  256.     list5.AddItem "Pitch:  " + pitch(tm(1).tmPitchAndFamily)
  257.     list5.AddItem "Family:  " + family(tm(1).tmPitchAndFamily)
  258.     list5.AddItem "Char Set:  " + chst(tm(1).tmCharSet)
  259.     list5.AddItem "Overhang:  " + Str$(tm(1).tmOverhang)
  260.     list5.AddItem "Digitized X:  " + Str$(tm(1).tmDigitizedAspectX)
  261.     list5.AddItem "Digitized Y: " + Str$(tm(1).tmDigitizedAspectY)
  262.     list5.AddItem "Size EM:  " + Str$(tm(1).ntmSizeEM)
  263.     list5.AddItem "Cell Height:  " + Str$(tm(1).ntmCellHeight)
  264.     list5.AddItem "Avg. Width - notional:  " + Str$(tm(1).ntmAvgWidth)
  265.     label6.FontName = selfont$
  266. End Sub
  267. Function outprecision (testitem As String)
  268.     Select Case Asc(testitem)
  269.            Case 0
  270.                 outprecision = "Default"
  271.            Case 1
  272.                 outprecision = "String"
  273.            Case 2
  274.                 outprecision = "Character"
  275.            Case 3
  276.                 outprecision = "Stroke"
  277.            Case 4
  278.                 outprecision = "TT"
  279.            Case 5
  280.                 outprecision = "Device"
  281.            Case 6
  282.                 outprecision = "Raster"
  283.            Case 7
  284.                 outprecision = "TT Only"
  285.            Case Else
  286.                 outprecision = "Unknown"
  287.     End Select
  288. End Function
  289. Function pitch (testitem As String)
  290.     i = Asc(testitem) Mod 16
  291.     Select Case i
  292.         Case 0
  293.             pitch = "Default"
  294.         Case 1
  295.             pitch = "Fixed"
  296.         Case 2
  297.             pitch = "Variable"
  298.         Case Else
  299.             pitch = "Unknown"
  300.     End Select
  301. End Function
  302. Function quality (testitem As String)
  303.     Select Case Asc(testitem)
  304.         Case 0
  305.             quality = "Default"
  306.         Case 1
  307.             quality = "Draft"
  308.         Case 2
  309.             quality = "Proof"
  310.         Case Else
  311.             quality = "Unknown"
  312.     End Select
  313. End Function
  314. Function weight (testitem As Integer)
  315.     Select Case i
  316.         Case 0
  317.             weight = "Don't care"
  318.         Case 100
  319.             weight = "Thin"
  320.         Case 200
  321.             weight = "Extra Light"
  322.         Case 300
  323.             weight = "Light"
  324.         Case 400
  325.             weight = "Normal"
  326.         Case 500
  327.             weight = "Medium"
  328.         Case 600
  329.             weight = "Semi-bold"
  330.         Case 700
  331.             weight = "Bold"
  332.         Case 800
  333.             weight = "Extra Bold"
  334.         Case 900
  335.             weight = "Heavy"
  336.         Case Else
  337.             weight = "Unknown"
  338.     End Select
  339. End Function
  340. Function yn (testitem As String)
  341.     If Asc(testitem) = 0 Then
  342.        yn = "Yes"
  343.     Else
  344.        yn = "No"
  345.     End If
  346. End Function
  347.