ScriptPositionSingleGlyph
関数シグネチャ
// USP10.dll
#include <windows.h>
HRESULT ScriptPositionSingleGlyph(
HDC hdc, // optional
void** psc,
SCRIPT_ANALYSIS* psa, // optional
DWORD tagScript,
DWORD tagLangSys,
DWORD tagFeature,
INT lParameter,
WORD wGlyphId,
INT iAdvance,
GOFFSET GOffset,
INT* piOutAdvance,
GOFFSET* pOutGoffset
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdc | HDC | inoptional | デバイスコンテキストへのハンドル。詳細については、キャッシュを参照してください。 |
| psc | void** | inout | スクリプトキャッシュを識別する SCRIPT_CACHE 構造体へのポインター。 |
| psa | SCRIPT_ANALYSIS* | inoptional | 以前の ScriptItemizeOpenType の呼び出しで取得した SCRIPT_ANALYSIS 構造体へのポインター。この構造体はシェーピングエンジンを識別するため、送り幅を取得できます。 あるいは、フィルター処理されていない結果を取得するために、このパラメーターを NULL に設定することもできます。 |
| tagScript | DWORD | in | シェーピング用のスクリプトタグを定義する OPENTYPE_TAG 構造体。 |
| tagLangSys | DWORD | in | シェーピング用の言語タグを定義する OPENTYPE_TAG 構造体。 |
| tagFeature | DWORD | in | 代替グリフのシェーピングに使用する機能タグを定義する OPENTYPE_TAG 構造体。 |
| lParameter | INT | in | wGlyphId で指定された識別子に単一置換を適用するかどうかを指定するフラグ。識別子に単一置換機能を適用するには、アプリケーションはこのパラメーターを 1 に設定します。関数がこの機能を適用しないようにするには、パラメーターを 0 に設定します。 |
| wGlyphId | WORD | in | シェーピングされる元のグリフの識別子。 |
| iAdvance | INT | in | 元のグリフの送り幅。 |
| GOffset | GOFFSET | in | 元のグリフのオフセット。通常、この値は ScriptPlaceOpenType または ScriptPlace の出力です。 |
| piOutAdvance | INT* | out | 代替グリフ用に調整された新しい送り幅を、この関数が取得する場所へのポインター。 |
| pOutGoffset | GOFFSET* | out | 代替グリフ用に調整された新しいグリフオフセットを、この関数が取得する場所へのポインター。 |
戻り値の型: HRESULT
公式ドキュメント
OpenType 処理用にフォントが提供する指定された機能を使用して、単一のグリフを単一の調整で配置します。アプリケーションがこの関数を使用するのは、行頭または行末でグリフを視覚的に揃える場合がほとんどです。
戻り値
成功した場合は 0 を返します。成功しなかった場合、この関数は 0 以外の HRESULT 値を返します。アプリケーションは SUCCEEDED および FAILED マクロで戻り値をテストできます。
解説(Remarks)
この関数は、指定されたグリフの送り幅やオフセットを調整することで、個々のグリフを配置します。この関数は、フォントが調整を 1 回だけ必要とすることを前提としています。
この関数の典型的な用途は、特定の文字が与える視覚的な印象を考慮してマージンをわずかに調整することです。たとえばラテン文字では、行頭において、グリフの左側に垂直線を持たない先頭の大文字("T" や "O" など)を左へわずかに調整するのが一般的です。これを行うと厳密な直線的マージンは崩れますが、目にはマージンがより均等であるように見えます。
次の例はこの効果を示しています。最初の例は厳密な配置を示し、続く 2 つの例は先頭の "T" を左へ調整した様子を示しています。調整はそれぞれ 1 ピクセルと 2 ピクセルです。右側の拡大画像は、それぞれの場合で "T" が左マージンへわずかに深く押し込まれていく様子を示しています。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// USP10.dll
#include <windows.h>
HRESULT ScriptPositionSingleGlyph(
HDC hdc, // optional
void** psc,
SCRIPT_ANALYSIS* psa, // optional
DWORD tagScript,
DWORD tagLangSys,
DWORD tagFeature,
INT lParameter,
WORD wGlyphId,
INT iAdvance,
GOFFSET GOffset,
INT* piOutAdvance,
GOFFSET* pOutGoffset
);[DllImport("USP10.dll", ExactSpelling = true)]
static extern int ScriptPositionSingleGlyph(
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
int iAdvance, // INT
GOFFSET GOffset, // GOFFSET
out int piOutAdvance, // INT* out
IntPtr pOutGoffset // GOFFSET* out
);<DllImport("USP10.dll", ExactSpelling:=True)>
Public Shared Function ScriptPositionSingleGlyph(
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
iAdvance As Integer, ' INT
GOffset As GOFFSET, ' GOFFSET
<Out> ByRef piOutAdvance As Integer, ' INT* out
pOutGoffset As IntPtr ' GOFFSET* 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
' iAdvance : INT
' GOffset : GOFFSET
' piOutAdvance : INT* out
' pOutGoffset : GOFFSET* out
Declare PtrSafe Function ScriptPositionSingleGlyph 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, _
ByVal iAdvance As Long, _
ByVal GOffset As LongPtr, _
ByRef piOutAdvance As Long, _
ByVal pOutGoffset As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ScriptPositionSingleGlyph = ctypes.windll.usp10.ScriptPositionSingleGlyph
ScriptPositionSingleGlyph.restype = ctypes.c_int
ScriptPositionSingleGlyph.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.c_int, # iAdvance : INT
GOFFSET, # GOffset : GOFFSET
ctypes.POINTER(ctypes.c_int), # piOutAdvance : INT* out
ctypes.c_void_p, # pOutGoffset : GOFFSET* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USP10.dll')
ScriptPositionSingleGlyph = Fiddle::Function.new(
lib['ScriptPositionSingleGlyph'],
[
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_INT, # iAdvance : INT
Fiddle::TYPE_VOIDP, # GOffset : GOFFSET
Fiddle::TYPE_VOIDP, # piOutAdvance : INT* out
Fiddle::TYPE_VOIDP, # pOutGoffset : GOFFSET* out
],
Fiddle::TYPE_INT)#[link(name = "usp10")]
extern "system" {
fn ScriptPositionSingleGlyph(
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
iAdvance: i32, // INT
GOffset: GOFFSET, // GOFFSET
piOutAdvance: *mut i32, // INT* out
pOutGoffset: *mut GOFFSET // GOFFSET* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USP10.dll")]
public static extern int ScriptPositionSingleGlyph(IntPtr hdc, IntPtr psc, IntPtr psa, uint tagScript, uint tagLangSys, uint tagFeature, int lParameter, ushort wGlyphId, int iAdvance, GOFFSET GOffset, out int piOutAdvance, IntPtr pOutGoffset);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USP10_ScriptPositionSingleGlyph' -Namespace Win32 -PassThru
# $api::ScriptPositionSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, iAdvance, GOffset, piOutAdvance, pOutGoffset)#uselib "USP10.dll"
#func global ScriptPositionSingleGlyph "ScriptPositionSingleGlyph" sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr, sptr
; ScriptPositionSingleGlyph hdc, psc, varptr(psa), tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, iAdvance, GOffset, varptr(piOutAdvance), varptr(pOutGoffset) ; 戻り値は 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"
; iAdvance : INT -> "sptr"
; GOffset : GOFFSET -> "sptr"
; piOutAdvance : INT* out -> "sptr"
; pOutGoffset : GOFFSET* out -> "sptr"
; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USP10.dll" #cfunc global ScriptPositionSingleGlyph "ScriptPositionSingleGlyph" sptr, sptr, var, int, int, int, int, int, int, int, var, var ; res = ScriptPositionSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, iAdvance, GOffset, piOutAdvance, pOutGoffset) ; 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" ; iAdvance : INT -> "int" ; GOffset : GOFFSET -> "int" ; piOutAdvance : INT* out -> "var" ; pOutGoffset : GOFFSET* out -> "var" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USP10.dll" #cfunc global ScriptPositionSingleGlyph "ScriptPositionSingleGlyph" sptr, sptr, sptr, int, int, int, int, int, int, int, sptr, sptr ; res = ScriptPositionSingleGlyph(hdc, psc, varptr(psa), tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, iAdvance, GOffset, varptr(piOutAdvance), varptr(pOutGoffset)) ; hdc : HDC optional -> "sptr" ; psc : void** in/out -> "sptr" ; psa : SCRIPT_ANALYSIS* optional -> "sptr" ; tagScript : DWORD -> "int" ; tagLangSys : DWORD -> "int" ; tagFeature : DWORD -> "int" ; lParameter : INT -> "int" ; wGlyphId : WORD -> "int" ; iAdvance : INT -> "int" ; GOffset : GOFFSET -> "int" ; piOutAdvance : INT* out -> "sptr" ; pOutGoffset : GOFFSET* out -> "sptr" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; HRESULT ScriptPositionSingleGlyph(HDC hdc, void** psc, SCRIPT_ANALYSIS* psa, DWORD tagScript, DWORD tagLangSys, DWORD tagFeature, INT lParameter, WORD wGlyphId, INT iAdvance, GOFFSET GOffset, INT* piOutAdvance, GOFFSET* pOutGoffset) #uselib "USP10.dll" #cfunc global ScriptPositionSingleGlyph "ScriptPositionSingleGlyph" intptr, intptr, var, int, int, int, int, int, int, int, var, var ; res = ScriptPositionSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, iAdvance, GOffset, piOutAdvance, pOutGoffset) ; 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" ; iAdvance : INT -> "int" ; GOffset : GOFFSET -> "int" ; piOutAdvance : INT* out -> "var" ; pOutGoffset : GOFFSET* out -> "var" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT ScriptPositionSingleGlyph(HDC hdc, void** psc, SCRIPT_ANALYSIS* psa, DWORD tagScript, DWORD tagLangSys, DWORD tagFeature, INT lParameter, WORD wGlyphId, INT iAdvance, GOFFSET GOffset, INT* piOutAdvance, GOFFSET* pOutGoffset) #uselib "USP10.dll" #cfunc global ScriptPositionSingleGlyph "ScriptPositionSingleGlyph" intptr, intptr, intptr, int, int, int, int, int, int, int, intptr, intptr ; res = ScriptPositionSingleGlyph(hdc, psc, varptr(psa), tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, iAdvance, GOffset, varptr(piOutAdvance), varptr(pOutGoffset)) ; hdc : HDC optional -> "intptr" ; psc : void** in/out -> "intptr" ; psa : SCRIPT_ANALYSIS* optional -> "intptr" ; tagScript : DWORD -> "int" ; tagLangSys : DWORD -> "int" ; tagFeature : DWORD -> "int" ; lParameter : INT -> "int" ; wGlyphId : WORD -> "int" ; iAdvance : INT -> "int" ; GOffset : GOFFSET -> "int" ; piOutAdvance : INT* out -> "intptr" ; pOutGoffset : GOFFSET* out -> "intptr" ; ※値渡し構造体は直接渡せません。intにパック、または var で構造体変数を渡してください。 ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
usp10 = windows.NewLazySystemDLL("USP10.dll")
procScriptPositionSingleGlyph = usp10.NewProc("ScriptPositionSingleGlyph")
)
// hdc (HDC optional), psc (void** in/out), psa (SCRIPT_ANALYSIS* optional), tagScript (DWORD), tagLangSys (DWORD), tagFeature (DWORD), lParameter (INT), wGlyphId (WORD), iAdvance (INT), GOffset (GOFFSET), piOutAdvance (INT* out), pOutGoffset (GOFFSET* out)
r1, _, err := procScriptPositionSingleGlyph.Call(
uintptr(hdc),
uintptr(psc),
uintptr(psa),
uintptr(tagScript),
uintptr(tagLangSys),
uintptr(tagFeature),
uintptr(lParameter),
uintptr(wGlyphId),
uintptr(iAdvance),
uintptr(GOffset),
uintptr(piOutAdvance),
uintptr(pOutGoffset),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction ScriptPositionSingleGlyph(
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
iAdvance: Integer; // INT
GOffset: GOFFSET; // GOFFSET
piOutAdvance: Pointer; // INT* out
pOutGoffset: Pointer // GOFFSET* out
): Integer; stdcall;
external 'USP10.dll' name 'ScriptPositionSingleGlyph';result := DllCall("USP10\ScriptPositionSingleGlyph"
, "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
, "Int", iAdvance ; INT
, "Ptr", GOffset ; GOFFSET
, "Ptr", piOutAdvance ; INT* out
, "Ptr", pOutGoffset ; GOFFSET* out
, "Int") ; return: HRESULT●ScriptPositionSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, iAdvance, GOffset, piOutAdvance, pOutGoffset) = DLL("USP10.dll", "int ScriptPositionSingleGlyph(void*, void*, void*, dword, dword, dword, int, int, int, void*, void*, void*)")
# 呼び出し: ScriptPositionSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, iAdvance, GOffset, piOutAdvance, pOutGoffset)
# 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"
# iAdvance : INT -> "int"
# GOffset : GOFFSET -> "void*"
# piOutAdvance : INT* out -> "void*"
# pOutGoffset : GOFFSET* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "usp10" fn ScriptPositionSingleGlyph(
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
iAdvance: i32, // INT
GOffset: GOFFSET, // GOFFSET
piOutAdvance: [*c]i32, // INT* out
pOutGoffset: [*c]GOFFSET // GOFFSET* out
) callconv(std.os.windows.WINAPI) i32;proc ScriptPositionSingleGlyph(
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
iAdvance: int32, # INT
GOffset: GOFFSET, # GOFFSET
piOutAdvance: ptr int32, # INT* out
pOutGoffset: ptr GOFFSET # GOFFSET* out
): int32 {.importc: "ScriptPositionSingleGlyph", stdcall, dynlib: "USP10.dll".}pragma(lib, "usp10");
extern(Windows)
int ScriptPositionSingleGlyph(
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
int iAdvance, // INT
GOFFSET GOffset, // GOFFSET
int* piOutAdvance, // INT* out
GOFFSET* pOutGoffset // GOFFSET* out
);ccall((:ScriptPositionSingleGlyph, "USP10.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, Ptr{SCRIPT_ANALYSIS}, UInt32, UInt32, UInt32, Int32, UInt16, Int32, GOFFSET, Ptr{Int32}, Ptr{GOFFSET}),
hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, iAdvance, GOffset, piOutAdvance, pOutGoffset)
# 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
# iAdvance : INT -> Int32
# GOffset : GOFFSET -> GOFFSET
# piOutAdvance : INT* out -> Ptr{Int32}
# pOutGoffset : GOFFSET* out -> Ptr{GOFFSET}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ScriptPositionSingleGlyph(
void* hdc,
void** psc,
void* psa,
uint32_t tagScript,
uint32_t tagLangSys,
uint32_t tagFeature,
int32_t lParameter,
uint16_t wGlyphId,
int32_t iAdvance,
GOFFSET GOffset,
int32_t* piOutAdvance,
void* pOutGoffset);
]]
local usp10 = ffi.load("usp10")
-- usp10.ScriptPositionSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, iAdvance, GOffset, piOutAdvance, pOutGoffset)
-- hdc : HDC optional
-- psc : void** in/out
-- psa : SCRIPT_ANALYSIS* optional
-- tagScript : DWORD
-- tagLangSys : DWORD
-- tagFeature : DWORD
-- lParameter : INT
-- wGlyphId : WORD
-- iAdvance : INT
-- GOffset : GOFFSET
-- piOutAdvance : INT* out
-- pOutGoffset : GOFFSET* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('USP10.dll');
const ScriptPositionSingleGlyph = lib.func('__stdcall', 'ScriptPositionSingleGlyph', 'int32_t', ['void *', 'void *', 'void *', 'uint32_t', 'uint32_t', 'uint32_t', 'int32_t', 'uint16_t', 'int32_t', 'GOFFSET', 'int32_t *', 'void *']);
// ScriptPositionSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, iAdvance, GOffset, piOutAdvance, pOutGoffset)
// 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'
// iAdvance : INT -> 'int32_t'
// GOffset : GOFFSET -> 'GOFFSET'
// piOutAdvance : INT* out -> 'int32_t *'
// pOutGoffset : GOFFSET* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USP10.dll", {
ScriptPositionSingleGlyph: { parameters: ["pointer", "pointer", "pointer", "u32", "u32", "u32", "i32", "u16", "i32", "buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.ScriptPositionSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, iAdvance, GOffset, piOutAdvance, pOutGoffset)
// 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"
// iAdvance : INT -> "i32"
// GOffset : GOFFSET -> "buffer"
// piOutAdvance : INT* out -> "pointer"
// pOutGoffset : GOFFSET* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ScriptPositionSingleGlyph(
void* hdc,
void** psc,
void* psa,
uint32_t tagScript,
uint32_t tagLangSys,
uint32_t tagFeature,
int32_t lParameter,
uint16_t wGlyphId,
int32_t iAdvance,
GOFFSET GOffset,
int32_t* piOutAdvance,
void* pOutGoffset);
C, "USP10.dll");
// $ffi->ScriptPositionSingleGlyph(hdc, psc, psa, tagScript, tagLangSys, tagFeature, lParameter, wGlyphId, iAdvance, GOffset, piOutAdvance, pOutGoffset);
// hdc : HDC optional
// psc : void** in/out
// psa : SCRIPT_ANALYSIS* optional
// tagScript : DWORD
// tagLangSys : DWORD
// tagFeature : DWORD
// lParameter : INT
// wGlyphId : WORD
// iAdvance : INT
// GOffset : GOFFSET
// piOutAdvance : INT* out
// pOutGoffset : GOFFSET* 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 ScriptPositionSingleGlyph(
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
int iAdvance, // INT
GOFFSET /* extends Structure (by value) */ GOffset, // GOFFSET
IntByReference piOutAdvance, // INT* out
Pointer pOutGoffset // GOFFSET* out
);
}@[Link("usp10")]
lib LibUSP10
fun ScriptPositionSingleGlyph = ScriptPositionSingleGlyph(
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
iAdvance : Int32, # INT
GOffset : GOFFSET, # GOFFSET
piOutAdvance : Int32*, # INT* out
pOutGoffset : GOFFSET* # GOFFSET* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ScriptPositionSingleGlyphNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Uint32, Uint32, Uint32, Int32, Uint16, Int32, GOFFSET, Pointer<Int32>, Pointer<Void>);
typedef ScriptPositionSingleGlyphDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, int, int, int, int, int, int, int, Pointer<Int32>, Pointer<Void>);
final ScriptPositionSingleGlyph = DynamicLibrary.open('USP10.dll')
.lookupFunction<ScriptPositionSingleGlyphNative, ScriptPositionSingleGlyphDart>('ScriptPositionSingleGlyph');
// 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
// iAdvance : INT -> Int32
// GOffset : GOFFSET -> GOFFSET
// piOutAdvance : INT* out -> Pointer<Int32>
// pOutGoffset : GOFFSET* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ScriptPositionSingleGlyph(
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
iAdvance: Integer; // INT
GOffset: GOFFSET; // GOFFSET
piOutAdvance: Pointer; // INT* out
pOutGoffset: Pointer // GOFFSET* out
): Integer; stdcall;
external 'USP10.dll' name 'ScriptPositionSingleGlyph';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ScriptPositionSingleGlyph"
c_ScriptPositionSingleGlyph :: Ptr () -> Ptr () -> Ptr () -> Word32 -> Word32 -> Word32 -> Int32 -> Word16 -> Int32 -> GOFFSET -> Ptr Int32 -> Ptr () -> 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
-- iAdvance : INT -> Int32
-- GOffset : GOFFSET -> GOFFSET
-- piOutAdvance : INT* out -> Ptr Int32
-- pOutGoffset : GOFFSET* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
-- ※値渡し構造体は GHC FFI で直接渡せません。Ptr で渡すラッパ(C側)経由にしてください。open Ctypes
open Foreign
let scriptpositionsingleglyph =
foreign "ScriptPositionSingleGlyph"
((ptr void) @-> (ptr void) @-> (ptr void) @-> uint32_t @-> uint32_t @-> uint32_t @-> int32_t @-> uint16_t @-> int32_t @-> GOFFSET @-> (ptr int32_t) @-> (ptr void) @-> 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 *)
(* iAdvance : INT -> int32_t *)
(* GOffset : GOFFSET -> GOFFSET *)
(* piOutAdvance : INT* out -> (ptr int32_t) *)
(* pOutGoffset : GOFFSET* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library usp10 (t "USP10.dll"))
(cffi:use-foreign-library usp10)
(cffi:defcfun ("ScriptPositionSingleGlyph" script-position-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
(i-advance :int32) ; INT
(goffset (:struct goffset)) ; GOFFSET
(pi-out-advance :pointer) ; INT* out
(p-out-goffset :pointer)) ; GOFFSET* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ScriptPositionSingleGlyph = Win32::API::More->new('USP10',
'int ScriptPositionSingleGlyph(HANDLE hdc, LPVOID psc, LPVOID psa, DWORD tagScript, DWORD tagLangSys, DWORD tagFeature, int lParameter, WORD wGlyphId, int iAdvance, LPVOID GOffset, LPVOID piOutAdvance, LPVOID pOutGoffset)');
# my $ret = $ScriptPositionSingleGlyph->Call($hdc, $psc, $psa, $tagScript, $tagLangSys, $tagFeature, $lParameter, $wGlyphId, $iAdvance, $GOffset, $piOutAdvance, $pOutGoffset);
# 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
# iAdvance : INT -> int
# GOffset : GOFFSET -> LPVOID
# piOutAdvance : INT* out -> LPVOID
# pOutGoffset : GOFFSET* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f ScriptItemizeOpenType — 文字列をスクリプトタグ付きでアイテム分割する。