Win32 API 日本語リファレンス
ホームGlobalization › ScriptSubstituteSingleGlyph

ScriptSubstituteSingleGlyph

関数
指定OpenType機能で単一グリフを置換する。
DLLUSP10.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT ScriptSubstituteSingleGlyph(
    HDC hdc,   // optional
    void** psc,
    SCRIPT_ANALYSIS* psa,   // optional
    DWORD tagScript,
    DWORD tagLangSys,
    DWORD tagFeature,
    INT lParameter,
    WORD wGlyphId,
    WORD* pwOutGlyphId
);

パラメーター

名前方向説明
hdcHDCinoptionalデバイスコンテキストのハンドル。詳細については、Caching を参照してください。
pscvoid**inoutスクリプトキャッシュを示す SCRIPT_CACHE 構造体へのポインター。
psaSCRIPT_ANALYSIS*inoptional

以前の ScriptItemizeOpenType の呼び出しから取得した SCRIPT_ANALYSIS 構造体へのポインター。このパラメーターはシェーピングエンジンを識別し、正しい代替グリフが使用されるようにします。

また、フィルター処理されていない結果を取得するために、アプリケーションはこのパラメーターを NULL に設定することもできます。

tagScriptDWORDinシェーピング用のスクリプトタグを定義する OPENTYPE_TAG 構造体。
tagLangSysDWORDinシェーピング用の言語タグを定義する OPENTYPE_TAG 構造体。
tagFeatureDWORDin代替グリフのシェーピングに使用するフィーチャータグを定義する OPENTYPE_TAG 構造体。
lParameterINTin置換する代替グリフへの参照。この参照は、OPENTYPE_FEATURE_RECORD に示されているように、フィーチャーで定義されたすべての代替グリフを含む配列へのインデックスです。代替グリフ配列は、ScriptGetFontAlternateGlyphs によって取得される項目の 1 つです。
wGlyphIdWORDin元のグリフの識別子。
pwOutGlyphIdWORD*outこの関数が代替グリフの識別子を取得する場所へのポインター。

戻り値の型: HRESULT

公式ドキュメント

OpenType 処理において、単一のグリフを同じグリフの 1 つの代替形に置換できるようにします。

戻り値

成功した場合は 0 を返します。成功しなかった場合、関数は 0 以外の HRESULT 値を返します。アプリケーションは SUCCEEDED および FAILED マクロを使用して戻り値をテストできます。

解説(Remarks)

この関数は 1 対 1 の置換を使用し、アプリケーションは 1 つのグリフを 1 つの代替形に置換できます。アプリケーションは多くの場合、行頭または行末に箇条書きの記号や代替グリフを設定するためにこの関数を使用します。

重要 Windows 8 以降: Windows 7 上で実行できるようにするには、Uniscribe を使用するモジュールは、ライブラリリスト内で gdi32.lib より前に Usp10.lib を指定する必要があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

