' ########################################################################################
' Microsoft Windows
' File: t2embapi.inc
' Contents: OpenType embedding services dll (T2EMBED.DLL)
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_t2embapi_PBI)
#DEFINE PBX_t2embapi_PBI
%EQUATE `T2EMBAPI_INC = 1
'// Charset flags for ulCharSet field of TTEmbedFont
%EQUATE `CHARSET_UNICODE = 1
%EQUATE `CHARSET_DEFAULT = 1
%EQUATE `CHARSET_SYMBOL = 2
%EQUATE `CHARSET_GLYPHIDX = 3
'// Status returned by TTLoadEmbeddedFont
%EQUATE `EMBED_PREVIEWPRINT = 1
%EQUATE `EMBED_EDITABLE = 2
%EQUATE `EMBED_INSTALLABLE = 3
%EQUATE `EMBED_NOEMBEDDING = 4
'// Use restriction flags
%EQUATE `LICENSE_INSTALLABLE = &H0000
%EQUATE `LICENSE_DEFAULT = &H0000
%EQUATE `LICENSE_NOEMBEDDING = &H0002
%EQUATE `LICENSE_PREVIEWPRINT = &H0004
%EQUATE `LICENSE_EDITABLE = &H0008
'// Options given to TTEmbedFont in uFlags parameter
%EQUATE `TTEMBED_RAW = &H00000000
%EQUATE `TTEMBED_SUBSET = &H00000001
%EQUATE `TTEMBED_TTCOMPRESSED = &H00000004
%EQUATE `TTEMBED_FAILIFVARIATIONSIMULATED = &H00000010
'// Embed EUDC font. If there is typeface EUDC embed it otherwise embed system EUDC.
%EQUATE `TTEMBED_EMBEDEUDC = &H00000020
%EQUATE `TTEMBED_WEBOBJECT = &H00000080
%EQUATE `TTEMBED_XORENCRYPTDATA = &H10000000
'// Bits returned through pulStatus for TTEmbedFont
%EQUATE `TTEMBED_VARIATIONSIMULATED = &H00000001
'// Bit set if EUDC embed success.
%EQUATE `TTEMBED_EUDCEMBEDDED = &H00000002
'// Bit set if font embedding permissions indicate no subset and subset requested by client.
%EQUATE `TTEMBED_SUBSETCANCEL = &H00000004
'// Flag options for TTLoadEmbeddedFont
%EQUATE `TTLOAD_PRIVATE = &H00000001
'// If typeface already has EUDC, overwrite setting.
%EQUATE `TTLOAD_EUDC_OVERWRITE = &H00000002
'// Bits returned through pulStatus for TTLoadEmbeddedFont
%EQUATE `TTLOAD_FONT_SUBSETTED = &H00000001
%EQUATE `TTLOAD_FONT_IN_SYSSTARTUP = &H00000002
%EQUATE `TTLOAD_EUDC_SET = &H00000004
'// Flag options for TTDeleteEmbeddedFont
%EQUATE `TTDELETE_DONTREMOVEFONT = &H00000001
'// Error codes
%EQUATE `E_NONE = &H0000&
%EQUATE `E_API_NOTIMPL = &H0001&
'// Top level error codes
%EQUATE `E_CHARCODECOUNTINVALID = &H0002&
%EQUATE `E_CHARCODESETINVALID = &H0003&
%EQUATE `E_DEVICETRUETYPEFONT = &H0004&
%EQUATE `E_HDCINVALID = &H0006&
%EQUATE `E_NOFREEMEMORY = &H0007&
%EQUATE `E_FONTREFERENCEINVALID = &H0008&
%EQUATE `E_NOTATRUETYPEFONT = &H000A&
%EQUATE `E_ERRORACCESSINGFONTDATA = &H000C&
%EQUATE `E_ERRORACCESSINGFACENAME = &H000D&
%EQUATE `E_ERRORUNICODECONVERSION = &H0011&
%EQUATE `E_ERRORCONVERTINGCHARS = &H0012&
%EQUATE `E_EXCEPTION = &H0013&
%EQUATE `E_RESERVEDPARAMNOTNULL = &H0014&
%EQUATE `E_CHARSETINVALID = &H0015&
%EQUATE `E_FILE_NOT_FOUND = &H0017&
%EQUATE `E_TTC_INDEX_OUT_OF_RANGE = &H0018&
%EQUATE `E_INPUTPARAMINVALID = &H0019&
'// Indep level error codes
%EQUATE `E_ERRORCOMPRESSINGFONTDATA = &H0100&
%EQUATE `E_FONTDATAINVALID = &H0102&
%EQUATE `E_NAMECHANGEFAILED = &H0103&
%EQUATE `E_FONTNOTEMBEDDABLE = &H0104&
%EQUATE `E_PRIVSINVALID = &H0105&
%EQUATE `E_SUBSETTINGFAILED = &H0106&
%EQUATE `E_READFROMSTREAMFAILED = &H0107&
%EQUATE `E_SAVETOSTREAMFAILED = &H0108&
%EQUATE `E_NOOS2 = &H0109&
%EQUATE `E_T2NOFREEMEMORY = &H010A&
%EQUATE `E_ERRORREADINGFONTDATA = &H010B&
%EQUATE `E_FLAGSINVALID = &H010C&
%EQUATE `E_ERRORCREATINGFONTFILE = &H010D&
%EQUATE `E_FONTALREADYEXISTS = &H010E&
%EQUATE `E_FONTNAMEALREADYEXISTS = &H010F&
%EQUATE `E_FONTINSTALLFAILED = &H0110&
%EQUATE `E_ERRORDECOMPRESSINGFONTDATA = &H0111&
%EQUATE `E_ERRORACCESSINGEXCLUDELIST = &H0112&
%EQUATE `E_FACENAMEINVALID = &H0113&
%EQUATE `E_STREAMINVALID = &H0114&
%EQUATE `E_STATUSINVALID = &H0115&
%EQUATE `E_PRIVSTATUSINVALID = &H0116&
%EQUATE `E_PERMISSIONSINVALID = &H0117&
%EQUATE `E_PBENABLEDINVALID = &H0118&
%EQUATE `E_SUBSETTINGEXCEPTION = &H0119&
%EQUATE `E_SUBSTRING_TEST_FAIL = &H011A&
%EQUATE `E_FONTVARIATIONSIMULATED = &H011B&
%EQUATE `E_FONTFAMILYNAMENOTINFULL = &H011D&
'// Bottom level error codes
%EQUATE `E_ADDFONTFAILED = &H0200&
%EQUATE `E_COULDNTCREATETEMPFILE = &H0201&
%EQUATE `E_FONTFILECREATEFAILED = &H0203&
%EQUATE `E_WINDOWSAPI = &H0204&
%EQUATE `E_FONTFILENOTFOUND = &H0205&
%EQUATE `E_RESOURCEFILECREATEFAILED = &H0206&
%EQUATE `E_ERROREXPANDINGFONTDATA = &H0207&
%EQUATE `E_ERRORGETTINGDC = &H0208&
%EQUATE `E_EXCEPTIONINDECOMPRESSION = &H0209&
%EQUATE `E_EXCEPTIONINCOMPRESSION = &H020A&
'// 1st argument - Stream identifier (file handle or other) (dwStream) */
'// 2nd argument - Address of buffer with data to read or write */
'// 3rd argument - Number of bytes to read or write */
'typedef unsigned long( WINAPIV *READEMBEDPROC ) ( void*, void*, const unsigned long );
'FUNCTION READEMBEDPROC ( ' BYVAL lpvReadStream AS DWORD
' , BYVAL lpvBuffer AS DWORD
' , BYVAL cbBuffer AS DWORD
' ) AS DWORD ' unsigned long
'typedef unsigned long( WINAPIV *WRITEEMBEDPROC ) ( void*, const void*, const unsigned long );
'FUNCTION WRITEEMBEDPROC ( ' BYVAL lpvReadStream AS DWORD
' , BYVAL lpvBuffer AS DWORD
' , BYVAL cbBuffer AS DWORD
' ) AS DWORD ' unsigned long
' // Size = 8 bytes
TYPE TTLOADINFO DWORD FILL
 usStructSize AS WORD ' unsigned short // size in bytes of structure client should set to sizeof(TTLOADINFO)
 usRefStrSize AS WORD ' unsigned short // size in wide characters of pusRefStr including NULL terminator
 pusRefStr AS WSTRINGZ PTR ' unsigned short * // reference or actual string.
END TYPE
' // Size = 8 bytes
TYPE TTEMBEDINFO DWORD FILL
 usStructSize AS WORD ' unsigned short // size in bytes of structure client should set to sizeof(TTEMBEDINFO)
 usRootStrSize AS WORD ' unsigned short // size in wide chars of pusSubStr including NULL terminator(s)
 pusRootStr AS WSTRINGZ PTR ' unsigned short * // substring(s) of strings given at load time. can have multiple strings separated
 ' // by a NULL terminator.
END TYPE
' // Size = 24 bytes
TYPE TTVALIDATIONTESTSPARAMS DWORD FILL
 ulStructSize AS DWORD ' unsigned long
 lTestFromSize AS LONG ' long
 lTestToSize AS LONG ' long
 ulCharSet AS DWORD ' unsigned long // Same as ulCharSet param to TTEmbedFont.
 usReserved1 AS WORD ' unsigned short
 usCharCodeCount AS WORD ' unsigned short // If zero, we test over all glyphs.
 pusCharCodeSet AS WSTRINGZ PTR ' unsigned short * // Pointer to array of Unicode chars.
END TYPE
' // Size = 24 bytes
TYPE TTVALIDATIONTESTSPARAMSEX DWORD FILL
 ulStructSize AS DWORD ' unsigned loong
 lTestFromSize AS LONG ' long
 lTestToSize AS LONG ' long
 ulCharSet AS DWORD ' unsigned loong // Same as ulCharSet param to TTEmbedFont.
 usReserved1 AS WORD ' unsigned short
 usCharCodeCount AS WORD ' unsigned short // If zero, we test over all glyphs.
 pulCharCodeSet AS WSTRINGZ PTR ' unsigned short * // Pointer to array of Unicode chars.
END TYPE
'/* Font Embedding APIs ----------------------------------------------------*/
DECLARE FUNCTION TTEmbedFont LIB "t2embed.dll" ALIAS "TTEmbedFont" ( BYVAL hDC AS QUAD , BYVAL ulFlags AS QUAD , BYVAL ulCharSet AS QUAD , BYREF pulPrivStatus AS QUAD , BYREF pulStatus AS QUAD , BYVAL lpfnWriteToStream AS QUAD , BYVAL lpvWriteStream AS QUAD , BYREF pusCharCodeSet AS WORD , BYVAL usCharCodeCount AS WORD , BYVAL usLanguage AS WORD , BYREF pTTEmbedInfo AS TTEMBEDINFO ) AS LONG
DECLARE FUNCTION TTEmbedFontFromFileA LIB "t2embed.dll" ALIAS "TTEmbedFontFromFileA" ( BYVAL hDC AS QUAD
 , BYREF szFontFileName AS ASCIIZ
 , BYVAL usTTCIndex AS WORD
 , BYVAL ulFlags AS DWORD
 , BYVAL ulCharSet AS DWORD
 , BYREF pulPrivStatus AS DWORD
 , BYREF pulStatus AS DWORD
 , BYVAL lpfnWriteToStream AS DWORD
 , BYVAL lpvWriteStream AS DWORD
 , BYREF pusCharCodeSet AS WORD
 , BYVAL usCharCodeCount AS WORD
 , BYVAL usLanguage AS WORD
 , BYREF pTTEmbedInfo AS TTEMBEDINFO
 ) AS LONG
DECLARE FUNCTION TTLoadEmbeddedFont LIB "t2embed.dll" ALIAS "TTLoadEmbeddedFont" ( BYREF phFontReference AS DWORD
 , BYVAL ulFlags AS DWORD
 , BYREF pulPrivStatus AS DWORD
 , BYVAL ulPrivs AS DWORD
 , BYREF pulStatus AS DWORD
 , BYVAL lpfnReadFromStream AS DWORD
 , BYVAL lpvReadStream AS DWORD
 , BYREF szWinFamilyName AS WSTRINGZ
 , BYREF szMacFamilyName AS ASCIIZ
 , BYREF pTTLoadInfo AS TTLOADINFO
 ) AS LONG
DECLARE FUNCTION TTGetEmbeddedFontInfo LIB "t2embed.dll" ALIAS "TTGetEmbeddedFontInfo" ( BYVAL ulFlags AS DWORD
 , BYREF pulPrivStatus AS DWORD
 , BYVAL ulPrivs AS DWORD
 , BYREF pulStatus AS DWORD
 , BYVAL lpfnReadFromStream AS DWORD
 , BYVAL lpvReadStream AS DWORD
 , BYREF pTTLoadInfo AS TTLOADINFO
 ) AS LONG
DECLARE FUNCTION TTDeleteEmbeddedFont LIB "t2embed.dll" ALIAS "TTDeleteEmbeddedFont" ( BYVAL hFontReference AS DWORD
 , BYVAL ulFlags AS DWORD
 , BYREF pulStatus AS DWORD
 ) AS LONG
DECLARE FUNCTION TTGetEmbeddingType LIB "t2embed.dll" ALIAS "TTGetEmbeddingType" ( BYVAL hDC AS DWORD
 , BYREF pulEmbedType AS DWORD
 ) AS LONG
DECLARE FUNCTION TTCharToUnicode LIB "t2embed.dll" ALIAS "TTCharToUnicode" ( BYVAL hDC AS DWORD
 , BYREF pucCharCodes AS BYTE
 , BYVAL ulCharCodeSize AS DWORD
 , BYREF pusShortCodes AS WORD
 , BYVAL ulShortCodeSize AS DWORD
 , BYVAL ulFlags AS DWORD
 ) AS LONG
DECLARE FUNCTION TTRunValidationTests LIB "t2embed.dll" ALIAS "TTRunValidationTests" ( BYVAL hDC AS DWORD
 , BYREF pTestParam AS TTVALIDATIONTESTSPARAMS
 ) AS LONG
'/* Font Enabling APIs -----------------------------------------------------*/
DECLARE FUNCTION TTIsEmbeddingEnabled LIB "t2embed.dll" ALIAS "TTIsEmbeddingEnabled" ( BYVAL hDC AS QUAD , BYREF pbEnabled AS LONG ) AS LONG
DECLARE FUNCTION TTIsEmbeddingEnabledForFacename LIB "t2embed.dll" ALIAS "TTIsEmbeddingEnabledForFacename" ( BYREF lpszFacename AS ASCIIZ
 , BYREF pbEnabled AS LONG
 ) AS LONG
' If fEnable != 0, it removes the indicated typeface name from the "embedding
' exclusion list". Else, it enters the indicated typeface name in the "embedding exclusion list".
DECLARE FUNCTION TTEnableEmbeddingForFacename LIB "t2embed.dll" ALIAS "TTEnableEmbeddingForFacename" ( BYREF lpszFacename AS ASCIIZ , BYVAL bEnable AS LONG ) AS LONG
DECLARE FUNCTION TTEmbedFontEx LIB "t2embed.dll" ALIAS "TTEmbedFontEx" ( BYVAL hDC AS QUAD
 , BYVAL ulFlags AS DWORD
 , BYVAL ulCharSet AS DWORD
 , BYREF pulPrivStatus AS DWORD
 , BYREF pulStatus AS DWORD
 , BYVAL lpfnWriteToStream AS DWORD
 , BYVAL lpvWriteStream AS DWORD
 , BYREF pulCharCodeSet AS DWORD
 , BYVAL usCharCodeCount AS WORD
 , BYVAL usLanguage AS WORD
 , BYREF pTTEmbedInfo AS TTEMBEDINFO
 ) AS LONG
DECLARE FUNCTION TTRunValidationTestsEx LIB "t2embed.dll" ALIAS "TTRunValidationTestsEx" ( BYVAL hDC AS DWORD
 , BYREF pTestParam AS TTVALIDATIONTESTSPARAMSEX
 ) AS LONG
DECLARE FUNCTION TTGetNewFontName LIB "t2embed.dll" ALIAS "TTGetNewFontName" ( BYVAL phFontReference AS DWORD
 , BYREF wzWinFamilyName AS WSTRINGZ
 , BYVAL cchMaxWinName AS LONG
 , BYREF szMacFamilyName AS ASCIIZ
 , BYVAL cchMaxMacName AS LONG
 ) AS LONG
#ENDIF
