ホーム › Graphics.Gdi › GetKerningPairsW
GetKerningPairsW
関数フォントのカーニングペア情報を取得する(Unicode版)。
シグネチャ
// GDI32.dll (Unicode / -W)
#include <windows.h>
DWORD GetKerningPairsW(
HDC hdc,
DWORD nPairs,
KERNINGPAIR* lpKernPair // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hdc | HDC | in |
| nPairs | DWORD | in |
| lpKernPair | KERNINGPAIR* | outoptional |
戻り値の型: DWORD
各言語での呼び出し定義
// GDI32.dll (Unicode / -W)
#include <windows.h>
DWORD GetKerningPairsW(
HDC hdc,
DWORD nPairs,
KERNINGPAIR* lpKernPair // optional
);[DllImport("GDI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint GetKerningPairsW(
IntPtr hdc, // HDC
uint nPairs, // DWORD
IntPtr lpKernPair // KERNINGPAIR* optional, out
);<DllImport("GDI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function GetKerningPairsW(
hdc As IntPtr, ' HDC
nPairs As UInteger, ' DWORD
lpKernPair As IntPtr ' KERNINGPAIR* optional, out
) As UInteger
End Function' hdc : HDC
' nPairs : DWORD
' lpKernPair : KERNINGPAIR* optional, out
Declare PtrSafe Function GetKerningPairsW Lib "gdi32" ( _
ByVal hdc As LongPtr, _
ByVal nPairs As Long, _
ByVal lpKernPair As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetKerningPairsW = ctypes.windll.gdi32.GetKerningPairsW
GetKerningPairsW.restype = wintypes.DWORD
GetKerningPairsW.argtypes = [
wintypes.HANDLE, # hdc : HDC
wintypes.DWORD, # nPairs : DWORD
ctypes.c_void_p, # lpKernPair : KERNINGPAIR* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('GDI32.dll')
GetKerningPairsW = Fiddle::Function.new(
lib['GetKerningPairsW'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
-Fiddle::TYPE_INT, # nPairs : DWORD
Fiddle::TYPE_VOIDP, # lpKernPair : KERNINGPAIR* optional, out
],
-Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "gdi32")]
extern "system" {
fn GetKerningPairsW(
hdc: *mut core::ffi::c_void, // HDC
nPairs: u32, // DWORD
lpKernPair: *mut KERNINGPAIR // KERNINGPAIR* optional, out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("GDI32.dll", CharSet = CharSet.Unicode)]
public static extern uint GetKerningPairsW(IntPtr hdc, uint nPairs, IntPtr lpKernPair);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_GetKerningPairsW' -Namespace Win32 -PassThru
# $api::GetKerningPairsW(hdc, nPairs, lpKernPair)#uselib "GDI32.dll"
#func global GetKerningPairsW "GetKerningPairsW" wptr, wptr, wptr
; GetKerningPairsW hdc, nPairs, varptr(lpKernPair) ; 戻り値は stat
; hdc : HDC -> "wptr"
; nPairs : DWORD -> "wptr"
; lpKernPair : KERNINGPAIR* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "GDI32.dll" #cfunc global GetKerningPairsW "GetKerningPairsW" sptr, int, var ; res = GetKerningPairsW(hdc, nPairs, lpKernPair) ; hdc : HDC -> "sptr" ; nPairs : DWORD -> "int" ; lpKernPair : KERNINGPAIR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "GDI32.dll" #cfunc global GetKerningPairsW "GetKerningPairsW" sptr, int, sptr ; res = GetKerningPairsW(hdc, nPairs, varptr(lpKernPair)) ; hdc : HDC -> "sptr" ; nPairs : DWORD -> "int" ; lpKernPair : KERNINGPAIR* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD GetKerningPairsW(HDC hdc, DWORD nPairs, KERNINGPAIR* lpKernPair) #uselib "GDI32.dll" #cfunc global GetKerningPairsW "GetKerningPairsW" intptr, int, var ; res = GetKerningPairsW(hdc, nPairs, lpKernPair) ; hdc : HDC -> "intptr" ; nPairs : DWORD -> "int" ; lpKernPair : KERNINGPAIR* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD GetKerningPairsW(HDC hdc, DWORD nPairs, KERNINGPAIR* lpKernPair) #uselib "GDI32.dll" #cfunc global GetKerningPairsW "GetKerningPairsW" intptr, int, intptr ; res = GetKerningPairsW(hdc, nPairs, varptr(lpKernPair)) ; hdc : HDC -> "intptr" ; nPairs : DWORD -> "int" ; lpKernPair : KERNINGPAIR* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdi32 = windows.NewLazySystemDLL("GDI32.dll")
procGetKerningPairsW = gdi32.NewProc("GetKerningPairsW")
)
// hdc (HDC), nPairs (DWORD), lpKernPair (KERNINGPAIR* optional, out)
r1, _, err := procGetKerningPairsW.Call(
uintptr(hdc),
uintptr(nPairs),
uintptr(lpKernPair),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction GetKerningPairsW(
hdc: THandle; // HDC
nPairs: DWORD; // DWORD
lpKernPair: Pointer // KERNINGPAIR* optional, out
): DWORD; stdcall;
external 'GDI32.dll' name 'GetKerningPairsW';result := DllCall("GDI32\GetKerningPairsW"
, "Ptr", hdc ; HDC
, "UInt", nPairs ; DWORD
, "Ptr", lpKernPair ; KERNINGPAIR* optional, out
, "UInt") ; return: DWORD●GetKerningPairsW(hdc, nPairs, lpKernPair) = DLL("GDI32.dll", "dword GetKerningPairsW(void*, dword, void*)")
# 呼び出し: GetKerningPairsW(hdc, nPairs, lpKernPair)
# hdc : HDC -> "void*"
# nPairs : DWORD -> "dword"
# lpKernPair : KERNINGPAIR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。