HRESULT ScriptSubstituteSingleGlyph(
    HDC hdc,   // optional
    void** psc,
    SCRIPT_ANALYSIS* psa,   // optional
    DWORD tagScript,
    DWORD tagLangSys,
    DWORD tagFeature,
    INT lParameter,
    WORD wGlyphId,
    WORD* pwOutGlyphId
);
[DllImport("USP10.dll", ExactSpelling = true)]
static extern int ScriptSubstituteSingleGlyph(
    IntPtr hdc,   // HDC optional
    IntPtr psc,   // void** in/out
    IntPtr psa,   // SCRIPT_ANALYSIS* optional
    uint tagScript,   // DWORD
    uint tagLangSys,   // DWORD
    uint tagFeature,   // DWORD
    int lParameter,   // INT
    ushort wGlyphId,   // WORD
    out ushort pwOutGlyphId   // WORD* out
);
<DllImport("USP10.dll", ExactSpelling:=True)>
Public Shared Function ScriptSubstituteSingleGlyph(
    hdc As IntPtr,   ' HDC optional
    psc As IntPtr,   ' void** in/out
    psa As IntPtr,   ' SCRIPT_ANALYSIS* optional
    tagScript As UInteger,   ' DWORD
    tagLangSys As UInteger,   ' DWORD
    tagFeature As UInteger,   ' DWORD
    lParameter As Integer,   ' INT
    wGlyphId As UShort,   ' WORD
    <Out> ByRef pwOutGlyphId As UShort   ' WORD* out
) As Integer
End Function
' hdc : HDC optional
' psc : void** in/out
' psa : SCRIPT_ANALYSIS* optional
' tagScript : DWORD
' tagLangSys : DWORD
' tagFeature : DWORD
' lParameter : INT
' wGlyphId : WORD
' pwOutGlyphId : WORD* out
Declare PtrSafe Function ScriptSubstituteSingleGlyph Lib "usp10" ( _
    ByVal hdc As LongPtr, _
    ByVal psc As LongPtr, _
    ByVal psa As LongPtr, _
    ByVal tagScript As Long, _
    ByVal tagLangSys As Long, _
    ByVal tagFeature As Long, _
    ByVal lParameter As Long, _
    ByVal wGlyphId As Integer, _
    ByRef pwOutGlyphId As Integer) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ScriptSubstituteSingleGlyph = ctypes.windll.usp10.ScriptSubstituteSingleGlyph
