ホーム › Globalization › ScriptGetGlyphABCWidth
ScriptGetGlyphABCWidth
関数指定グリフのABC幅を取得する。
シグネチャ
// USP10.dll
#include <windows.h>
HRESULT ScriptGetGlyphABCWidth(
HDC hdc,
void** psc,
WORD wGlyph,
ABC* pABC
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hdc | HDC | in | 省略可能。デバイスコンテキストへのハンドルです。詳細については、キャッシュを参照してください。 |
| psc | void** | inout | スクリプトキャッシュを識別する SCRIPT_CACHE 構造体へのポインターです。 |
| wGlyph | WORD | in | 解析対象のグリフです。 |
| pABC | ABC* | out | 指定したグリフの ABC 幅へのポインターです。 |
戻り値の型: HRESULT
公式ドキュメント
指定したグリフの ABC 幅を取得します。
戻り値
グリフの ABC 幅を取得できた場合は S_OK を返します。成功しなかった場合、この関数は 0 以外の HRESULT 値を返します。
フォントまたはオペレーティングシステムがグリフインデックスをサポートしていない場合、この関数は E_HANDLE を返します。
解説(Remarks)
この関数の用途は限られています。たとえば、グリフチャートの描画に役立ちます。通常の複雑なスクリプトテキストの整形には使用しないでください。
重要 Windows 8 以降: Windows 7 上で実行できる状態を維持するため、Uniscribe を使用するモジュールは、ライブラリリスト内で gdi32.lib より前に Usp10.lib を指定する必要があります。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// USP10.dll
#include <windows.h>
HRESULT ScriptGetGlyphABCWidth(
HDC hdc,
void** psc,
WORD wGlyph,
ABC* pABC
);[DllImport("USP10.dll", ExactSpelling = true)]
static extern int ScriptGetGlyphABCWidth(
IntPtr hdc, // HDC
IntPtr psc, // void** in/out
ushort wGlyph, // WORD
IntPtr pABC // ABC* out
);<DllImport("USP10.dll", ExactSpelling:=True)>
Public Shared Function ScriptGetGlyphABCWidth(
hdc As IntPtr, ' HDC
psc As IntPtr, ' void** in/out
wGlyph As UShort, ' WORD
pABC As IntPtr ' ABC* out
) As Integer
End Function' hdc : HDC
' psc : void** in/out
' wGlyph : WORD
' pABC : ABC* out
Declare PtrSafe Function ScriptGetGlyphABCWidth Lib "usp10" ( _
ByVal hdc As LongPtr, _
ByVal psc As LongPtr, _
ByVal wGlyph As Integer, _
ByVal pABC As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ScriptGetGlyphABCWidth = ctypes.windll.usp10.ScriptGetGlyphABCWidth
ScriptGetGlyphABCWidth.restype = ctypes.c_int
ScriptGetGlyphABCWidth.argtypes = [
wintypes.HANDLE, # hdc : HDC
ctypes.c_void_p, # psc : void** in/out
ctypes.c_ushort, # wGlyph : WORD
ctypes.c_void_p, # pABC : ABC* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USP10.dll')
ScriptGetGlyphABCWidth = Fiddle::Function.new(
lib['ScriptGetGlyphABCWidth'],
[
Fiddle::TYPE_VOIDP, # hdc : HDC
Fiddle::TYPE_VOIDP, # psc : void** in/out
-Fiddle::TYPE_SHORT, # wGlyph : WORD
Fiddle::TYPE_VOIDP, # pABC : ABC* out
],
Fiddle::TYPE_INT)#[link(name = "usp10")]
extern "system" {
fn ScriptGetGlyphABCWidth(
hdc: *mut core::ffi::c_void, // HDC
psc: *mut *mut (), // void** in/out
wGlyph: u16, // WORD
pABC: *mut ABC // ABC* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USP10.dll")]
public static extern int ScriptGetGlyphABCWidth(IntPtr hdc, IntPtr psc, ushort wGlyph, IntPtr pABC);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USP10_ScriptGetGlyphABCWidth' -Namespace Win32 -PassThru
# $api::ScriptGetGlyphABCWidth(hdc, psc, wGlyph, pABC)#uselib "USP10.dll"
#func global ScriptGetGlyphABCWidth "ScriptGetGlyphABCWidth" sptr, sptr, sptr, sptr
; ScriptGetGlyphABCWidth hdc, psc, wGlyph, varptr(pABC) ; 戻り値は stat
; hdc : HDC -> "sptr"
; psc : void** in/out -> "sptr"
; wGlyph : WORD -> "sptr"
; pABC : ABC* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USP10.dll" #cfunc global ScriptGetGlyphABCWidth "ScriptGetGlyphABCWidth" sptr, sptr, int, var ; res = ScriptGetGlyphABCWidth(hdc, psc, wGlyph, pABC) ; hdc : HDC -> "sptr" ; psc : void** in/out -> "sptr" ; wGlyph : WORD -> "int" ; pABC : ABC* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USP10.dll" #cfunc global ScriptGetGlyphABCWidth "ScriptGetGlyphABCWidth" sptr, sptr, int, sptr ; res = ScriptGetGlyphABCWidth(hdc, psc, wGlyph, varptr(pABC)) ; hdc : HDC -> "sptr" ; psc : void** in/out -> "sptr" ; wGlyph : WORD -> "int" ; pABC : ABC* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT ScriptGetGlyphABCWidth(HDC hdc, void** psc, WORD wGlyph, ABC* pABC) #uselib "USP10.dll" #cfunc global ScriptGetGlyphABCWidth "ScriptGetGlyphABCWidth" intptr, intptr, int, var ; res = ScriptGetGlyphABCWidth(hdc, psc, wGlyph, pABC) ; hdc : HDC -> "intptr" ; psc : void** in/out -> "intptr" ; wGlyph : WORD -> "int" ; pABC : ABC* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT ScriptGetGlyphABCWidth(HDC hdc, void** psc, WORD wGlyph, ABC* pABC) #uselib "USP10.dll" #cfunc global ScriptGetGlyphABCWidth "ScriptGetGlyphABCWidth" intptr, intptr, int, intptr ; res = ScriptGetGlyphABCWidth(hdc, psc, wGlyph, varptr(pABC)) ; hdc : HDC -> "intptr" ; psc : void** in/out -> "intptr" ; wGlyph : WORD -> "int" ; pABC : ABC* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
usp10 = windows.NewLazySystemDLL("USP10.dll")
procScriptGetGlyphABCWidth = usp10.NewProc("ScriptGetGlyphABCWidth")
)
// hdc (HDC), psc (void** in/out), wGlyph (WORD), pABC (ABC* out)
r1, _, err := procScriptGetGlyphABCWidth.Call(
uintptr(hdc),
uintptr(psc),
uintptr(wGlyph),
uintptr(pABC),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction ScriptGetGlyphABCWidth(
hdc: THandle; // HDC
psc: Pointer; // void** in/out
wGlyph: Word; // WORD
pABC: Pointer // ABC* out
): Integer; stdcall;
external 'USP10.dll' name 'ScriptGetGlyphABCWidth';result := DllCall("USP10\ScriptGetGlyphABCWidth"
, "Ptr", hdc ; HDC
, "Ptr", psc ; void** in/out
, "UShort", wGlyph ; WORD
, "Ptr", pABC ; ABC* out
, "Int") ; return: HRESULT●ScriptGetGlyphABCWidth(hdc, psc, wGlyph, pABC) = DLL("USP10.dll", "int ScriptGetGlyphABCWidth(void*, void*, int, void*)")
# 呼び出し: ScriptGetGlyphABCWidth(hdc, psc, wGlyph, pABC)
# hdc : HDC -> "void*"
# psc : void** in/out -> "void*"
# wGlyph : WORD -> "int"
# pABC : ABC* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "usp10" fn ScriptGetGlyphABCWidth(
hdc: ?*anyopaque, // HDC
psc: ?*anyopaque, // void** in/out
wGlyph: u16, // WORD
pABC: [*c]ABC // ABC* out
) callconv(std.os.windows.WINAPI) i32;proc ScriptGetGlyphABCWidth(
hdc: pointer, # HDC
psc: pointer, # void** in/out
wGlyph: uint16, # WORD
pABC: ptr ABC # ABC* out
): int32 {.importc: "ScriptGetGlyphABCWidth", stdcall, dynlib: "USP10.dll".}pragma(lib, "usp10");
extern(Windows)
int ScriptGetGlyphABCWidth(
void* hdc, // HDC
void** psc, // void** in/out
ushort wGlyph, // WORD
ABC* pABC // ABC* out
);ccall((:ScriptGetGlyphABCWidth, "USP10.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, UInt16, Ptr{ABC}),
hdc, psc, wGlyph, pABC)
# hdc : HDC -> Ptr{Cvoid}
# psc : void** in/out -> Ptr{Cvoid}
# wGlyph : WORD -> UInt16
# pABC : ABC* out -> Ptr{ABC}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ScriptGetGlyphABCWidth(
void* hdc,
void** psc,
uint16_t wGlyph,
void* pABC);
]]
local usp10 = ffi.load("usp10")
-- usp10.ScriptGetGlyphABCWidth(hdc, psc, wGlyph, pABC)
-- hdc : HDC
-- psc : void** in/out
-- wGlyph : WORD
-- pABC : ABC* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('USP10.dll');
const ScriptGetGlyphABCWidth = lib.func('__stdcall', 'ScriptGetGlyphABCWidth', 'int32_t', ['void *', 'void *', 'uint16_t', 'void *']);
// ScriptGetGlyphABCWidth(hdc, psc, wGlyph, pABC)
// hdc : HDC -> 'void *'
// psc : void** in/out -> 'void *'
// wGlyph : WORD -> 'uint16_t'
// pABC : ABC* out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USP10.dll", {
ScriptGetGlyphABCWidth: { parameters: ["pointer", "pointer", "u16", "pointer"], result: "i32" },
});
// lib.symbols.ScriptGetGlyphABCWidth(hdc, psc, wGlyph, pABC)
// hdc : HDC -> "pointer"
// psc : void** in/out -> "pointer"
// wGlyph : WORD -> "u16"
// pABC : ABC* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ScriptGetGlyphABCWidth(
void* hdc,
void** psc,
uint16_t wGlyph,
void* pABC);
C, "USP10.dll");
// $ffi->ScriptGetGlyphABCWidth(hdc, psc, wGlyph, pABC);
// hdc : HDC
// psc : void** in/out
// wGlyph : WORD
// pABC : ABC* 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 Usp10 extends StdCallLibrary {
Usp10 INSTANCE = Native.load("usp10", Usp10.class);
int ScriptGetGlyphABCWidth(
Pointer hdc, // HDC
Pointer psc, // void** in/out
short wGlyph, // WORD
Pointer pABC // ABC* out
);
}@[Link("usp10")]
lib LibUSP10
fun ScriptGetGlyphABCWidth = ScriptGetGlyphABCWidth(
hdc : Void*, # HDC
psc : Void**, # void** in/out
wGlyph : UInt16, # WORD
pABC : ABC* # ABC* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ScriptGetGlyphABCWidthNative = Int32 Function(Pointer<Void>, Pointer<Void>, Uint16, Pointer<Void>);
typedef ScriptGetGlyphABCWidthDart = int Function(Pointer<Void>, Pointer<Void>, int, Pointer<Void>);
final ScriptGetGlyphABCWidth = DynamicLibrary.open('USP10.dll')
.lookupFunction<ScriptGetGlyphABCWidthNative, ScriptGetGlyphABCWidthDart>('ScriptGetGlyphABCWidth');
// hdc : HDC -> Pointer<Void>
// psc : void** in/out -> Pointer<Void>
// wGlyph : WORD -> Uint16
// pABC : ABC* out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ScriptGetGlyphABCWidth(
hdc: THandle; // HDC
psc: Pointer; // void** in/out
wGlyph: Word; // WORD
pABC: Pointer // ABC* out
): Integer; stdcall;
external 'USP10.dll' name 'ScriptGetGlyphABCWidth';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ScriptGetGlyphABCWidth"
c_ScriptGetGlyphABCWidth :: Ptr () -> Ptr () -> Word16 -> Ptr () -> IO Int32
-- hdc : HDC -> Ptr ()
-- psc : void** in/out -> Ptr ()
-- wGlyph : WORD -> Word16
-- pABC : ABC* out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let scriptgetglyphabcwidth =
foreign "ScriptGetGlyphABCWidth"
((ptr void) @-> (ptr void) @-> uint16_t @-> (ptr void) @-> returning int32_t)
(* hdc : HDC -> (ptr void) *)
(* psc : void** in/out -> (ptr void) *)
(* wGlyph : WORD -> uint16_t *)
(* pABC : ABC* out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library usp10 (t "USP10.dll"))
(cffi:use-foreign-library usp10)
(cffi:defcfun ("ScriptGetGlyphABCWidth" script-get-glyph-abcwidth :convention :stdcall) :int32
(hdc :pointer) ; HDC
(psc :pointer) ; void** in/out
(w-glyph :uint16) ; WORD
(p-abc :pointer)) ; ABC* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ScriptGetGlyphABCWidth = Win32::API::More->new('USP10',
'int ScriptGetGlyphABCWidth(HANDLE hdc, LPVOID psc, WORD wGlyph, LPVOID pABC)');
# my $ret = $ScriptGetGlyphABCWidth->Call($hdc, $psc, $wGlyph, $pABC);
# hdc : HDC -> HANDLE
# psc : void** in/out -> LPVOID
# wGlyph : WORD -> WORD
# pABC : ABC* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型