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

ScriptShapeOpenType

関数
OpenType機能を用いて文字列をグリフ列に整形する。
DLLUSP10.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT ScriptShapeOpenType(
    HDC hdc,   // optional
    void** psc,
    SCRIPT_ANALYSIS* psa,
    DWORD tagScript,
    DWORD tagLangSys,
    INT* rcRangeChars,   // optional
    TEXTRANGE_PROPERTIES** rpRangeProperties,   // optional
    INT cRanges,
    LPCWSTR pwcChars,
    INT cChars,
    INT cMaxGlyphs,
    WORD* pwLogClust,
    SCRIPT_CHARPROP* pCharProps,
    WORD* pwOutGlyphs,
    SCRIPT_GLYPHPROP* pOutGlyphProps,
    INT* pcGlyphs
);

パラメーター

名前方向
hdcHDCinoptional
pscvoid**inout
psaSCRIPT_ANALYSIS*inout
tagScriptDWORDin
tagLangSysDWORDin
rcRangeCharsINT*inoptional
rpRangePropertiesTEXTRANGE_PROPERTIES**inoptional
cRangesINTin
pwcCharsLPCWSTRin
cCharsINTin
cMaxGlyphsINTin
pwLogClustWORD*out
pCharPropsSCRIPT_CHARPROP*out
pwOutGlyphsWORD*out
pOutGlyphPropsSCRIPT_GLYPHPROP*out
pcGlyphsINT*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT ScriptShapeOpenType(
    HDC hdc,   // optional
    void** psc,
    SCRIPT_ANALYSIS* psa,
    DWORD tagScript,
    DWORD tagLangSys,
    INT* rcRangeChars,   // optional
    TEXTRANGE_PROPERTIES** rpRangeProperties,   // optional
    INT cRanges,
    LPCWSTR pwcChars,
    INT cChars,
    INT cMaxGlyphs,
    WORD* pwLogClust,
    SCRIPT_CHARPROP* pCharProps,
    WORD* pwOutGlyphs,
    SCRIPT_GLYPHPROP* pOutGlyphProps,
    INT* pcGlyphs
);
[DllImport("USP10.dll", ExactSpelling = true)]
static extern int ScriptShapeOpenType(
    IntPtr hdc,   // HDC optional
    IntPtr psc,   // void** in/out
    IntPtr psa,   // SCRIPT_ANALYSIS* in/out
    uint tagScript,   // DWORD
    uint tagLangSys,   // DWORD
    IntPtr rcRangeChars,   // INT* optional
    IntPtr rpRangeProperties,   // TEXTRANGE_PROPERTIES** optional
    int cRanges,   // INT
    [MarshalAs(UnmanagedType.LPWStr)] string pwcChars,   // LPCWSTR
    int cChars,   // INT
    int cMaxGlyphs,   // INT
    out ushort pwLogClust,   // WORD* out
    IntPtr pCharProps,   // SCRIPT_CHARPROP* out
    out ushort pwOutGlyphs,   // WORD* out
    IntPtr pOutGlyphProps,   // SCRIPT_GLYPHPROP* out
    out int pcGlyphs   // INT* out
);
<DllImport("USP10.dll", ExactSpelling:=True)>
Public Shared Function ScriptShapeOpenType(
    hdc As IntPtr,   ' HDC optional
    psc As IntPtr,   ' void** in/out
    psa As IntPtr,   ' SCRIPT_ANALYSIS* in/out
    tagScript As UInteger,   ' DWORD
    tagLangSys As UInteger,   ' DWORD
    rcRangeChars As IntPtr,   ' INT* optional
    rpRangeProperties As IntPtr,   ' TEXTRANGE_PROPERTIES** optional
    cRanges As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPWStr)> pwcChars As String,   ' LPCWSTR
    cChars As Integer,   ' INT
    cMaxGlyphs As Integer,   ' INT
    <Out> ByRef pwLogClust As UShort,   ' WORD* out
    pCharProps As IntPtr,   ' SCRIPT_CHARPROP* out
    <Out> ByRef pwOutGlyphs As UShort,   ' WORD* out
    pOutGlyphProps As IntPtr,   ' SCRIPT_GLYPHPROP* out
    <Out> ByRef pcGlyphs As Integer   ' INT* out
) As Integer
End Function
' hdc : HDC optional
' psc : void** in/out
' psa : SCRIPT_ANALYSIS* in/out
' tagScript : DWORD
' tagLangSys : DWORD
' rcRangeChars : INT* optional
' rpRangeProperties : TEXTRANGE_PROPERTIES** optional
' cRanges : INT
' pwcChars : LPCWSTR
' cChars : INT
' cMaxGlyphs : INT
' pwLogClust : WORD* out
' pCharProps : SCRIPT_CHARPROP* out
' pwOutGlyphs : WORD* out
' pOutGlyphProps : SCRIPT_GLYPHPROP* out
' pcGlyphs : INT* out
Declare PtrSafe Function ScriptShapeOpenType Lib "usp10" ( _
    ByVal hdc As LongPtr, _
    ByVal psc As LongPtr, _
    ByVal psa As LongPtr, _
    ByVal tagScript As Long, _
    ByVal tagLangSys As Long, _
    ByVal rcRangeChars As LongPtr, _
    ByVal rpRangeProperties As LongPtr, _
    ByVal cRanges As Long, _
    ByVal pwcChars As LongPtr, _
    ByVal cChars As Long, _
    ByVal cMaxGlyphs As Long, _
    ByRef pwLogClust As Integer, _
    ByVal pCharProps As LongPtr, _
    ByRef pwOutGlyphs As Integer, _
    ByVal pOutGlyphProps As LongPtr, _
    ByRef pcGlyphs As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

ScriptShapeOpenType = ctypes.windll.usp10.ScriptShapeOpenType
ScriptShapeOpenType.restype = ctypes.c_int
ScriptShapeOpenType.argtypes = [
    wintypes.HANDLE,  # hdc : HDC optional
    ctypes.c_void_p,  # psc : void** in/out
    ctypes.c_void_p,  # psa : SCRIPT_ANALYSIS* in/out
    wintypes.DWORD,  # tagScript : DWORD
    wintypes.DWORD,  # tagLangSys : DWORD
    ctypes.POINTER(ctypes.c_int),  # rcRangeChars : INT* optional
    ctypes.c_void_p,  # rpRangeProperties : TEXTRANGE_PROPERTIES** optional
    ctypes.c_int,  # cRanges : INT
    wintypes.LPCWSTR,  # pwcChars : LPCWSTR
    ctypes.c_int,  # cChars : INT
    ctypes.c_int,  # cMaxGlyphs : INT
    ctypes.POINTER(ctypes.c_ushort),  # pwLogClust : WORD* out
    ctypes.c_void_p,  # pCharProps : SCRIPT_CHARPROP* out
    ctypes.POINTER(ctypes.c_ushort),  # pwOutGlyphs : WORD* out
    ctypes.c_void_p,  # pOutGlyphProps : SCRIPT_GLYPHPROP* out
    ctypes.POINTER(ctypes.c_int),  # pcGlyphs : INT* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	usp10 = windows.NewLazySystemDLL("USP10.dll")
	procScriptShapeOpenType = usp10.NewProc("ScriptShapeOpenType")
)

// hdc (HDC optional), psc (void** in/out), psa (SCRIPT_ANALYSIS* in/out), tagScript (DWORD), tagLangSys (DWORD), rcRangeChars (INT* optional), rpRangeProperties (TEXTRANGE_PROPERTIES** optional), cRanges (INT), pwcChars (LPCWSTR), cChars (INT), cMaxGlyphs (INT), pwLogClust (WORD* out), pCharProps (SCRIPT_CHARPROP* out), pwOutGlyphs (WORD* out), pOutGlyphProps (SCRIPT_GLYPHPROP* out), pcGlyphs (INT* out)
r1, _, err := procScriptShapeOpenType.Call(
	uintptr(hdc),
	uintptr(psc),
	uintptr(psa),
	uintptr(tagScript),
	uintptr(tagLangSys),
	uintptr(rcRangeChars),
	uintptr(rpRangeProperties),
	uintptr(cRanges),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwcChars))),
	uintptr(cChars),
	uintptr(cMaxGlyphs),
	uintptr(pwLogClust),
	uintptr(pCharProps),
	uintptr(pwOutGlyphs),
	uintptr(pOutGlyphProps),
	uintptr(pcGlyphs),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function ScriptShapeOpenType(
  hdc: THandle;   // HDC optional
  psc: Pointer;   // void** in/out
  psa: Pointer;   // SCRIPT_ANALYSIS* in/out
  tagScript: DWORD;   // DWORD
  tagLangSys: DWORD;   // DWORD
  rcRangeChars: Pointer;   // INT* optional
  rpRangeProperties: Pointer;   // TEXTRANGE_PROPERTIES** optional
  cRanges: Integer;   // INT
  pwcChars: PWideChar;   // LPCWSTR
  cChars: Integer;   // INT
  cMaxGlyphs: Integer;   // INT
  pwLogClust: Pointer;   // WORD* out
  pCharProps: Pointer;   // SCRIPT_CHARPROP* out
  pwOutGlyphs: Pointer;   // WORD* out
  pOutGlyphProps: Pointer;   // SCRIPT_GLYPHPROP* out
  pcGlyphs: Pointer   // INT* out
): Integer; stdcall;
  external 'USP10.dll' name 'ScriptShapeOpenType';
