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インストール済みの埋め込みフォントを識別するハンドル。このハンドルは Hfont ではなく、内部構造体を参照します。
wzWinFamilyNameLPWSTRout新しい 16 ビット文字の Microsoft Windows ファミリ名を格納するバッファ。
cchMaxWinNameINTinWindows 名 (szWinFamilyName) 用に確保された文字列の長さ。少なくとも LF_FACESIZE 以上である必要があります。
szMacFamilyNameLPSTRout新しい 8 ビット文字の MacIntosh ファミリ名を格納するバッファ。
cchMaxMacNameINTinMacintosh 名 (szMacFamilyName) 用に確保された文字列の長さ。少なくとも LF_FACESIZE 以上である必要があります。

戻り値の型: INT

公式ドキュメント

TTLoadEmbeddedFont を通じて読み込まれたフォントのファミリ名を取得します。

戻り値

成功した場合は E_NONE を返します。

フォントのファミリ名は、szWinFamilyName または szMacFamilyName 内の文字列として格納されます。

それ以外の場合は、Embedding-Function Error Messages に記載されているエラー コードを返します。

解説(Remarks)

注意 この関数は、Windows 用または MacIntosh 用のいずれか適切な文字列バッファにフォントのファミリ名を返します。もう一方のオペレーティング システム用のバッファは使用されません。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// 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)。
const std = @import("std");

extern "t2embed" fn TTGetNewFontName(
    phFontReference: ?*anyopaque, // HANDLE*
    wzWinFamilyName: [*c]u16, // LPWSTR out
    cchMaxWinName: i32, // INT
    szMacFamilyName: [*c]u8, // LPSTR out
    cchMaxMacName: i32 // INT
) callconv(std.os.windows.WINAPI) i32;
proc TTGetNewFontName(
    phFontReference: pointer,  # HANDLE*
    wzWinFamilyName: ptr uint16,  # LPWSTR out
    cchMaxWinName: int32,  # INT
    szMacFamilyName: ptr char,  # LPSTR out
    cchMaxMacName: int32  # INT
): int32 {.importc: "TTGetNewFontName", stdcall, dynlib: "t2embed.dll".}
pragma(lib, "t2embed");
extern(Windows)
int TTGetNewFontName(
    void* phFontReference,   // HANDLE*
    wchar* wzWinFamilyName,   // LPWSTR out
    int cchMaxWinName,   // INT
    char* szMacFamilyName,   // LPSTR out
    int cchMaxMacName   // INT
);
ccall((:TTGetNewFontName, "t2embed.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{UInt16}, Int32, Ptr{UInt8}, Int32),
      phFontReference, wzWinFamilyName, cchMaxWinName, szMacFamilyName, cchMaxMacName)
# phFontReference : HANDLE* -> Ptr{Cvoid}
# wzWinFamilyName : LPWSTR out -> Ptr{UInt16}
# cchMaxWinName : INT -> Int32
# szMacFamilyName : LPSTR out -> Ptr{UInt8}
# cchMaxMacName : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t TTGetNewFontName(
    void* phFontReference,
    uint16_t* wzWinFamilyName,
    int32_t cchMaxWinName,
    char* szMacFamilyName,
    int32_t cchMaxMacName);
]]
local t2embed = ffi.load("t2embed")
-- t2embed.TTGetNewFontName(phFontReference, wzWinFamilyName, cchMaxWinName, szMacFamilyName, cchMaxMacName)
-- phFontReference : HANDLE*
-- wzWinFamilyName : LPWSTR out
-- cchMaxWinName : INT
-- szMacFamilyName : LPSTR out
-- cchMaxMacName : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('t2embed.dll');
const TTGetNewFontName = lib.func('__stdcall', 'TTGetNewFontName', 'int32_t', ['void *', 'uint16_t *', 'int32_t', 'char *', 'int32_t']);
// TTGetNewFontName(phFontReference, wzWinFamilyName, cchMaxWinName, szMacFamilyName, cchMaxMacName)
// phFontReference : HANDLE* -> 'void *'
// wzWinFamilyName : LPWSTR out -> 'uint16_t *'
// cchMaxWinName : INT -> 'int32_t'
// szMacFamilyName : LPSTR out -> 'char *'
// cchMaxMacName : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("t2embed.dll", {
  TTGetNewFontName: { parameters: ["pointer", "buffer", "i32", "buffer", "i32"], result: "i32" },
});
// lib.symbols.TTGetNewFontName(phFontReference, wzWinFamilyName, cchMaxWinName, szMacFamilyName, cchMaxMacName)
// phFontReference : HANDLE* -> "pointer"
// wzWinFamilyName : LPWSTR out -> "buffer"
// cchMaxWinName : INT -> "i32"
// szMacFamilyName : LPSTR out -> "buffer"
// cchMaxMacName : INT -> "i32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t TTGetNewFontName(
    void* phFontReference,
    uint16_t* wzWinFamilyName,
    int32_t cchMaxWinName,
    char* szMacFamilyName,
    int32_t cchMaxMacName);