ScriptSubstituteSingleGlyph.restype = ctypes.c_int
ScriptSubstituteSingleGlyph.argtypes = [
    wintypes.HANDLE,  # hdc : HDC optional
    ctypes.c_void_p,  # psc : void** in/out
    ctypes.c_void_p,  # psa : SCRIPT_ANALYSIS* optional
    wintypes.DWORD,  # tagScript : DWORD
    wintypes.DWORD,  # tagLangSys : DWORD
    wintypes.DWORD,  # tagFeature : DWORD
    ctypes.c_int,  # lParameter : INT
    ctypes.c_ushort,  # wGlyphId : WORD
    ctypes.POINTER(ctypes.c_ushort),  # pwOutGlyphId : WORD* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USP10.dll')
ScriptSubstituteSingleGlyph = Fiddle::Function.new(
  lib['ScriptSubstituteSingleGlyph'],
  [
    Fiddle::TYPE_VOIDP,  # hdc : HDC optional
    Fiddle::TYPE_VOIDP,  # psc : void** in/out
    Fiddle::TYPE_VOIDP,  # psa : SCRIPT_ANALYSIS* optional
    -Fiddle::TYPE_INT,  # tagScript : DWORD
    -Fiddle::TYPE_INT,  # tagLangSys : DWORD
    -Fiddle::TYPE_INT,  # tagFeature : DWORD
    Fiddle::TYPE_INT,  # lParameter : INT
    -Fiddle::TYPE_SHORT,  # wGlyphId : WORD
    Fiddle::TYPE_VOIDP,  # pwOutGlyphId : WORD* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "usp10")]
extern "system" {
    fn ScriptSubstituteSingleGlyph(
        hdc: *mut core::ffi::c_void,  // HDC optional
        psc: *mut *mut (),  // void** in/out
        psa: *mut SCRIPT_ANALYSIS,  // SCRIPT_ANALYSIS* optional
        tagScript: u32,  // DWORD
        tagLangSys: u32,  // DWORD
        tagFeature: u32,  // DWORD
        lParameter: i32,  // INT
        wGlyphId: u16,  // WORD
        pwOutGlyphId: *mut u16  // WORD* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USP10.dll")]
public static extern int ScriptSubstituteSingleGlyph(IntPtr hdc, IntPtr psc, IntPtr psa, uint tagScript, uint tagLangSys, uint tagFeature, int lParameter, ushort wGlyphId, out ushort pwOutGlyphId);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USP10_ScriptSubstituteSingleGlyph' -Namespace Win32 -PassThru
# $api::ScriptSubstituteSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, pwOutGlyphId)
#uselib "USP10.dll"
#func global ScriptSubstituteSingleGlyph "ScriptSubstituteSingleGlyph" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; ScriptSubstituteSingleGlyph hdc, psc, varptr(psa), tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, varptr(pwOutGlyphId)   ; 戻り値は stat
; hdc : HDC optional -> "sptr"
; psc : void** in/out -> "sptr"
; psa : SCRIPT_ANALYSIS* optional -> "sptr"
; tagScript : DWORD -> "sptr"
; tagLangSys : DWORD -> "sptr"
; tagFeature : DWORD -> "sptr"
; lParameter : INT -> "sptr"
; wGlyphId : WORD -> "sptr"
; pwOutGlyphId : WORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USP10.dll"
#cfunc global ScriptSubstituteSingleGlyph "ScriptSubstituteSingleGlyph" sptr, sptr, var, int, int, int, int, int, var
; res = ScriptSubstituteSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, pwOutGlyphId)
; hdc : HDC optional -> "sptr"
; psc : void** in/out -> "sptr"
; psa : SCRIPT_ANALYSIS* optional -> "var"
; tagScript : DWORD -> "int"
; tagLangSys : DWORD -> "int"
; tagFeature : DWORD -> "int"
; lParameter : INT -> "int"
; wGlyphId : WORD -> "int"
; pwOutGlyphId : WORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT ScriptSubstituteSingleGlyph(HDC hdc, void** psc, SCRIPT_ANALYSIS* psa, DWORD tagScript, DWORD tagLangSys, DWORD tagFeature, INT lParameter, WORD wGlyphId, WORD* pwOutGlyphId)
#uselib "USP10.dll"
#cfunc global ScriptSubstituteSingleGlyph "ScriptSubstituteSingleGlyph" intptr, intptr, var, int, int, int, int, int, var
; res = ScriptSubstituteSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, pwOutGlyphId)
; hdc : HDC optional -> "intptr"
; psc : void** in/out -> "intptr"
; psa : SCRIPT_ANALYSIS* optional -> "var"
; tagScript : DWORD -> "int"
; tagLangSys : DWORD -> "int"
; tagFeature : DWORD -> "int"
; lParameter : INT -> "int"
; wGlyphId : WORD -> "int"
; pwOutGlyphId : WORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	usp10 = windows.NewLazySystemDLL("USP10.dll")
	procScriptSubstituteSingleGlyph = usp10.NewProc("ScriptSubstituteSingleGlyph")
)

// hdc (HDC optional), psc (void** in/out), psa (SCRIPT_ANALYSIS* optional), tagScript (DWORD), tagLangSys (DWORD), tagFeature (DWORD), lParameter (INT), wGlyphId (WORD), pwOutGlyphId (WORD* out)
r1, _, err := procScriptSubstituteSingleGlyph.Call(
	uintptr(hdc),
	uintptr(psc),
	uintptr(psa),
	uintptr(tagScript),
	uintptr(tagLangSys),
	uintptr(tagFeature),
	uintptr(lParameter),
	uintptr(wGlyphId),
	uintptr(pwOutGlyphId),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function ScriptSubstituteSingleGlyph(
  hdc: THandle;   // HDC optional
  psc: Pointer;   // void** in/out
  psa: Pointer;   // SCRIPT_ANALYSIS* optional
  tagScript: DWORD;   // DWORD
  tagLangSys: DWORD;   // DWORD
  tagFeature: DWORD;   // DWORD
  lParameter: Integer;   // INT
  wGlyphId: Word;   // WORD
  pwOutGlyphId: Pointer   // WORD* out
): Integer; stdcall;
  external 'USP10.dll' name 'ScriptSubstituteSingleGlyph';
result := DllCall("USP10\ScriptSubstituteSingleGlyph"
    , "Ptr", hdc   ; HDC optional
    , "Ptr", psc   ; void** in/out
    , "Ptr", psa   ; SCRIPT_ANALYSIS* optional
    , "UInt", tagScript   ; DWORD
    , "UInt", tagLangSys   ; DWORD
    , "UInt", tagFeature   ; DWORD
    , "Int", lParameter   ; INT
    , "UShort", wGlyphId   ; WORD
    , "Ptr", pwOutGlyphId   ; WORD* out
    , "Int")   ; return: HRESULT
●ScriptSubstituteSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, pwOutGlyphId) = DLL("USP10.dll", "int ScriptSubstituteSingleGlyph(void*, void*, void*, dword, dword, dword, int, int, void*)")
# 呼び出し: ScriptSubstituteSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, pwOutGlyphId)
# hdc : HDC optional -> "void*"
# psc : void** in/out -> "void*"
# psa : SCRIPT_ANALYSIS* optional -> "void*"
# tagScript : DWORD -> "dword"
# tagLangSys : DWORD -> "dword"
# tagFeature : DWORD -> "dword"
# lParameter : INT -> "int"
# wGlyphId : WORD -> "int"
# pwOutGlyphId : WORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "usp10" fn ScriptSubstituteSingleGlyph(
    hdc: ?*anyopaque, // HDC optional
    psc: ?*anyopaque, // void** in/out
    psa: [*c]SCRIPT_ANALYSIS, // SCRIPT_ANALYSIS* optional
    tagScript: u32, // DWORD
    tagLangSys: u32, // DWORD
    tagFeature: u32, // DWORD
    lParameter: i32, // INT
    wGlyphId: u16, // WORD
    pwOutGlyphId: [*c]u16 // WORD* out
) callconv(std.os.windows.WINAPI) i32;
proc ScriptSubstituteSingleGlyph(
    hdc: pointer,  # HDC optional
    psc: pointer,  # void** in/out
    psa: ptr SCRIPT_ANALYSIS,  # SCRIPT_ANALYSIS* optional
    tagScript: uint32,  # DWORD
    tagLangSys: uint32,  # DWORD
    tagFeature: uint32,  # DWORD
    lParameter: int32,  # INT
    wGlyphId: uint16,  # WORD
    pwOutGlyphId: ptr uint16  # WORD* out
): int32 {.importc: "ScriptSubstituteSingleGlyph", stdcall, dynlib: "USP10.dll".}
pragma(lib, "usp10");
extern(Windows)
int ScriptSubstituteSingleGlyph(
    void* hdc,   // HDC optional
    void** psc,   // void** in/out
    SCRIPT_ANALYSIS* psa,   // SCRIPT_ANALYSIS* optional
    uint tagScript,   // DWORD
    uint tagLangSys,   // DWORD
    uint tagFeature,   // DWORD
    int lParameter,   // INT
    ushort wGlyphId,   // WORD
    ushort* pwOutGlyphId   // WORD* out
);
ccall((:ScriptSubstituteSingleGlyph, "USP10.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{Cvoid}, Ptr{SCRIPT_ANALYSIS}, UInt32, UInt32, UInt32, Int32, UInt16, Ptr{UInt16}),
      hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, pwOutGlyphId)
# hdc : HDC optional -> Ptr{Cvoid}
# psc : void** in/out -> Ptr{Cvoid}
# psa : SCRIPT_ANALYSIS* optional -> Ptr{SCRIPT_ANALYSIS}
# tagScript : DWORD -> UInt32
# tagLangSys : DWORD -> UInt32
# tagFeature : DWORD -> UInt32
# lParameter : INT -> Int32
# wGlyphId : WORD -> UInt16
# pwOutGlyphId : WORD* out -> Ptr{UInt16}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t ScriptSubstituteSingleGlyph(
    void* hdc,
    void** psc,
    void* psa,
    uint32_t tagScript,
    uint32_t tagLangSys,
    uint32_t tagFeature,
    int32_t lParameter,
    uint16_t wGlyphId,
    uint16_t* pwOutGlyphId);
]]
local usp10 = ffi.load("usp10")
-- usp10.ScriptSubstituteSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, pwOutGlyphId)
-- hdc : HDC optional
-- psc : void** in/out
-- psa : SCRIPT_ANALYSIS* optional
-- tagScript : DWORD
-- tagLangSys : DWORD
-- tagFeature : DWORD
-- lParameter : INT
-- wGlyphId : WORD
-- pwOutGlyphId : WORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('USP10.dll');
const ScriptSubstituteSingleGlyph = lib.func('__stdcall', 'ScriptSubstituteSingleGlyph', 'int32_t', ['void *', 'void *', 'void *', 'uint32_t', 'uint32_t', 'uint32_t', 'int32_t', 'uint16_t', 'uint16_t *']);
// ScriptSubstituteSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, pwOutGlyphId)
// hdc : HDC optional -> 'void *'
// psc : void** in/out -> 'void *'
// psa : SCRIPT_ANALYSIS* optional -> 'void *'
// tagScript : DWORD -> 'uint32_t'
// tagLangSys : DWORD -> 'uint32_t'
// tagFeature : DWORD -> 'uint32_t'
// lParameter : INT -> 'int32_t'
// wGlyphId : WORD -> 'uint16_t'
// pwOutGlyphId : WORD* out -> 'uint16_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("USP10.dll", {
  ScriptSubstituteSingleGlyph: { parameters: ["pointer", "pointer", "pointer", "u32", "u32", "u32", "i32", "u16", "pointer"], result: "i32" },
});
// lib.symbols.ScriptSubstituteSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, pwOutGlyphId)
// hdc : HDC optional -> "pointer"
// psc : void** in/out -> "pointer"
// psa : SCRIPT_ANALYSIS* optional -> "pointer"
// tagScript : DWORD -> "u32"
// tagLangSys : DWORD -> "u32"
// tagFeature : DWORD -> "u32"
// lParameter : INT -> "i32"
// wGlyphId : WORD -> "u16"
// pwOutGlyphId : WORD* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t ScriptSubstituteSingleGlyph(
    void* hdc,
    void** psc,
    void* psa,
    uint32_t tagScript,
    uint32_t tagLangSys,
    uint32_t tagFeature,
    int32_t lParameter,
    uint16_t wGlyphId,
    uint16_t* pwOutGlyphId);
