Error CTypefaceStore -14 when using custom font

 


 

  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);

In the above code, if the last sentence of ReleaseFont is not called, the error will be generated. CTypefaceStore -14
GetNearestFontInTwips and ReleaseFont must appear in pairs.
When creating a custom font using CGraphicsDevice and its integrated class GetNearestFontInTwips and other methods,
you must call ReleaseFont after using the font Release the font.
Similar functions include GetNearestFontToDesignHeightInTwips(), GetNearestFontToMaxHeightInTwips(),

If it is CFbsDevice etc., there are also these functions
GetFontById()
GetNearestFontToMaxHeightInPixels()
GetNearestFontInPixels()
GetNearestFontToDesignHeightInPixels()
GetNearestFontToMaxHeightInPixels() also requires a relative font

 

 

Guess you like

Origin blog.csdn.net/windcao/article/details/3051944