C, "t2embed.dll");
// $ffi->TTGetNewFontName(phFontReference, wzWinFamilyName, cchMaxWinName, szMacFamilyName, cchMaxMacName);
// phFontReference : HANDLE*
// wzWinFamilyName : LPWSTR out
// cchMaxWinName : INT
// szMacFamilyName : LPSTR out
// cchMaxMacName : INT
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface T2embed extends StdCallLibrary {
    T2embed INSTANCE = Native.load("t2embed", T2embed.class);
    int TTGetNewFontName(
        Pointer phFontReference,   // HANDLE*
        char[] wzWinFamilyName,   // LPWSTR out
        int cchMaxWinName,   // INT
        byte[] szMacFamilyName,   // LPSTR out
        int cchMaxMacName   // INT
    );
}
@[Link("t2embed")]
lib Libt2embed
  fun TTGetNewFontName = TTGetNewFontName(
    phFontReference : Void*,   # HANDLE*
    wzWinFamilyName : UInt16*,   # LPWSTR out
    cchMaxWinName : Int32,   # INT
    szMacFamilyName : UInt8*,   # LPSTR out
    cchMaxMacName : Int32   # INT
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef TTGetNewFontNameNative = Int32 Function(Pointer<Void>, Pointer<Utf16>, Int32, Pointer<Utf8>, Int32);
typedef TTGetNewFontNameDart = int Function(Pointer<Void>, Pointer<Utf16>, int, Pointer<Utf8>, int);
final TTGetNewFontName = DynamicLibrary.open('t2embed.dll')
    .lookupFunction<TTGetNewFontNameNative, TTGetNewFontNameDart>('TTGetNewFontName');
// phFontReference : HANDLE* -> Pointer<Void>
// wzWinFamilyName : LPWSTR out -> Pointer<Utf16>
// cchMaxWinName : INT -> Int32
// szMacFamilyName : LPSTR out -> Pointer<Utf8>
// cchMaxMacName : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
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';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "TTGetNewFontName"
  c_TTGetNewFontName :: Ptr () -> CWString -> Int32 -> CString -> Int32 -> IO Int32
-- phFontReference : HANDLE* -> Ptr ()
-- wzWinFamilyName : LPWSTR out -> CWString
-- cchMaxWinName : INT -> Int32
-- szMacFamilyName : LPSTR out -> CString
-- cchMaxMacName : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let ttgetnewfontname =
  foreign "TTGetNewFontName"
    ((ptr void) @-> (ptr uint16_t) @-> int32_t @-> string @-> int32_t @-> returning int32_t)
(* phFontReference : HANDLE* -> (ptr void) *)
(* wzWinFamilyName : LPWSTR out -> (ptr uint16_t) *)
(* cchMaxWinName : INT -> int32_t *)
(* szMacFamilyName : LPSTR out -> string *)
(* cchMaxMacName : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library t2embed (t "t2embed.dll"))
(cffi:use-foreign-library t2embed)

(cffi:defcfun ("TTGetNewFontName" ttget-new-font-name :convention :stdcall) :int32
  (ph-font-reference :pointer)   ; HANDLE*
  (wz-win-family-name :pointer)   ; LPWSTR out
  (cch-max-win-name :int32)   ; INT
  (sz-mac-family-name :pointer)   ; LPSTR out
  (cch-max-mac-name :int32))   ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $TTGetNewFontName = Win32::API::More->new('t2embed',
    'int TTGetNewFontName(HANDLE phFontReference, LPWSTR wzWinFamilyName, int cchMaxWinName, LPSTR szMacFamilyName, int cchMaxMacName)');
# my $ret = $TTGetNewFontName->Call($phFontReference, $wzWinFamilyName, $cchMaxWinName, $szMacFamilyName, $cchMaxMacName);
# phFontReference : HANDLE* -> HANDLE
# wzWinFamilyName : LPWSTR out -> LPWSTR
# cchMaxWinName : INT -> int
# szMacFamilyName : LPSTR out -> LPSTR
# cchMaxMacName : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目