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

GdipGetLogFontA

関数
フォントからLOGFONT構造体を取得する(ANSI版)。
DLLgdiplus.dll文字セットANSI (-A)呼出規約winapi

シグネチャ

// gdiplus.dll  (ANSI / -A)
#include <windows.h>

Status GdipGetLogFontA(
    GpFont* font,
    GpGraphics* graphics,
    LOGFONTA* logfontA
);

パラメーター

名前方向説明
fontGpFont*inoutLOGFONT情報を取得する対象のGpFontオブジェクトへのポインタ。
graphicsGpGraphics*inout変換時の単位や変換行列の基準とするGpGraphicsオブジェクトへのポインタ。
logfontALOGFONTA*inoutANSI版LOGFONTA構造体を受け取る出力先のポインタ。

戻り値の型: Status

各言語での呼び出し定義

// gdiplus.dll  (ANSI / -A)
#include <windows.h>

Status GdipGetLogFontA(
    GpFont* font,
    GpGraphics* graphics,
    LOGFONTA* logfontA
);
[DllImport("gdiplus.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int GdipGetLogFontA(
    IntPtr font,   // GpFont* in/out
    IntPtr graphics,   // GpGraphics* in/out
    IntPtr logfontA   // LOGFONTA* in/out
);
<DllImport("gdiplus.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function GdipGetLogFontA(
    font As IntPtr,   ' GpFont* in/out
    graphics As IntPtr,   ' GpGraphics* in/out
    logfontA As IntPtr   ' LOGFONTA* in/out
) As Integer
End Function
' font : GpFont* in/out
' graphics : GpGraphics* in/out
' logfontA : LOGFONTA* in/out
Declare PtrSafe Function GdipGetLogFontA Lib "gdiplus" ( _
    ByVal font As LongPtr, _
    ByVal graphics As LongPtr, _
    ByVal logfontA As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GdipGetLogFontA = ctypes.windll.gdiplus.GdipGetLogFontA
GdipGetLogFontA.restype = ctypes.c_int
GdipGetLogFontA.argtypes = [
    ctypes.c_void_p,  # font : GpFont* in/out
    ctypes.c_void_p,  # graphics : GpGraphics* in/out
    ctypes.c_void_p,  # logfontA : LOGFONTA* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('gdiplus.dll')
GdipGetLogFontA = Fiddle::Function.new(
  lib['GdipGetLogFontA'],
  [
    Fiddle::TYPE_VOIDP,  # font : GpFont* in/out
    Fiddle::TYPE_VOIDP,  # graphics : GpGraphics* in/out
    Fiddle::TYPE_VOIDP,  # logfontA : LOGFONTA* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "gdiplus")]
extern "system" {
    fn GdipGetLogFontA(
        font: *mut GpFont,  // GpFont* in/out
        graphics: *mut GpGraphics,  // GpGraphics* in/out
        logfontA: *mut LOGFONTA  // LOGFONTA* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("gdiplus.dll", CharSet = CharSet.Ansi)]
public static extern int GdipGetLogFontA(IntPtr font, IntPtr graphics, IntPtr logfontA);
"@
$api = Add-Type -MemberDefinition $sig -Name 'gdiplus_GdipGetLogFontA' -Namespace Win32 -PassThru
# $api::GdipGetLogFontA(font, graphics, logfontA)
#uselib "gdiplus.dll"
#func global GdipGetLogFontA "GdipGetLogFontA" sptr, sptr, sptr
; GdipGetLogFontA varptr(font), varptr(graphics), varptr(logfontA)   ; 戻り値は stat
; font : GpFont* in/out -> "sptr"
; graphics : GpGraphics* in/out -> "sptr"
; logfontA : LOGFONTA* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "gdiplus.dll"
#cfunc global GdipGetLogFontA "GdipGetLogFontA" var, var, var
; res = GdipGetLogFontA(font, graphics, logfontA)
; font : GpFont* in/out -> "var"
; graphics : GpGraphics* in/out -> "var"
; logfontA : LOGFONTA* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; Status GdipGetLogFontA(GpFont* font, GpGraphics* graphics, LOGFONTA* logfontA)
#uselib "gdiplus.dll"
#cfunc global GdipGetLogFontA "GdipGetLogFontA" var, var, var
; res = GdipGetLogFontA(font, graphics, logfontA)
; font : GpFont* in/out -> "var"
; graphics : GpGraphics* in/out -> "var"
; logfontA : LOGFONTA* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	gdiplus = windows.NewLazySystemDLL("gdiplus.dll")
	procGdipGetLogFontA = gdiplus.NewProc("GdipGetLogFontA")
)

// font (GpFont* in/out), graphics (GpGraphics* in/out), logfontA (LOGFONTA* in/out)
r1, _, err := procGdipGetLogFontA.Call(
	uintptr(font),
	uintptr(graphics),
	uintptr(logfontA),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // Status
function GdipGetLogFontA(
  font: Pointer;   // GpFont* in/out
  graphics: Pointer;   // GpGraphics* in/out
  logfontA: Pointer   // LOGFONTA* in/out
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipGetLogFontA';
result := DllCall("gdiplus\GdipGetLogFontA"
    , "Ptr", font   ; GpFont* in/out
    , "Ptr", graphics   ; GpGraphics* in/out
    , "Ptr", logfontA   ; LOGFONTA* in/out
    , "Int")   ; return: Status
●GdipGetLogFontA(font, graphics, logfontA) = DLL("gdiplus.dll", "int GdipGetLogFontA(void*, void*, void*)")
# 呼び出し: GdipGetLogFontA(font, graphics, logfontA)
# font : GpFont* in/out -> "void*"
# graphics : GpGraphics* in/out -> "void*"
# logfontA : LOGFONTA* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "gdiplus" fn GdipGetLogFontA(
    font: [*c]GpFont, // GpFont* in/out
    graphics: [*c]GpGraphics, // GpGraphics* in/out
    logfontA: [*c]LOGFONTA // LOGFONTA* in/out
) callconv(std.os.windows.WINAPI) i32;
proc GdipGetLogFontA(
    font: ptr GpFont,  # GpFont* in/out
    graphics: ptr GpGraphics,  # GpGraphics* in/out
    logfontA: ptr LOGFONTA  # LOGFONTA* in/out
): int32 {.importc: "GdipGetLogFontA", stdcall, dynlib: "gdiplus.dll".}
pragma(lib, "gdiplus");
extern(Windows)
int GdipGetLogFontA(
    GpFont* font,   // GpFont* in/out
    GpGraphics* graphics,   // GpGraphics* in/out
    LOGFONTA* logfontA   // LOGFONTA* in/out
);
ccall((:GdipGetLogFontA, "gdiplus.dll"), stdcall, Int32,
      (Ptr{GpFont}, Ptr{GpGraphics}, Ptr{LOGFONTA}),
      font, graphics, logfontA)
# font : GpFont* in/out -> Ptr{GpFont}
# graphics : GpGraphics* in/out -> Ptr{GpGraphics}
# logfontA : LOGFONTA* in/out -> Ptr{LOGFONTA}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t GdipGetLogFontA(
    void* font,
    void* graphics,
    void* logfontA);
]]
local gdiplus = ffi.load("gdiplus")
-- gdiplus.GdipGetLogFontA(font, graphics, logfontA)
-- font : GpFont* in/out
-- graphics : GpGraphics* in/out
-- logfontA : LOGFONTA* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('gdiplus.dll');
const GdipGetLogFontA = lib.func('__stdcall', 'GdipGetLogFontA', 'int32_t', ['void *', 'void *', 'void *']);
// GdipGetLogFontA(font, graphics, logfontA)
// font : GpFont* in/out -> 'void *'
// graphics : GpGraphics* in/out -> 'void *'
// logfontA : LOGFONTA* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("gdiplus.dll", {
  GdipGetLogFontA: { parameters: ["pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.GdipGetLogFontA(font, graphics, logfontA)
// font : GpFont* in/out -> "pointer"
// graphics : GpGraphics* in/out -> "pointer"
// logfontA : LOGFONTA* in/out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t GdipGetLogFontA(
    void* font,
    void* graphics,
    void* logfontA);
C, "gdiplus.dll");
// $ffi->GdipGetLogFontA(font, graphics, logfontA);
// font : GpFont* in/out
// graphics : GpGraphics* in/out
// logfontA : LOGFONTA* 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.ASCII_OPTIONS);
    int GdipGetLogFontA(
        Pointer font,   // GpFont* in/out
        Pointer graphics,   // GpGraphics* in/out
        Pointer logfontA   // LOGFONTA* in/out
    );
}
@[Link("gdiplus")]
lib Libgdiplus
  fun GdipGetLogFontA = GdipGetLogFontA(
    font : GpFont*,   # GpFont* in/out
    graphics : GpGraphics*,   # GpGraphics* in/out
    logfontA : LOGFONTA*   # LOGFONTA* 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 GdipGetLogFontANative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef GdipGetLogFontADart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>);
final GdipGetLogFontA = DynamicLibrary.open('gdiplus.dll')
    .lookupFunction<GdipGetLogFontANative, GdipGetLogFontADart>('GdipGetLogFontA');
// font : GpFont* in/out -> Pointer<Void>
// graphics : GpGraphics* in/out -> Pointer<Void>
// logfontA : LOGFONTA* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function GdipGetLogFontA(
  font: Pointer;   // GpFont* in/out
  graphics: Pointer;   // GpGraphics* in/out
  logfontA: Pointer   // LOGFONTA* in/out
): Integer; stdcall;
  external 'gdiplus.dll' name 'GdipGetLogFontA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "GdipGetLogFontA"
  c_GdipGetLogFontA :: Ptr () -> Ptr () -> Ptr () -> IO Int32
-- font : GpFont* in/out -> Ptr ()
-- graphics : GpGraphics* in/out -> Ptr ()
-- logfontA : LOGFONTA* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let gdipgetlogfonta =
  foreign "GdipGetLogFontA"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* font : GpFont* in/out -> (ptr void) *)
(* graphics : GpGraphics* in/out -> (ptr void) *)
(* logfontA : LOGFONTA* 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 ("GdipGetLogFontA" gdip-get-log-font-a :convention :stdcall) :int32
  (font :pointer)   ; GpFont* in/out
  (graphics :pointer)   ; GpGraphics* in/out
  (logfont-a :pointer))   ; LOGFONTA* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $GdipGetLogFontA = Win32::API::More->new('gdiplus',
    'int GdipGetLogFontA(LPVOID font, LPVOID graphics, LPVOID logfontA)');
# my $ret = $GdipGetLogFontA->Call($font, $graphics, $logfontA);
# font : GpFont* in/out -> LPVOID
# graphics : GpGraphics* in/out -> LPVOID
# logfontA : LOGFONTA* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い
使用する型