使用自定义字体时报错 CTypefaceStore -14


 

  1.  aGc.Device()->GetNearestFontInTwips(font,fontSpec);
  2.  aGc.SetPenColor(KRgbBlack);
  3.  aGc.SetPenStyle(CGraphicsContext::ESolidPen);
  4.  aGc.UseFont(font);
  5.  aGc.DrawText(text,TPoint(0,font->HeightInPixels()));
  6.  aGc.DiscardFont();
  7.  aGc.Device()->ReleaseFont(font);

上面的代码里面如果没有调用最后一句ReleaseFont就会产生该错误CTypefaceStore -14
GetNearestFontInTwips和ReleaseFont必须成对出现,
使用CGraphicsDevice及其集成类的GetNearestFontInTwips 等方法创建自定义字体的时候,
使用完字体要调用一下ReleaseFont 释放 该字体。
类似函数还有GetNearestFontToDesignHeightInTwips(), GetNearestFontToMaxHeightInTwips(),

如果是CFbsDevice等,还有这些函数
GetFontById()
GetNearestFontToMaxHeightInPixels()
GetNearestFontInPixels()
GetNearestFontToDesignHeightInPixels()
GetNearestFontToMaxHeightInPixels()也需要relesefont

猜你喜欢

转载自blog.csdn.net/windcao/article/details/3051944
14
今日推荐