ホーム › Globalization › ScriptShape
ScriptShape
関数文字列をグリフ列に整形(シェイピング)する。
シグネチャ
// USP10.dll
#include <windows.h>
HRESULT ScriptShape(
HDC hdc,
void** psc,
LPCWSTR pwcChars,
INT cChars,
INT cMaxGlyphs,
SCRIPT_ANALYSIS* psa,
WORD* pwOutGlyphs,
WORD* pwLogClust,
SCRIPT_VISATTR* psva,
INT* pcGlyphs
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hdc | HDC | in |
| psc | void** | inout |
| pwcChars | LPCWSTR | in |
| cChars | INT | in |
| cMaxGlyphs | INT | in |
| psa | SCRIPT_ANALYSIS* | inout |
| pwOutGlyphs | WORD* | out |
| pwLogClust | WORD* | out |
| psva | SCRIPT_VISATTR* | out |
| pcGlyphs | INT* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// USP10.dll
#include <windows.h>
HRESULT ScriptShape(
HDC hdc,
void** psc,
LPCWSTR pwcChars,
INT cChars,
INT cMaxGlyphs,
SCRIPT_ANALYSIS* psa,
WORD* pwOutGlyphs,
WORD* pwLogClust,
SCRIPT_VISATTR* psva,
INT* pcGlyphs
);[DllImport("USP10.dll", ExactSpelling = true)]
static extern int ScriptShape(
IntPtr hdc, // HDC
IntPtr psc, // void** in/out
[MarshalAs(UnmanagedType.LPWStr)] string pwcChars, // LPCWSTR
int cChars, // INT
int cMaxGlyphs, // INT
IntPtr psa, // SCRIPT_ANALYSIS* in/out
out ushort pwOutGlyphs, // WORD* out
out ushort pwLogClust, // WORD* out
IntPtr psva, // SCRIPT_VISATTR* out
out int pcGlyphs // INT* out
);<DllImport("USP10.dll", ExactSpelling:=True)>
Public Shared Function ScriptShape(
hdc As IntPtr, ' HDC
psc As IntPtr, ' void** in/out
<MarshalAs(UnmanagedType.LPWStr)> pwcChars As String, ' LPCWSTR
cChars As Integer, ' INT
cMaxGlyphs As Integer, ' INT
psa As IntPtr, ' SCRIPT_ANALYSIS* in/out
<Out> ByRef pwOutGlyphs As UShort, ' WORD* out
<Out> ByRef pwLogClust As UShort, ' WORD* out
psva As IntPtr, ' SCRIPT_VISATTR* out
<Out> ByRef pcGlyphs As Integer ' INT* out
) As Integer
End Function' hdc : HDC
' psc : void** in/out
' pwcChars : LPCWSTR
' cChars : INT
' cMaxGlyphs : INT
' psa : SCRIPT_ANALYSIS* in/out
' pwOutGlyphs : WORD* out
' pwLogClust : WORD* out
' psva : SCRIPT_VISATTR* out
' pcGlyphs : INT* out
Declare PtrSafe Function ScriptShape Lib "usp10" ( _
ByVal hdc As LongPtr, _
ByVal psc As LongPtr, _
ByVal pwcChars As LongPtr, _
ByVal cChars As Long, _
ByVal cMaxGlyphs As Long, _
ByVal psa As LongPtr, _
ByRef pwOutGlyphs As Integer, _
ByRef pwLogClust As Integer, _
ByVal psva 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
ScriptShape = ctypes.windll.usp10.ScriptShape
ScriptShape.restype = ctypes.c_int
ScriptShape.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.c_void_p, # psc : void** in/out
wintypes.LPCWSTR, # pwcChars : LPCWSTR
ctypes.c_int, # cChars : INT
ctypes.c_int, # cMaxGlyphs : INT
ctypes.c_void_p, # psa : SCRIPT_ANALYSIS* in/out
ctypes.POINTER(ctypes.c_ushort), # pwOutGlyphs : WORD* out
ctypes.POINTER(ctypes.c_ushort), # pwLogClust : WORD* out
ctypes.c_void_p, # psva : SCRIPT_VISATTR* out
ctypes.POINTER(ctypes.c_int), # pcGlyphs : INT* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USP10.dll')
ScriptShape = Fiddle::Function.new(
lib['ScriptShape'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_VOIDP, # psc : void** in/out
Fiddle::TYPE_VOIDP, # pwcChars : LPCWSTR
Fiddle::TYPE_INT, # cChars : INT
Fiddle::TYPE_INT, # cMaxGlyphs : INT
Fiddle::TYPE_VOIDP, # psa : SCRIPT_ANALYSIS* in/out
Fiddle::TYPE_VOIDP, # pwOutGlyphs : WORD* out
Fiddle::TYPE_VOIDP, # pwLogClust : WORD* out
Fiddle::TYPE_VOIDP, # psva : SCRIPT_VISATTR* out
Fiddle::TYPE_VOIDP, # pcGlyphs : INT* out
],
Fiddle::TYPE_INT)#[link(name = "usp10")]
extern "system" {
fn ScriptShape(
hdc: *mut core::ffi::c_void, // HDC
psc: *mut *mut (), // void** in/out
pwcChars: *const u16, // LPCWSTR
cChars: i32, // INT
cMaxGlyphs: i32, // INT
psa: *mut SCRIPT_ANALYSIS, // SCRIPT_ANALYSIS* in/out
pwOutGlyphs: *mut u16, // WORD* out
pwLogClust: *mut u16, // WORD* out
psva: *mut SCRIPT_VISATTR, // SCRIPT_VISATTR* 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 ScriptShape(IntPtr hdc, IntPtr psc, [MarshalAs(UnmanagedType.LPWStr)] string pwcChars, int cChars, int cMaxGlyphs, IntPtr psa, out ushort pwOutGlyphs, out ushort pwLogClust, IntPtr psva, out int pcGlyphs);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USP10_ScriptShape' -Namespace Win32 -PassThru
# $api::ScriptShape(hdc, psc, pwcChars, cChars, cMaxGlyphs, psa, pwOutGlyphs, pwLogClust, psva, pcGlyphs)#uselib "USP10.dll"
#func global ScriptShape "ScriptShape" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; ScriptShape hdc, psc, pwcChars, cChars, cMaxGlyphs, varptr(psa), varptr(pwOutGlyphs), varptr(pwLogClust), varptr(psva), varptr(pcGlyphs) ; 戻り値は stat
; hdc : HDC -> "sptr"
; psc : void** in/out -> "sptr"
; pwcChars : LPCWSTR -> "sptr"
; cChars : INT -> "sptr"
; cMaxGlyphs : INT -> "sptr"
; psa : SCRIPT_ANALYSIS* in/out -> "sptr"
; pwOutGlyphs : WORD* out -> "sptr"
; pwLogClust : WORD* out -> "sptr"
; psva : SCRIPT_VISATTR* out -> "sptr"
; pcGlyphs : INT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USP10.dll" #cfunc global ScriptShape "ScriptShape" sptr, sptr, wstr, int, int, var, var, var, var, var ; res = ScriptShape(hdc, psc, pwcChars, cChars, cMaxGlyphs, psa, pwOutGlyphs, pwLogClust, psva, pcGlyphs) ; hdc : HDC -> "sptr" ; psc : void** in/out -> "sptr" ; pwcChars : LPCWSTR -> "wstr" ; cChars : INT -> "int" ; cMaxGlyphs : INT -> "int" ; psa : SCRIPT_ANALYSIS* in/out -> "var" ; pwOutGlyphs : WORD* out -> "var" ; pwLogClust : WORD* out -> "var" ; psva : SCRIPT_VISATTR* out -> "var" ; pcGlyphs : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USP10.dll" #cfunc global ScriptShape "ScriptShape" sptr, sptr, wstr, int, int, sptr, sptr, sptr, sptr, sptr ; res = ScriptShape(hdc, psc, pwcChars, cChars, cMaxGlyphs, varptr(psa), varptr(pwOutGlyphs), varptr(pwLogClust), varptr(psva), varptr(pcGlyphs)) ; hdc : HDC -> "sptr" ; psc : void** in/out -> "sptr" ; pwcChars : LPCWSTR -> "wstr" ; cChars : INT -> "int" ; cMaxGlyphs : INT -> "int" ; psa : SCRIPT_ANALYSIS* in/out -> "sptr" ; pwOutGlyphs : WORD* out -> "sptr" ; pwLogClust : WORD* out -> "sptr" ; psva : SCRIPT_VISATTR* out -> "sptr" ; pcGlyphs : INT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT ScriptShape(HDC hdc, void** psc, LPCWSTR pwcChars, INT cChars, INT cMaxGlyphs, SCRIPT_ANALYSIS* psa, WORD* pwOutGlyphs, WORD* pwLogClust, SCRIPT_VISATTR* psva, INT* pcGlyphs) #uselib "USP10.dll" #cfunc global ScriptShape "ScriptShape" intptr, intptr, wstr, int, int, var, var, var, var, var ; res = ScriptShape(hdc, psc, pwcChars, cChars, cMaxGlyphs, psa, pwOutGlyphs, pwLogClust, psva, pcGlyphs) ; hdc : HDC -> "intptr" ; psc : void** in/out -> "intptr" ; pwcChars : LPCWSTR -> "wstr" ; cChars : INT -> "int" ; cMaxGlyphs : INT -> "int" ; psa : SCRIPT_ANALYSIS* in/out -> "var" ; pwOutGlyphs : WORD* out -> "var" ; pwLogClust : WORD* out -> "var" ; psva : SCRIPT_VISATTR* out -> "var" ; pcGlyphs : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT ScriptShape(HDC hdc, void** psc, LPCWSTR pwcChars, INT cChars, INT cMaxGlyphs, SCRIPT_ANALYSIS* psa, WORD* pwOutGlyphs, WORD* pwLogClust, SCRIPT_VISATTR* psva, INT* pcGlyphs) #uselib "USP10.dll" #cfunc global ScriptShape "ScriptShape" intptr, intptr, wstr, int, int, intptr, intptr, intptr, intptr, intptr ; res = ScriptShape(hdc, psc, pwcChars, cChars, cMaxGlyphs, varptr(psa), varptr(pwOutGlyphs), varptr(pwLogClust), varptr(psva), varptr(pcGlyphs)) ; hdc : HDC -> "intptr" ; psc : void** in/out -> "intptr" ; pwcChars : LPCWSTR -> "wstr" ; cChars : INT -> "int" ; cMaxGlyphs : INT -> "int" ; psa : SCRIPT_ANALYSIS* in/out -> "intptr" ; pwOutGlyphs : WORD* out -> "intptr" ; pwLogClust : WORD* out -> "intptr" ; psva : SCRIPT_VISATTR* out -> "intptr" ; pcGlyphs : INT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
usp10 = windows.NewLazySystemDLL("USP10.dll")
procScriptShape = usp10.NewProc("ScriptShape")
)
// hdc (HDC), psc (void** in/out), pwcChars (LPCWSTR), cChars (INT), cMaxGlyphs (INT), psa (SCRIPT_ANALYSIS* in/out), pwOutGlyphs (WORD* out), pwLogClust (WORD* out), psva (SCRIPT_VISATTR* out), pcGlyphs (INT* out)
r1, _, err := procScriptShape.Call(
uintptr(hdc),
uintptr(psc),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwcChars))),
uintptr(cChars),
uintptr(cMaxGlyphs),
uintptr(psa),
uintptr(pwOutGlyphs),
uintptr(pwLogClust),
uintptr(psva),
uintptr(pcGlyphs),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction ScriptShape(
hdc: THandle; // HDC
psc: Pointer; // void** in/out
pwcChars: PWideChar; // LPCWSTR
cChars: Integer; // INT
cMaxGlyphs: Integer; // INT
psa: Pointer; // SCRIPT_ANALYSIS* in/out
pwOutGlyphs: Pointer; // WORD* out
pwLogClust: Pointer; // WORD* out
psva: Pointer; // SCRIPT_VISATTR* out
pcGlyphs: Pointer // INT* out
): Integer; stdcall;
external 'USP10.dll' name 'ScriptShape';result := DllCall("USP10\ScriptShape"
, "Ptr", hdc ; HDC
, "Ptr", psc ; void** in/out
, "WStr", pwcChars ; LPCWSTR
, "Int", cChars ; INT
, "Int", cMaxGlyphs ; INT
, "Ptr", psa ; SCRIPT_ANALYSIS* in/out
, "Ptr", pwOutGlyphs ; WORD* out
, "Ptr", pwLogClust ; WORD* out
, "Ptr", psva ; SCRIPT_VISATTR* out
, "Ptr", pcGlyphs ; INT* out
, "Int") ; return: HRESULT●ScriptShape(hdc, psc, pwcChars, cChars, cMaxGlyphs, psa, pwOutGlyphs, pwLogClust, psva, pcGlyphs) = DLL("USP10.dll", "int ScriptShape(void*, void*, char*, int, int, void*, void*, void*, void*, void*)")
# 呼び出し: ScriptShape(hdc, psc, pwcChars, cChars, cMaxGlyphs, psa, pwOutGlyphs, pwLogClust, psva, pcGlyphs)
# hdc : HDC -> "void*"
# psc : void** in/out -> "void*"
# pwcChars : LPCWSTR -> "char*"
# cChars : INT -> "int"
# cMaxGlyphs : INT -> "int"
# psa : SCRIPT_ANALYSIS* in/out -> "void*"
# pwOutGlyphs : WORD* out -> "void*"
# pwLogClust : WORD* out -> "void*"
# psva : SCRIPT_VISATTR* out -> "void*"
# pcGlyphs : INT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。