result := DllCall("USP10\ScriptShapeOpenType"
    , "Ptr", hdc   ; HDC optional
    , "Ptr", psc   ; void** in/out
    , "Ptr", psa   ; SCRIPT_ANALYSIS* in/out
    , "UInt", tagScript   ; DWORD
    , "UInt", tagLangSys   ; DWORD
    , "Ptr", rcRangeChars   ; INT* optional
    , "Ptr", rpRangeProperties   ; TEXTRANGE_PROPERTIES** optional
    , "Int", cRanges   ; INT
    , "WStr", pwcChars   ; LPCWSTR
    , "Int", cChars   ; INT
    , "Int", cMaxGlyphs   ; INT
    , "Ptr", pwLogClust   ; WORD* out
    , "Ptr", pCharProps   ; SCRIPT_CHARPROP* out
    , "Ptr", pwOutGlyphs   ; WORD* out
    , "Ptr", pOutGlyphProps   ; SCRIPT_GLYPHPROP* out
    , "Ptr", pcGlyphs   ; INT* out
    , "Int")   ; return: HRESULT
●ScriptShapeOpenType(hdc, psc, psa, tagScript, tagLangSys, rcRangeChars, rpRangeProperties, cRanges, pwcChars, cChars, cMaxGlyphs, pwLogClust, pCharProps, pwOutGlyphs, pOutGlyphProps, pcGlyphs) = DLL("USP10.dll", "int ScriptShapeOpenType(void*, void*, void*, dword, dword, void*, void*, int, char*, int, int, void*, void*, void*, void*, void*)")
# 呼び出し: ScriptShapeOpenType(hdc, psc, psa, tagScript, tagLangSys, rcRangeChars, rpRangeProperties, cRanges, pwcChars, cChars, cMaxGlyphs, pwLogClust, pCharProps, pwOutGlyphs, pOutGlyphProps, pcGlyphs)
# hdc : HDC optional -> "void*"
# psc : void** in/out -> "void*"
# psa : SCRIPT_ANALYSIS* in/out -> "void*"
# tagScript : DWORD -> "dword"
# tagLangSys : DWORD -> "dword"
# rcRangeChars : INT* optional -> "void*"
# rpRangeProperties : TEXTRANGE_PROPERTIES** optional -> "void*"
# cRanges : INT -> "int"
# pwcChars : LPCWSTR -> "char*"
# cChars : INT -> "int"
# cMaxGlyphs : INT -> "int"
# pwLogClust : WORD* out -> "void*"
# pCharProps : SCRIPT_CHARPROP* out -> "void*"
# pwOutGlyphs : WORD* out -> "void*"
# pOutGlyphProps : SCRIPT_GLYPHPROP* out -> "void*"
# pcGlyphs : INT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。