Win32 API 日本語リファレンス
ホームGraphics.Gdi › TTGetNewFontName

TTGetNewFontName

関数
読み込んだ埋め込みフォントに付与された新しい書体名を取得する。
DLLt2embed.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// t2embed.dll
#include <windows.h>

INT TTGetNewFontName(
    HANDLE* phFontReference,
    LPWSTR wzWinFamilyName,
    INT cchMaxWinName,
    LPSTR szMacFamilyName,
    INT cchMaxMacName
);

パラメーター

名前方向
phFontReferenceHANDLE*in
wzWinFamilyNameLPWSTRout
cchMaxWinNameINTin
szMacFamilyNameLPSTRout
cchMaxMacNameINTin

戻り値の型: INT

各言語での呼び出し定義

// t2embed.dll
#include <windows.h>

INT TTGetNewFontName(
    HANDLE* phFontReference,
    LPWSTR wzWinFamilyName,
    INT cchMaxWinName,
    LPSTR szMacFamilyName,
    INT cchMaxMacName
);
[DllImport("t2embed.dll", ExactSpelling = true)]
static extern int TTGetNewFontName(
    IntPtr phFontReference,   // HANDLE*
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder wzWinFamilyName,   // LPWSTR out
    int cchMaxWinName,   // INT
    [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szMacFamilyName,   // LPSTR out
    int cchMaxMacName   // INT
);
<DllImport("t2embed.dll", ExactSpelling:=True)>
Public Shared Function TTGetNewFontName(
    phFontReference As IntPtr,   ' HANDLE*
    <MarshalAs(UnmanagedType.LPWStr)> wzWinFamilyName As System.Text.StringBuilder,   ' LPWSTR out
    cchMaxWinName As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPStr)> szMacFamilyName As System.Text.StringBuilder,   ' LPSTR out
    cchMaxMacName As Integer   ' INT
) As Integer
End Function
' phFontReference : HANDLE*
' wzWinFamilyName : LPWSTR out
' cchMaxWinName : INT
' szMacFamilyName : LPSTR out
' cchMaxMacName : INT
Declare PtrSafe Function TTGetNewFontName Lib "t2embed" ( _
    ByVal phFontReference As LongPtr, _
    ByVal wzWinFamilyName As LongPtr, _
    ByVal cchMaxWinName As Long, _
    ByVal szMacFamilyName As String, _
    ByVal cchMaxMacName As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

TTGetNewFontName = ctypes.windll.t2embed.TTGetNewFontName
TTGetNewFontName.restype = ctypes.c_int
TTGetNewFontName.argtypes = [
    ctypes.c_void_p,  # phFontReference : HANDLE*
    wintypes.LPWSTR,  # wzWinFamilyName : LPWSTR out
    ctypes.c_int,  # cchMaxWinName : INT
    wintypes.LPSTR,  # szMacFamilyName : LPSTR out
    ctypes.c_int,  # cchMaxMacName : INT
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('t2embed.dll')
TTGetNewFontName = Fiddle::Function.new(
  lib['TTGetNewFontName'],
  [
    Fiddle::TYPE_VOIDP,  # phFontReference : HANDLE*
    Fiddle::TYPE_VOIDP,  # wzWinFamilyName : LPWSTR out
    Fiddle::TYPE_INT,  # cchMaxWinName : INT
    Fiddle::TYPE_VOIDP,  # szMacFamilyName : LPSTR out
    Fiddle::TYPE_INT,  # cchMaxMacName : INT
  ],
  Fiddle::TYPE_INT)
#[link(name = "t2embed")]
extern "system" {
    fn TTGetNewFontName(
        phFontReference: *mut *mut core::ffi::c_void,  // HANDLE*
        wzWinFamilyName: *mut u16,  // LPWSTR out
        cchMaxWinName: i32,  // INT
        szMacFamilyName: *mut u8,  // LPSTR out
        cchMaxMacName: i32  // INT
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("t2embed.dll")]
public static extern int TTGetNewFontName(IntPtr phFontReference, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder wzWinFamilyName, int cchMaxWinName, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder szMacFamilyName, int cchMaxMacName);
"@
$api = Add-Type -MemberDefinition $sig -Name 't2embed_TTGetNewFontName' -Namespace Win32 -PassThru
# $api::TTGetNewFontName(phFontReference, wzWinFamilyName, cchMaxWinName, szMacFamilyName, cchMaxMacName)
#uselib "t2embed.dll"
#func global TTGetNewFontName "TTGetNewFontName" sptr, sptr, sptr, sptr, sptr
; TTGetNewFontName phFontReference, varptr(wzWinFamilyName), cchMaxWinName, varptr(szMacFamilyName), cchMaxMacName   ; 戻り値は stat
; phFontReference : HANDLE* -> "sptr"
; wzWinFamilyName : LPWSTR out -> "sptr"
; cchMaxWinName : INT -> "sptr"
; szMacFamilyName : LPSTR out -> "sptr"
; cchMaxMacName : INT -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "t2embed.dll"
#cfunc global TTGetNewFontName "TTGetNewFontName" sptr, var, int, var, int
; res = TTGetNewFontName(phFontReference, wzWinFamilyName, cchMaxWinName, szMacFamilyName, cchMaxMacName)
; phFontReference : HANDLE* -> "sptr"
; wzWinFamilyName : LPWSTR out -> "var"
; cchMaxWinName : INT -> "int"
; szMacFamilyName : LPSTR out -> "var"
; cchMaxMacName : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT TTGetNewFontName(HANDLE* phFontReference, LPWSTR wzWinFamilyName, INT cchMaxWinName, LPSTR szMacFamilyName, INT cchMaxMacName)
#uselib "t2embed.dll"
#cfunc global TTGetNewFontName "TTGetNewFontName" intptr, var, int, var, int
; res = TTGetNewFontName(phFontReference, wzWinFamilyName, cchMaxWinName, szMacFamilyName, cchMaxMacName)
; phFontReference : HANDLE* -> "intptr"
; wzWinFamilyName : LPWSTR out -> "var"
; cchMaxWinName : INT -> "int"
; szMacFamilyName : LPSTR out -> "var"
; cchMaxMacName : INT -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	t2embed = windows.NewLazySystemDLL("t2embed.dll")
	procTTGetNewFontName = t2embed.NewProc("TTGetNewFontName")
)

// phFontReference (HANDLE*), wzWinFamilyName (LPWSTR out), cchMaxWinName (INT), szMacFamilyName (LPSTR out), cchMaxMacName (INT)
r1, _, err := procTTGetNewFontName.Call(
	uintptr(phFontReference),
	uintptr(wzWinFamilyName),
	uintptr(cchMaxWinName),
	uintptr(szMacFamilyName),
	uintptr(cchMaxMacName),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT
function TTGetNewFontName(
  phFontReference: Pointer;   // HANDLE*
  wzWinFamilyName: PWideChar;   // LPWSTR out
  cchMaxWinName: Integer;   // INT
  szMacFamilyName: PAnsiChar;   // LPSTR out
  cchMaxMacName: Integer   // INT
): Integer; stdcall;
  external 't2embed.dll' name 'TTGetNewFontName';
result := DllCall("t2embed\TTGetNewFontName"
    , "Ptr", phFontReference   ; HANDLE*
    , "Ptr", wzWinFamilyName   ; LPWSTR out
    , "Int", cchMaxWinName   ; INT
    , "Ptr", szMacFamilyName   ; LPSTR out
    , "Int", cchMaxMacName   ; INT
    , "Int")   ; return: INT
●TTGetNewFontName(phFontReference, wzWinFamilyName, cchMaxWinName, szMacFamilyName, cchMaxMacName) = DLL("t2embed.dll", "int TTGetNewFontName(void*, char*, int, char*, int)")
# 呼び出し: TTGetNewFontName(phFontReference, wzWinFamilyName, cchMaxWinName, szMacFamilyName, cchMaxMacName)
# phFontReference : HANDLE* -> "void*"
# wzWinFamilyName : LPWSTR out -> "char*"
# cchMaxWinName : INT -> "int"
# szMacFamilyName : LPSTR out -> "char*"
# cchMaxMacName : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。