C, "USP10.dll");
// $ffi->ScriptSubstituteSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, pwOutGlyphId);
// hdc : HDC optional
// psc : void** in/out
// psa : SCRIPT_ANALYSIS* optional
// tagScript : DWORD
// tagLangSys : DWORD
// tagFeature : DWORD
// lParameter : INT
// wGlyphId : WORD
// pwOutGlyphId : WORD* out
// 構造体/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 Usp10 extends StdCallLibrary {
    Usp10 INSTANCE = Native.load("usp10", Usp10.class);
    int ScriptSubstituteSingleGlyph(
        Pointer hdc,   // HDC optional
        Pointer psc,   // void** in/out
        Pointer psa,   // SCRIPT_ANALYSIS* optional
        int tagScript,   // DWORD
        int tagLangSys,   // DWORD
        int tagFeature,   // DWORD
        int lParameter,   // INT
        short wGlyphId,   // WORD
        ShortByReference pwOutGlyphId   // WORD* out
    );
}
@[Link("usp10")]
lib LibUSP10
  fun ScriptSubstituteSingleGlyph = ScriptSubstituteSingleGlyph(
    hdc : Void*,   # HDC optional
    psc : Void**,   # void** in/out
    psa : SCRIPT_ANALYSIS*,   # SCRIPT_ANALYSIS* optional
    tagScript : UInt32,   # DWORD
    tagLangSys : UInt32,   # DWORD
    tagFeature : UInt32,   # DWORD
    lParameter : Int32,   # INT
    wGlyphId : UInt16,   # WORD
    pwOutGlyphId : UInt16*   # WORD* out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef ScriptSubstituteSingleGlyphNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Uint32, Uint32, Uint32, Int32, Uint16, Pointer<Uint16>);
typedef ScriptSubstituteSingleGlyphDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, int, int, int, int, int, Pointer<Uint16>);
final ScriptSubstituteSingleGlyph = DynamicLibrary.open('USP10.dll')
    .lookupFunction<ScriptSubstituteSingleGlyphNative, ScriptSubstituteSingleGlyphDart>('ScriptSubstituteSingleGlyph');
