• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
周芳芳0824
博客园    首页    新随笔    联系   管理    订阅  订阅

DirectWrite

---恢复内容开始---

文字的呈现要求。

 

内容,格式。

ID2D1Factory -> DrawText
             -> DreaTextLayout -> SetFontSize
-> SetUnderline
IDWriteFactory
-> IDWriteTextFormat -> IDWriteTextLayout

WriteFactory 提供格式。

D2D1Factory 提供画图方法。

IDWriteFactory

hr = DWriteCreateFactory(
        DWRITE_FACTORY_TYPE_SHARED,
        __uuidof(IDWriteFactory),
        reinterpret_cast<IUnknown**>(&pDWriteFactory_)
        );

IDWriteTextFormat

virtual HRESULT CreateTextFormat(
  [in]   const WCHAR * fontFamilyName,                     //字体名
         IDWriteFontCollection * fontCollection,           //字体集合的指针,一般为NULL
         DWRITE_FONT_WEIGHT  fontWeight,                   //指示字体粗细
         DWRITE_FONT_STYLE  fontStyle,                     //指示字体样式
         DWRITE_FONT_STRETCH  fontStretch,                 //指示字体拉伸
         FLOAT  fontSize,                                  //指示字体的逻辑大小,(DPI)
  [in]   const WCHAR * localeName,                         //区域设置名称
  [out]  IDWriteTextFormat ** textFormat
) = 0;

DrawText

void DrawText(
  [in]   WCHAR *string,                                    //字符串
UINT stringLength, //字符串长度 [
in] IDWriteTextFormat *textFormat, //IDWriteTextFormat [ref] const D2D1_RECT_F &layoutRect, //呈现矩形 [in] ID2D1Brush *defaultForegroundBrush, //画刷 D2D1_DRAW_TEXT_OPTIONS options = D2D1_DRAW_TEXT_OPTIONS_NONE, //可省略 DWRITE_MEASURING_MODE measuringMode = DWRITE_MEASURING_MODE_NATURAL //可省略 );

 

IDWriteTextLayout

 

virtual HRESULT CreateTextLayout(
  [in]   const WCHAR * string,                             //字符
         UINT32  stringLength,                             //字符长度
         IDWriteTextFormat * textFormat,                   //IDWriteTextFormat
         FLOAT  maxWidth,                                  //呈现矩形大小
         FLOAT  maxHeight,                                 
  [out]  IDWriteTextLayout ** textLayout
) = 0;

 

DrawTextLayout

virtual void DrawTextLayout(
        D2D1_POINT_2F origin,                                            //开始位置
  [in]  IDWriteTextLayout *textLayout,                                   //IDWriteTextLayout
  [in]  ID2D1Brush *defaultForegroundBrush,                              //画刷
        D2D1_DRAW_TEXT_OPTIONS options = D2D1_DRAW_TEXT_OPTIONS_NONE
) = 0;

 

使用IDWriteTextLayout可以使文本其中指定的子文本,呈现不同的格式。

SetFontSize

virtual HRESULT SetFontSize(
    FLOAT  fontSize,                           //大小
    DWRITE_TEXT_RANGE  textRange               //指示子文本在原来文本中的位置。
) = 0;

DWRITE_TEXT_RANGE

struct DWRITE_TEXT_RANGE {
  UINT32 startPosition;                        //指示子文本在原文本的开始位置
  UINT32 length;                               //指示自文本的长度
};

 

 

---恢复内容结束---

posted @ 2016-02-07 21:41  周芳芳0824  阅读(496)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3