zoukankan      html  css  js  c++  java
  • 【SonicUI】关于字体高亮的问题。。



    	m_pSonicString[1]->Format(_T("/c=%x, a='http://hi.csdn.net/', linkh=0xFF00F0, font, font_height=25, font_bold=1, font_italic=1/点我打开链接uM"),RGB(128,0,32));
    	m_pSonicString[2]->Format(_T("/c=%x, a='http://hi.csdn.net/', linkh=0xFF00F0, font, font_height=25, font_bold=1, font_italic=0/点我打开链接uM"),RGB(128,0,32));
    

    測试代码如上:

    通过代码分析,发现了作者使用的是 API GetTextExtentPoint32

    BOOL GetTextExtentPoint32(  HDC hdc,           // handle to DC
      LPCTSTR lpString,  // text string  int c,      // characters in string
      LPSIZE lpSize      // string size);

    这个是函数是能够获取到字符串的宽度。。可是没有区分Italic类型,所以才会出现以上高亮后的问题。


    if (block.Font.bItalic)
    					{
    						UINT nChar = (UINT)block.strText.GetAt(strlen(block.strText) + -1);
    						if (nChar >= 0xA0)
    						{
    							nChar = ((UINT)block.strText.GetAt(strlen(block.strText) + -2) >> 8) + nChar;
    							nChar = nChar & 0xFFFF;
    							int nWidth;
    							GetCharWidth32(hdc,nChar ,nChar ,&nWidth);
    							nBlockWidth = sz.cx + nWidth;
    						}
    						else
    						{
    							ABC czAbc = {0};
    							GetCharABCWidths(hdc,nChar,nChar,&czAbc);						
    							nBlockWidth = sz.cx - czAbc.abcC;
    						}						
    					}
    					else
    					{
    						nBlockWidth = sz.cx;
    					}


    SonicUI_srcSonicUISonicString.cpp  477line     更改支持中英文。


    </pre><pre class="cpp" name="code">BOOL GetCharABCWidths(  HDC hdc,         // handle to DC
      UINT uFirstChar, // first character in range
      UINT uLastChar,  // last character in range
      LPABC lpabc      // array of character widths);



    通过这个函数获取当前字体下,最后一个字符的宽度。

    。能够非常好的全然显示出来!




    
  • 相关阅读:
    css 负边距 小记
    javascript Array 方法学习
    使用自定义字体 @font-face 小试
    mongodb 基本指令学习 (2)
    mongodb 基本指令学习
    ASP.NET MVC AJAX调用JsonResult方法并返回自定义错误信息
    MVC MVVM Knockout 常遇问题总结
    关于 mvc 中 连字符
    在一般处理程序中,把Form Post过来的表单集合转换成对象 ,仿 MVC post,反射原理
    EF经验分享_jimmyzzc
  • 原文地址:https://www.cnblogs.com/jzssuanfa/p/6991277.html
Copyright © 2011-2022 走看看