惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - Clingingboy

冒个泡,刷刷存在感 使用文件映射和信号量来进程间通信 Xperf Basics: Recording a Trace (the easy way)(转) Xperf Basics: Recording a Trace(转) Xperf Analysis Basics(转) Android相关sdk使用 Chrome RenderText分析(2) c++智能指针 codepage IMLangCodePages GUI 快捷键的实现思路 Menu实现逻辑 控件保持多种绘图状态的做法 2个函数宏技巧 绘图 Painter转接口封装的方式 DirectUI消息循环的简单封装 c++以代理的方式来实现接口化编程 c++对象工厂 使用模板来解决接口继承问题 VC++ 使用attributes定义接口
Uniscribe文字自动换行
Clingingboy · 2013-12-08 · via 博客园 - Clingingboy

2013-12-08 13:29  Clingingboy  阅读(775)  评论()    收藏  举报

转载:http://blog.csdn.net/jianlizhao66/article/details/1480457

我们获得了每个字形的宽度数组piAdvances,以及这个RUN所占用的总宽度abc。

piVdvances对应于每个字符,它取得了每个字形所占用宽度。

如果我们以行为单位来绘制文字,我们可以以一个循环来取得每个RUN的宽度信息,并一直相加,假设我们己取得了一些run的宽度和,假设这个宽度和为LineWidth.当我们再取得链表中下一个run的宽度(假设为lo)与这个宽度相加后超过一个行的宽度。我们假设这个run的索引为n即在链表中的节点顺序由头节点向后遍历的顺序为第n个。

我们可以中断这个run即把这个run分为两个run,所谓划分实际上也就是把这个run的字符分为两部分。

可以这样实现:

hr = ScriptGetLogicalWidths(&pRun->analysis,

                                pRun->iLen,

                                cGlyphs,

                                piAdvances,

                                pClusters,

                                pVisattrs,

                                logwidths);

ScriptGetLogicalWidhts函数转换一个指定字体的字形向前宽度为逻辑宽度。

HRESULT WINAPI ScriptGetLogicalWidths(
 const SCRIPT_ANALYSIS *psa,
 int cChars,
 int cGlyphs,
 const int *piGlyphWidth,
 const WORD *pwLogClust,
 const SCRIPT_VISATTR *psva,
 int *piDx,
);

psa

[in]一个 SCRIPT_ANALYSIS 结构指针.

cChars

[in] 在RUN中的逻辑编码点数量

cGlyphs

[in] 在一个RUN中的字形数量

piGlyphWidth

[in] 字形向前宽度的数组指针

pwLogClust

[in] 逻辑Cluster的数组指针

psva

[in] SCRIPT_VISATTR 结构指针

piDx

[out] 逻辑宽度的数组指针

可以看出这个函数的最后一个参数为输出参数,它代表逻辑宽度的数组。即每个字形所占用的宽度数组。

然后我们可以以一个循环来判断具体到哪个字符时满足不超过窗口宽度的条件。

iChars = 0;

       iWidth = 0;

       while(iChars < pRun->iLen && iWidth + logwidths[iChars] < iMaxWidth)

       {

              iWidth += logwidths[iChars];

              iChars++;

       }

pRun代表我们当前的run。iWidth代表当前run中某个字符的逻辑宽度,iMaxWidth代表窗口剩余的宽度即剩余了iMaxWidth的宽度,但这个宽度不足以显示这个run.

通过上面这个循环,我们找到了这个字符的位置。

if(iChars < pRun->iLen )

    {

        pNewRun     = new RUN;

        *pNewRun    = *pRun;

        pRun->pNext = pNewRun;

        pRun->iLen = iChars;

        pNewRun->iLen -= iChars;

    }

我们已经划分了这个RUN。

第二步已经完成,总结第二步,主要目的是确定一行(窗口宽度)要显示多少个RUN,并进行相应的划分。