ホーム › Globalization › ScriptStringGetLogicalWidths
ScriptStringGetLogicalWidths
関数解析済み文字列の各文字の論理幅を取得する。
シグネチャ
// USP10.dll
#include <windows.h>
HRESULT ScriptStringGetLogicalWidths(
void* ssa,
INT* piDx
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ssa | void* | in | 文字列に対応する SCRIPT_STRING_ANALYSIS 構造体です。 |
| piDx | INT* | inout | この関数が論理的な幅を取得するバッファーへのポインターです。バッファーには、少なくとも ScriptString_pcOutChars の ssa パラメーターが示す数の整数を格納できる領域が必要です。 |
戻り値の型: HRESULT
公式ドキュメント
視覚的な幅を論理的な幅に変換します。
戻り値
成功した場合は S_OK を返します。失敗した場合、この関数は 0 以外の HRESULT 値を返します。アプリケーションは SUCCEEDED マクロおよび FAILED マクロを使用して戻り値を判定できます。
解説(Remarks)
この関数は、ScriptStringAnalyse によって生成された視覚的な幅を、論理的な順序で元の文字ごとに 1 つずつ、論理的な幅に変換します。
この関数を使用するには、アプリケーションは ScriptStringAnalyse の最初の呼び出しで SSA_GLYPHS を指定する必要があります。
重要 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 ScriptStringGetLogicalWidths(
void* ssa,
INT* piDx
);[DllImport("USP10.dll", ExactSpelling = true)]
static extern int ScriptStringGetLogicalWidths(
IntPtr ssa, // void*
ref int piDx // INT* in/out
);<DllImport("USP10.dll", ExactSpelling:=True)>
Public Shared Function ScriptStringGetLogicalWidths(
ssa As IntPtr, ' void*
ByRef piDx As Integer ' INT* in/out
) As Integer
End Function' ssa : void*
' piDx : INT* in/out
Declare PtrSafe Function ScriptStringGetLogicalWidths Lib "usp10" ( _
ByVal ssa As LongPtr, _
ByRef piDx As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ScriptStringGetLogicalWidths = ctypes.windll.usp10.ScriptStringGetLogicalWidths
ScriptStringGetLogicalWidths.restype = ctypes.c_int
ScriptStringGetLogicalWidths.argtypes = [
ctypes.POINTER(None), # ssa : void*
ctypes.POINTER(ctypes.c_int), # piDx : INT* in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USP10.dll')
ScriptStringGetLogicalWidths = Fiddle::Function.new(
lib['ScriptStringGetLogicalWidths'],
[
Fiddle::TYPE_VOIDP, # ssa : void*
Fiddle::TYPE_VOIDP, # piDx : INT* in/out
],
Fiddle::TYPE_INT)#[link(name = "usp10")]
extern "system" {
fn ScriptStringGetLogicalWidths(
ssa: *mut (), // void*
piDx: *mut i32 // INT* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USP10.dll")]
public static extern int ScriptStringGetLogicalWidths(IntPtr ssa, ref int piDx);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USP10_ScriptStringGetLogicalWidths' -Namespace Win32 -PassThru
# $api::ScriptStringGetLogicalWidths(ssa, piDx)#uselib "USP10.dll"
#func global ScriptStringGetLogicalWidths "ScriptStringGetLogicalWidths" sptr, sptr
; ScriptStringGetLogicalWidths ssa, varptr(piDx) ; 戻り値は stat
; ssa : void* -> "sptr"
; piDx : INT* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "USP10.dll" #cfunc global ScriptStringGetLogicalWidths "ScriptStringGetLogicalWidths" sptr, var ; res = ScriptStringGetLogicalWidths(ssa, piDx) ; ssa : void* -> "sptr" ; piDx : INT* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "USP10.dll" #cfunc global ScriptStringGetLogicalWidths "ScriptStringGetLogicalWidths" sptr, sptr ; res = ScriptStringGetLogicalWidths(ssa, varptr(piDx)) ; ssa : void* -> "sptr" ; piDx : INT* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT ScriptStringGetLogicalWidths(void* ssa, INT* piDx) #uselib "USP10.dll" #cfunc global ScriptStringGetLogicalWidths "ScriptStringGetLogicalWidths" intptr, var ; res = ScriptStringGetLogicalWidths(ssa, piDx) ; ssa : void* -> "intptr" ; piDx : INT* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT ScriptStringGetLogicalWidths(void* ssa, INT* piDx) #uselib "USP10.dll" #cfunc global ScriptStringGetLogicalWidths "ScriptStringGetLogicalWidths" intptr, intptr ; res = ScriptStringGetLogicalWidths(ssa, varptr(piDx)) ; ssa : void* -> "intptr" ; piDx : INT* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
usp10 = windows.NewLazySystemDLL("USP10.dll")
procScriptStringGetLogicalWidths = usp10.NewProc("ScriptStringGetLogicalWidths")
)
// ssa (void*), piDx (INT* in/out)
r1, _, err := procScriptStringGetLogicalWidths.Call(
uintptr(ssa),
uintptr(piDx),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction ScriptStringGetLogicalWidths(
ssa: Pointer; // void*
piDx: Pointer // INT* in/out
): Integer; stdcall;
external 'USP10.dll' name 'ScriptStringGetLogicalWidths';result := DllCall("USP10\ScriptStringGetLogicalWidths"
, "Ptr", ssa ; void*
, "Ptr", piDx ; INT* in/out
, "Int") ; return: HRESULT●ScriptStringGetLogicalWidths(ssa, piDx) = DLL("USP10.dll", "int ScriptStringGetLogicalWidths(void*, void*)")
# 呼び出し: ScriptStringGetLogicalWidths(ssa, piDx)
# ssa : void* -> "void*"
# piDx : INT* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "usp10" fn ScriptStringGetLogicalWidths(
ssa: ?*anyopaque, // void*
piDx: [*c]i32 // INT* in/out
) callconv(std.os.windows.WINAPI) i32;proc ScriptStringGetLogicalWidths(
ssa: pointer, # void*
piDx: ptr int32 # INT* in/out
): int32 {.importc: "ScriptStringGetLogicalWidths", stdcall, dynlib: "USP10.dll".}pragma(lib, "usp10");
extern(Windows)
int ScriptStringGetLogicalWidths(
void* ssa, // void*
int* piDx // INT* in/out
);ccall((:ScriptStringGetLogicalWidths, "USP10.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Int32}),
ssa, piDx)
# ssa : void* -> Ptr{Cvoid}
# piDx : INT* in/out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t ScriptStringGetLogicalWidths(
void* ssa,
int32_t* piDx);
]]
local usp10 = ffi.load("usp10")
-- usp10.ScriptStringGetLogicalWidths(ssa, piDx)
-- ssa : void*
-- piDx : INT* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('USP10.dll');
const ScriptStringGetLogicalWidths = lib.func('__stdcall', 'ScriptStringGetLogicalWidths', 'int32_t', ['void *', 'int32_t *']);
// ScriptStringGetLogicalWidths(ssa, piDx)
// ssa : void* -> 'void *'
// piDx : INT* in/out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("USP10.dll", {
ScriptStringGetLogicalWidths: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.ScriptStringGetLogicalWidths(ssa, piDx)
// ssa : void* -> "pointer"
// piDx : INT* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t ScriptStringGetLogicalWidths(
void* ssa,
int32_t* piDx);
C, "USP10.dll");
// $ffi->ScriptStringGetLogicalWidths(ssa, piDx);
// ssa : void*
// piDx : INT* 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 Usp10 extends StdCallLibrary {
Usp10 INSTANCE = Native.load("usp10", Usp10.class);
int ScriptStringGetLogicalWidths(
Pointer ssa, // void*
IntByReference piDx // INT* in/out
);
}@[Link("usp10")]
lib LibUSP10
fun ScriptStringGetLogicalWidths = ScriptStringGetLogicalWidths(
ssa : Void*, # void*
piDx : Int32* # INT* 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 ScriptStringGetLogicalWidthsNative = Int32 Function(Pointer<Void>, Pointer<Int32>);
typedef ScriptStringGetLogicalWidthsDart = int Function(Pointer<Void>, Pointer<Int32>);
final ScriptStringGetLogicalWidths = DynamicLibrary.open('USP10.dll')
.lookupFunction<ScriptStringGetLogicalWidthsNative, ScriptStringGetLogicalWidthsDart>('ScriptStringGetLogicalWidths');
// ssa : void* -> Pointer<Void>
// piDx : INT* in/out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ScriptStringGetLogicalWidths(
ssa: Pointer; // void*
piDx: Pointer // INT* in/out
): Integer; stdcall;
external 'USP10.dll' name 'ScriptStringGetLogicalWidths';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ScriptStringGetLogicalWidths"
c_ScriptStringGetLogicalWidths :: Ptr () -> Ptr Int32 -> IO Int32
-- ssa : void* -> Ptr ()
-- piDx : INT* in/out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let scriptstringgetlogicalwidths =
foreign "ScriptStringGetLogicalWidths"
((ptr void) @-> (ptr int32_t) @-> returning int32_t)
(* ssa : void* -> (ptr void) *)
(* piDx : INT* in/out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library usp10 (t "USP10.dll"))
(cffi:use-foreign-library usp10)
(cffi:defcfun ("ScriptStringGetLogicalWidths" script-string-get-logical-widths :convention :stdcall) :int32
(ssa :pointer) ; void*
(pi-dx :pointer)) ; INT* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ScriptStringGetLogicalWidths = Win32::API::More->new('USP10',
'int ScriptStringGetLogicalWidths(LPVOID ssa, LPVOID piDx)');
# my $ret = $ScriptStringGetLogicalWidths->Call($ssa, $piDx);
# ssa : void* -> LPVOID
# piDx : INT* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f ScriptStringAnalyse — 文字列を解析し描画用の状態オブジェクトを生成する。
- f ScriptString_pcOutChars — 解析済み文字列の出力文字数へのポインタを取得する。