ホーム › Graphics.GdiPlus › GdipGetLogFontW
GdipGetLogFontW
関数フォントからLOGFONT構造体を取得する(Unicode版)。
シグネチャ
// gdiplus.dll (Unicode / -W)
#include <windows.h>
Status GdipGetLogFontW(
GpFont* font,
GpGraphics* graphics,
LOGFONTW* logfontW
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| font | GpFont* | inout | LOGFONT情報を取得する対象のGpFontオブジェクトへのポインタ。 |
| graphics | GpGraphics* | inout | 変換時の単位や変換行列の基準とするGpGraphicsオブジェクトへのポインタ。 |
| logfontW | LOGFONTW* | inout | Unicode版LOGFONTW構造体を受け取る出力先のポインタ。 |
戻り値の型: Status
各言語での呼び出し定義
// gdiplus.dll (Unicode / -W)
#include <windows.h>
Status GdipGetLogFontW(
GpFont* font,
GpGraphics* graphics,
LOGFONTW* logfontW
);[DllImport("gdiplus.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int GdipGetLogFontW(
IntPtr font, // GpFont* in/out
IntPtr graphics, // GpGraphics* in/out
IntPtr logfontW // LOGFONTW* in/out
);<DllImport("gdiplus.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function GdipGetLogFontW(
font As IntPtr, ' GpFont* in/out
graphics As IntPtr, ' GpGraphics* in/out
logfontW As IntPtr ' LOGFONTW* in/out
) As Integer
End Function' font : GpFont* in/out
' graphics : GpGraphics* in/out
' logfontW : LOGFONTW* in/out
Declare PtrSafe Function GdipGetLogFontW Lib "gdiplus" ( _
ByVal font As LongPtr, _
ByVal graphics As LongPtr, _
ByVal logfontW 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
GdipGetLogFontW = ctypes.windll.gdiplus.GdipGetLogFontW
GdipGetLogFontW.restype = ctypes.c_int
GdipGetLogFontW.argtypes = [
ctypes.c_void_p, # font : GpFont* in/out
ctypes.c_void_p, # graphics : GpGraphics* in/out
ctypes.c_void_p, # logfontW : LOGFONTW* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('gdiplus.dll')
GdipGetLogFontW = Fiddle::Function.new(
lib['GdipGetLogFontW'],
[
Fiddle::TYPE_VOIDP, # font : GpFont* in/out
Fiddle::TYPE_VOIDP, # graphics : GpGraphics* in/out
Fiddle::TYPE_VOIDP, # logfontW : LOGFONTW* in/out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "gdiplus")]
extern "system" {
fn GdipGetLogFontW(
font: *mut GpFont, // GpFont* in/out
graphics: *mut GpGraphics, // GpGraphics* in/out
logfontW: *mut LOGFONTW // LOGFONTW* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("gdiplus.dll", CharSet = CharSet.Unicode)]
public static extern int GdipGetLogFontW(IntPtr font, IntPtr graphics, IntPtr logfontW);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipGetLogFontW' -Namespace Win32 -PassThru
# $api::GdipGetLogFontW(font, graphics, logfontW)#uselib "gdiplus.dll"
#func global GdipGetLogFontW "GdipGetLogFontW" wptr, wptr, wptr
; GdipGetLogFontW varptr(font), varptr(graphics), varptr(logfontW) ; 戻り値は stat
; font : GpFont* in/out -> "wptr"
; graphics : GpGraphics* in/out -> "wptr"
; logfontW : LOGFONTW* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "gdiplus.dll" #cfunc global GdipGetLogFontW "GdipGetLogFontW" var, var, var ; res = GdipGetLogFontW(font, graphics, logfontW) ; font : GpFont* in/out -> "var" ; graphics : GpGraphics* in/out -> "var" ; logfontW : LOGFONTW* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "gdiplus.dll" #cfunc global GdipGetLogFontW "GdipGetLogFontW" sptr, sptr, sptr ; res = GdipGetLogFontW(varptr(font), varptr(graphics), varptr(logfontW)) ; font : GpFont* in/out -> "sptr" ; graphics : GpGraphics* in/out -> "sptr" ; logfontW : LOGFONTW* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; Status GdipGetLogFontW(GpFont* font, GpGraphics* graphics, LOGFONTW* logfontW) #uselib "gdiplus.dll" #cfunc global GdipGetLogFontW "GdipGetLogFontW" var, var, var ; res = GdipGetLogFontW(font, graphics, logfontW) ; font : GpFont* in/out -> "var" ; graphics : GpGraphics* in/out -> "var" ; logfontW : LOGFONTW* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; Status GdipGetLogFontW(GpFont* font, GpGraphics* graphics, LOGFONTW* logfontW) #uselib "gdiplus.dll" #cfunc global GdipGetLogFontW "GdipGetLogFontW" intptr, intptr, intptr ; res = GdipGetLogFontW(varptr(font), varptr(graphics), varptr(logfontW)) ; font : GpFont* in/out -> "intptr" ; graphics : GpGraphics* in/out -> "intptr" ; logfontW : LOGFONTW* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
procGdipGetLogFontW = gdiplus.NewProc("GdipGetLogFontW")
)
// font (GpFont* in/out), graphics (GpGraphics* in/out), logfontW (LOGFONTW* in/out)
r1, _, err := procGdipGetLogFontW.Call(
uintptr(font),
uintptr(graphics),
uintptr(logfontW),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // Statusfunction GdipGetLogFontW(
font: Pointer; // GpFont* in/out
graphics: Pointer; // GpGraphics* in/out
logfontW: Pointer // LOGFONTW* in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipGetLogFontW';result := DllCall("gdiplus\GdipGetLogFontW"
, "Ptr", font ; GpFont* in/out
, "Ptr", graphics ; GpGraphics* in/out
, "Ptr", logfontW ; LOGFONTW* in/out
, "Int") ; return: Status●GdipGetLogFontW(font, graphics, logfontW) = DLL("gdiplus.dll", "int GdipGetLogFontW(void*, void*, void*)")
# 呼び出し: GdipGetLogFontW(font, graphics, logfontW)
# font : GpFont* in/out -> "void*"
# graphics : GpGraphics* in/out -> "void*"
# logfontW : LOGFONTW* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "gdiplus" fn GdipGetLogFontW(
font: [*c]GpFont, // GpFont* in/out
graphics: [*c]GpGraphics, // GpGraphics* in/out
logfontW: [*c]LOGFONTW // LOGFONTW* in/out
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc GdipGetLogFontW(
font: ptr GpFont, # GpFont* in/out
graphics: ptr GpGraphics, # GpGraphics* in/out
logfontW: ptr LOGFONTW # LOGFONTW* in/out
): int32 {.importc: "GdipGetLogFontW", stdcall, dynlib: "gdiplus.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "gdiplus");
extern(Windows)
int GdipGetLogFontW(
GpFont* font, // GpFont* in/out
GpGraphics* graphics, // GpGraphics* in/out
LOGFONTW* logfontW // LOGFONTW* in/out
);ccall((:GdipGetLogFontW, "gdiplus.dll"), stdcall, Int32,
(Ptr{GpFont}, Ptr{GpGraphics}, Ptr{LOGFONTW}),
font, graphics, logfontW)
# font : GpFont* in/out -> Ptr{GpFont}
# graphics : GpGraphics* in/out -> Ptr{GpGraphics}
# logfontW : LOGFONTW* in/out -> Ptr{LOGFONTW}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t GdipGetLogFontW(
void* font,
void* graphics,
void* logfontW);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipGetLogFontW(font, graphics, logfontW)
-- font : GpFont* in/out
-- graphics : GpGraphics* in/out
-- logfontW : LOGFONTW* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('gdiplus.dll');
const GdipGetLogFontW = lib.func('__stdcall', 'GdipGetLogFontW', 'int32_t', ['void *', 'void *', 'void *']);
// GdipGetLogFontW(font, graphics, logfontW)
// font : GpFont* in/out -> 'void *'
// graphics : GpGraphics* in/out -> 'void *'
// logfontW : LOGFONTW* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("gdiplus.dll", {
GdipGetLogFontW: { parameters: ["pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.GdipGetLogFontW(font, graphics, logfontW)
// font : GpFont* in/out -> "pointer"
// graphics : GpGraphics* in/out -> "pointer"
// logfontW : LOGFONTW* in/out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t GdipGetLogFontW(
void* font,
void* graphics,
void* logfontW);
C, "gdiplus.dll");
// $ffi->GdipGetLogFontW(font, graphics, logfontW);
// font : GpFont* in/out
// graphics : GpGraphics* in/out
// logfontW : LOGFONTW* in/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 Gdiplus extends StdCallLibrary {
Gdiplus INSTANCE = Native.load("gdiplus", Gdiplus.class, W32APIOptions.UNICODE_OPTIONS);
int GdipGetLogFontW(
Pointer font, // GpFont* in/out
Pointer graphics, // GpGraphics* in/out
Pointer logfontW // LOGFONTW* in/out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("gdiplus")]
lib Libgdiplus
fun GdipGetLogFontW = GdipGetLogFontW(
font : GpFont*, # GpFont* in/out
graphics : GpGraphics*, # GpGraphics* in/out
logfontW : LOGFONTW* # LOGFONTW* in/out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef GdipGetLogFontWNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef GdipGetLogFontWDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
final GdipGetLogFontW = DynamicLibrary.open('gdiplus.dll')
.lookupFunction<GdipGetLogFontWNative, GdipGetLogFontWDart>('GdipGetLogFontW');
// font : GpFont* in/out -> Pointer<Void>
// graphics : GpGraphics* in/out -> Pointer<Void>
// logfontW : LOGFONTW* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function GdipGetLogFontW(
font: Pointer; // GpFont* in/out
graphics: Pointer; // GpGraphics* in/out
logfontW: Pointer // LOGFONTW* in/out
): Integer; stdcall;
external 'gdiplus.dll' name 'GdipGetLogFontW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "GdipGetLogFontW"
c_GdipGetLogFontW :: Ptr () -> Ptr () -> Ptr () -> IO Int32
-- font : GpFont* in/out -> Ptr ()
-- graphics : GpGraphics* in/out -> Ptr ()
-- logfontW : LOGFONTW* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let gdipgetlogfontw =
foreign "GdipGetLogFontW"
((ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* font : GpFont* in/out -> (ptr void) *)
(* graphics : GpGraphics* in/out -> (ptr void) *)
(* logfontW : LOGFONTW* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library gdiplus (t "gdiplus.dll"))
(cffi:use-foreign-library gdiplus)
(cffi:defcfun ("GdipGetLogFontW" gdip-get-log-font-w :convention :stdcall) :int32
(font :pointer) ; GpFont* in/out
(graphics :pointer) ; GpGraphics* in/out
(logfont-w :pointer)) ; LOGFONTW* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $GdipGetLogFontW = Win32::API::More->new('gdiplus',
'int GdipGetLogFontW(LPVOID font, LPVOID graphics, LPVOID logfontW)');
# my $ret = $GdipGetLogFontW->Call($font, $graphics, $logfontW);
# font : GpFont* in/out -> LPVOID
# graphics : GpGraphics* in/out -> LPVOID
# logfontW : LOGFONTW* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f GdipGetLogFontA (ANSI版) — フォントからLOGFONT構造体を取得する(ANSI版)。