// hdc : HDC optional -> Pointer<Void>
// psc : void** in/out -> Pointer<Void>
// psa : SCRIPT_ANALYSIS* optional -> Pointer<Void>
// tagScript : DWORD -> Uint32
// tagLangSys : DWORD -> Uint32
// tagFeature : DWORD -> Uint32
// lParameter : INT -> Int32
// wGlyphId : WORD -> Uint16
// pwOutGlyphId : WORD* out -> Pointer<Uint16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function ScriptSubstituteSingleGlyph(
  hdc: THandle;   // HDC optional
  psc: Pointer;   // void** in/out
  psa: Pointer;   // SCRIPT_ANALYSIS* optional
  tagScript: DWORD;   // DWORD
  tagLangSys: DWORD;   // DWORD
  tagFeature: DWORD;   // DWORD
  lParameter: Integer;   // INT
  wGlyphId: Word;   // WORD
  pwOutGlyphId: Pointer   // WORD* out
): Integer; stdcall;
  external 'USP10.dll' name 'ScriptSubstituteSingleGlyph';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "ScriptSubstituteSingleGlyph"
  c_ScriptSubstituteSingleGlyph :: Ptr () -> Ptr () -> Ptr () -> Word32 -> Word32 -> Word32 -> Int32 -> Word16 -> Ptr Word16 -> IO Int32
