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

GetGlyphOutlineW

関数
文字のグリフ輪郭やビットマップを取得する。
DLLGDI32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD GetGlyphOutlineW(
    HDC hdc,
    DWORD uChar,
    GET_GLYPH_OUTLINE_FORMAT fuFormat,
    GLYPHMETRICS* lpgm,
    DWORD cjBuffer,
    void* pvBuffer,   // optional
    const MAT2* lpmat2
);

パラメーター

名前方向
hdcHDCin
uCharDWORDin
fuFormatGET_GLYPH_OUTLINE_FORMATin
lpgmGLYPHMETRICS*out
cjBufferDWORDin
pvBuffervoid*outoptional
lpmat2MAT2*in

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD GetGlyphOutlineW(
    HDC hdc,
    DWORD uChar,
    GET_GLYPH_OUTLINE_FORMAT fuFormat,
    GLYPHMETRICS* lpgm,
    DWORD cjBuffer,
    void* pvBuffer,   // optional
    const MAT2* lpmat2
);
[DllImport("GDI32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint GetGlyphOutlineW(
    IntPtr hdc,   // HDC
    uint uChar,   // DWORD
    uint fuFormat,   // GET_GLYPH_OUTLINE_FORMAT
    IntPtr lpgm,   // GLYPHMETRICS* out
    uint cjBuffer,   // DWORD
    IntPtr pvBuffer,   // void* optional, out
    IntPtr lpmat2   // MAT2*
);
<DllImport("GDI32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function GetGlyphOutlineW(
    hdc As IntPtr,   ' HDC
    uChar As UInteger,   ' DWORD
    fuFormat As UInteger,   ' GET_GLYPH_OUTLINE_FORMAT
    lpgm As IntPtr,   ' GLYPHMETRICS* out
    cjBuffer As UInteger,   ' DWORD
    pvBuffer As IntPtr,   ' void* optional, out
    lpmat2 As IntPtr   ' MAT2*
) As UInteger
End Function
' hdc : HDC
' uChar : DWORD
' fuFormat : GET_GLYPH_OUTLINE_FORMAT
' lpgm : GLYPHMETRICS* out
' cjBuffer : DWORD
' pvBuffer : void* optional, out
' lpmat2 : MAT2*
Declare PtrSafe Function GetGlyphOutlineW Lib "gdi32" ( _
    ByVal hdc As LongPtr, _
    ByVal uChar As Long, _
    ByVal fuFormat As Long, _
    ByVal lpgm As LongPtr, _
    ByVal cjBuffer As Long, _
    ByVal pvBuffer As LongPtr, _
    ByVal lpmat2 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

GetGlyphOutlineW = ctypes.windll.gdi32.GetGlyphOutlineW
GetGlyphOutlineW.restype = wintypes.DWORD
GetGlyphOutlineW.argtypes = [
    wintypes.HANDLE,  # hdc : HDC
    wintypes.DWORD,  # uChar : DWORD
    wintypes.DWORD,  # fuFormat : GET_GLYPH_OUTLINE_FORMAT
    ctypes.c_void_p,  # lpgm : GLYPHMETRICS* out
    wintypes.DWORD,  # cjBuffer : DWORD
    ctypes.POINTER(None),  # pvBuffer : void* optional, out
    ctypes.c_void_p,  # lpmat2 : MAT2*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	gdi32 = windows.NewLazySystemDLL("GDI32.dll")
	procGetGlyphOutlineW = gdi32.NewProc("GetGlyphOutlineW")
)

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