Gary <Gary@discussions.microsoft.com> schrieb im Beitrag
<71AFA002-22B4-41BE-992C-19C06DEDAC22@microsoft.com>...
> Any one has the example code for using GetFontUnicodeRanges in VB or vba? Or
> where I can find such information on website?
> I don't know how to declare GLYPHSET. Although I put null in the function,
> and hoped it returns the number of Unicode points supported, the application
> crashed. To declare GLYPHSET, I need to declare WCRANGE also. An example is
> highly appreciated!
GLYPHSET is a structure with an array of WCRANGE structures (field
"ranges"). This means that the size of this structure is variable. On the
one hand it is not possible to get the count of items of the array without
getting the GLYPHSET structure, on the other hand it is not possible to get
the GLYPHSET structure without knowing its total size, i.e. the count of
items of the array.
Therefore the function GetFontUnicodeRanges() provides another way: Setting
the second parameter to NULL lets the function return the total size of the
GLYPHSET structure. This will not help you to get the full GLYPHSET
structure in VB directly, but by this you can retrieve it indirectly.
Sample code ('on the fly'):
Private Declare Function GetFontUnicodeRanges _
Lib "gdi32.dll" _
( _
ByVal hDC As Long, _
pGLYPHSET As Any _
) As Long
Private Declare Sub CopyMemory _
Lib "kernel32" Alias "RtlMoveMemory" _
( _
pDestination As Any, _
pSource As Any, _
ByVal lByteCount As Long _
)
Private type typWCRANGE
iLow As Integer
iGlyphs As Integer
End Type
Private type typGLYPHSET
lStructSize As Long
lAccel As Long
lGlyphsSupported As Long
lRanges As Long
aRANGE() As typWCRANGE
End Type
Dim abData() As Byte, lIndexData As Long
Dim lResult As Long, lCount As Long, lIndex As Long
Dim GS as
lResult& = GetFontUnicodeRanges(hDC, ByVal 0&)
If lResult& Then
ReDim abData(0 To (lResult& - 1)) As Byte
lResult& = GetFontUnicodeRanges(hDC, abData(LBound(abData)))
If lResult& Then
lIndexData& = LBound(abData)
lCount& = 4& * 4&
Call CopyMemory(GS, abData(lIndexData), lCount&)
lIndexData& = lIndexData& + lCount&
With GS
If .lRanges& Then
ReDim .aRANGE(0 To (.lRanges& - 1)) As typWCRANGE
lIndex& = LBound(.aRANGE)
lCount = .lRanges&
While lCount&
Call CopyMemory(.aRANGE(lIndex&), abData(lIndexData&),
Len(.aRANGE(lIndex&)))
lIndexData& = lIndexData& + Len(.aRANGE(lIndex&))
lIndex& = lIndex& + 1
lCount& = lCount& - 1
Wend
End If
End With
End If
End If

Signature
----------------------------------------------------------------------
THORSTEN ALBERS Universität Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------
Gary - 27 Mar 2006 16:19 GMT
Thorsten,
Thanks lot for your help. It works perfectly. You solved a big issue for me
Sorry that I didn't see your original post before I replied to you.
Gary
> Gary <Gary@discussions.microsoft.com> schrieb im Beitrag
> <71AFA002-22B4-41BE-992C-19C06DEDAC22@microsoft.com>...
[quoted text clipped - 78 lines]
> End If
> End If