-- hdc : HDC optional -> Ptr ()
-- psc : void** in/out -> Ptr ()
-- psa : SCRIPT_ANALYSIS* optional -> Ptr ()
-- tagScript : DWORD -> Word32
-- tagLangSys : DWORD -> Word32
-- tagFeature : DWORD -> Word32
-- lParameter : INT -> Int32
-- wGlyphId : WORD -> Word16
-- pwOutGlyphId : WORD* out -> Ptr Word16
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let scriptsubstitutesingleglyph =
  foreign "ScriptSubstituteSingleGlyph"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> uint32_t @-> uint32_t @-> uint32_t @-> int32_t @-> uint16_t @-> (ptr uint16_t) @-> returning int32_t)
(* hdc : HDC optional -> (ptr void) *)
(* psc : void** in/out -> (ptr void) *)
(* psa : SCRIPT_ANALYSIS* optional -> (ptr void) *)
(* tagScript : DWORD -> uint32_t *)
(* tagLangSys : DWORD -> uint32_t *)
(* tagFeature : DWORD -> uint32_t *)
(* lParameter : INT -> int32_t *)
(* wGlyphId : WORD -> uint16_t *)
(* pwOutGlyphId : WORD* out -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library usp10 (t "USP10.dll"))
(cffi:use-foreign-library usp10)

(cffi:defcfun ("ScriptSubstituteSingleGlyph" script-substitute-single-glyph :convention :stdcall) :int32
  (hdc :pointer)   ; HDC optional
  (psc :pointer)   ; void** in/out
  (psa :pointer)   ; SCRIPT_ANALYSIS* optional
  (tag-script :uint32)   ; DWORD
  (tag-lang-sys :uint32)   ; DWORD
  (tag-feature :uint32)   ; DWORD
  (l-parameter :int32)   ; INT
  (w-glyph-id :uint16)   ; WORD
  (pw-out-glyph-id :pointer))   ; WORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $ScriptSubstituteSingleGlyph = Win32::API::More->new('USP10',
    'int ScriptSubstituteSingleGlyph(HANDLE hdc, LPVOID psc, LPVOID psa, DWORD tagScript, DWORD tagLangSys, DWORD tagFeature, int lParameter, WORD wGlyphId, LPVOID pwOutGlyphId)');
# my $ret = $ScriptSubstituteSingleGlyph->Call($hdc, $psc, $psa, $tagScript, $tagLangSys, $tagFeature, $lParameter, $wGlyphId, $pwOutGlyphId);
# hdc : HDC optional -> HANDLE
# psc : void** in/out -> LPVOID
# psa : SCRIPT_ANALYSIS* optional -> LPVOID
# tagScript : DWORD -> DWORD
# tagLangSys : DWORD -> DWORD
# tagFeature : DWORD -> DWORD
# lParameter : INT -> int
# wGlyphId : WORD -> WORD
# pwOutGlyphId : WORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型