Win32 API 日本語リファレンス
ホームGraphics.Gdi › GetOutlineTextMetricsW

GetOutlineTextMetricsW

関数
アウトラインフォントのテキストメトリックを取得する。
DLLGDI32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// GDI32.dll  (Unicode / -W)
#include <windows.h>

DWORD GetOutlineTextMetricsW(
    HDC hdc,
    DWORD cjCopy,
    OUTLINETEXTMETRICW* potm   // optional
);

パラメーター

名前方向
hdcHDCin
cjCopyDWORDin
potmOUTLINETEXTMETRICW*outoptional

戻り値の型: DWORD

各言語での呼び出し定義

// GDI32.dll  (Unicode / -W)
#include <windows.h>

DWORD GetOutlineTextMetricsW(
    HDC hdc,
    DWORD cjCopy,
    OUTLINETEXTMETRICW* potm   // optional
);
[DllImport("GDI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint GetOutlineTextMetricsW(
    IntPtr hdc,   // HDC
    uint cjCopy,   // DWORD
    IntPtr potm   // OUTLINETEXTMETRICW* optional, out
);
<DllImport("GDI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function GetOutlineTextMetricsW(
    hdc As IntPtr,   ' HDC
    cjCopy As UInteger,   ' DWORD
    potm As IntPtr   ' OUTLINETEXTMETRICW* optional, out
) As UInteger
End Function
' hdc : HDC
' cjCopy : DWORD
' potm : OUTLINETEXTMETRICW* optional, out
Declare PtrSafe Function GetOutlineTextMetricsW Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal cjCopy As Long, _
    ByVal potm 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

GetOutlineTextMetricsW = ctypes.windll.gdi32.GetOutlineTextMetricsW
GetOutlineTextMetricsW.restype = wintypes.DWORD
GetOutlineTextMetricsW.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    wintypes.DWORD,  # cjCopy : DWORD
    ctypes.c_void_p,  # potm : OUTLINETEXTMETRICW* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('GDI32.dll')
GetOutlineTextMetricsW = Fiddle::Function.new(
  lib['GetOutlineTextMetricsW'],
  [
    Fiddle::TYPE_VOIDP,  # hdc : HDC
    -Fiddle::TYPE_INT,  # cjCopy : DWORD
    Fiddle::TYPE_VOIDP,  # potm : OUTLINETEXTMETRICW* optional, out
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "gdi32")]
extern "system" {
    fn GetOutlineTextMetricsW(
        hdc: *mut core::ffi::c_void,  // HDC
        cjCopy: u32,  // DWORD
        potm: *mut OUTLINETEXTMETRICW  // OUTLINETEXTMETRICW* optional, out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("GDI32.dll", CharSet = CharSet.Unicode)]
public static extern uint GetOutlineTextMetricsW(IntPtr hdc, uint cjCopy, IntPtr potm);
"@
$api = Add-Type -MemberDefinition $sig -Name 'GDI32_GetOutlineTextMetricsW' -Namespace Win32 -PassThru
# $api::GetOutlineTextMetricsW(hdc, cjCopy, potm)
#uselib "GDI32.dll"
#func global GetOutlineTextMetricsW "GetOutlineTextMetricsW" wptr, wptr, wptr
; GetOutlineTextMetricsW hdc, cjCopy, varptr(potm)   ; 戻り値は stat
; hdc : HDC -> "wptr"
; cjCopy : DWORD -> "wptr"
; potm : OUTLINETEXTMETRICW* optional, out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "GDI32.dll"
#cfunc global GetOutlineTextMetricsW "GetOutlineTextMetricsW" sptr, int, var
; res = GetOutlineTextMetricsW(hdc, cjCopy, potm)
; hdc : HDC -> "sptr"
; cjCopy : DWORD -> "int"
; potm : OUTLINETEXTMETRICW* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD GetOutlineTextMetricsW(HDC hdc, DWORD cjCopy, OUTLINETEXTMETRICW* potm)
#uselib "GDI32.dll"
#cfunc global GetOutlineTextMetricsW "GetOutlineTextMetricsW" intptr, int, var
; res = GetOutlineTextMetricsW(hdc, cjCopy, potm)
; hdc : HDC -> "intptr"
; cjCopy : DWORD -> "int"
; potm : OUTLINETEXTMETRICW* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procGetOutlineTextMetricsW = gdi32.NewProc("GetOutlineTextMetricsW")
)

// hdc (HDC), cjCopy (DWORD), potm (OUTLINETEXTMETRICW* optional, out)
r1, _, err := procGetOutlineTextMetricsW.Call(
	uintptr(hdc),
	uintptr(cjCopy),
	uintptr(potm),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function GetOutlineTextMetricsW(
  hdc: THandle;   // HDC
  cjCopy: DWORD;   // DWORD
  potm: Pointer   // OUTLINETEXTMETRICW* optional, out
): DWORD; stdcall;
  external 'GDI32.dll' name 'GetOutlineTextMetricsW';
result := DllCall("GDI32\GetOutlineTextMetricsW"
    , "Ptr", hdc   ; HDC
    , "UInt", cjCopy   ; DWORD
    , "Ptr", potm   ; OUTLINETEXTMETRICW* optional, out
    , "UInt")   ; return: DWORD
●GetOutlineTextMetricsW(hdc, cjCopy, potm) = DLL("GDI32.dll", "dword GetOutlineTextMetricsW(void*, dword, void*)")
# 呼び出し: GetOutlineTextMetricsW(hdc, cjCopy, potm)
# hdc : HDC -> "void*"
# cjCopy : DWORD -> "dword"
# potm : OUTLINETEXTMETRICW* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。