游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2650|回复: 4

D3D 里怎么得到字符的宽度啊

[复制链接]

19

主题

73

帖子

73

积分

注册会员

Rank: 2

积分
73
发表于 2007-1-2 23:35:00 | 显示全部楼层 |阅读模式
还了DX SDK 的 UI 例子,里面有个函数

_ScriptStringXtoCP

能通过当前鼠标的位置得到所选中字符串中的哪一个字符


到这个函数再也找不到在那里实现的


其实,偶想知道,在 D3D里如何得到 绘制的字符所占的宽度(屏幕坐标)

121

主题

2029

帖子

2034

积分

金牌会员

Rank: 6Rank: 6

积分
2034
QQ
发表于 2007-1-3 15:46:00 | 显示全部楼层

Re:D3D 里怎么得到字符的宽度啊

ScriptStringXtoCP
The ScriptStringXtoCP function converts an x-coordinate to a character position.

HRESULT WINAPI ScriptStringXtoCP(
  SCRIPT_STRING_ANALYSIS  ssa,
  int iX,
  int *piCh,
  int *piTrailing
);
Parameters
ssa
[in] A SCRIPT_STRING_ANALYSIS structure for the string.
iX
[in] Specifies the x coordinate.
piCh
[out] Pointer to a variable that receives the character position corresponding to iX.
piTrailing
[out] Pointer to a variable that receives an indicator whether the position is the leading or trailing edge of the character.
Return Values
If the function is successful, it returns S_OK.

If the function fails, it returns an HRESULT.

The return value can be tested with the SUCCEEDED and FAILED macros.

Requirements
  Windows NT/2000/XP: Included in Windows 2000 and later.
  Redistributable: Requires Internet Explorer 5 or later on Windows 95/98/Me.
  Header: Declared in Usp10.h.
  Library: Use Usp10.lib.

6

主题

27

帖子

33

积分

注册会员

Rank: 2

积分
33
发表于 2007-1-4 10:37:00 | 显示全部楼层

Re:D3D 里怎么得到字符的宽度啊

RECT rect = {0, 0, 0,0};
ID3DXFont:rawTextW(NULL, "哈哈", 2, &rect, DT_CALCRECT, 0xffffffff);
return rect.Right - rect.Left;

19

主题

73

帖子

73

积分

注册会员

Rank: 2

积分
73
 楼主| 发表于 2007-1-4 13:52:00 | 显示全部楼层

Re:D3D 里怎么得到字符的宽度啊

thanks lingjingqiu 没向导是API

:)

37

主题

180

帖子

180

积分

注册会员

Rank: 2

积分
180
发表于 2007-1-4 23:15:00 | 显示全部楼层

Re:D3D 里怎么得到字符的宽度啊

@_@ 跟d3d 没关系呀

这跟向量字形有关
主要是GetCharABCWidths
关键在ABC结构
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-26 04:35

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表