AJA NTV2 SDK  18.0.0.2122
NTV2 SDK 18.0.0.2122
ccfont.h
Go to the documentation of this file.
1 
8 #ifndef CCFONT_H
9  #define CCFONT_H
10 
11  #include "ajatypes.h"
12  #include "ntv2caption608types.h"
13  #include "ntv2enums.h"
14 
15 
19  typedef uint16_t NTV2GlyphIndex;
20 
21 
27  class NTV2CCFont
28  {
29  // CLASS METHODS
30  public:
34  static const NTV2CCFont & GetInstance (void);
35 
41  static UByte GlyphIndexToCharacterCode (const NTV2GlyphIndex inGlyphIndex);
42 
48  static NTV2GlyphIndex CharacterCodeToGlyphIndex (const UByte inCharacterCode);
49 
55  static UByte UnicodeCodePointToCharacterCode (const ULWord inCodePoint);
56 
62  static std::string Utf8ToCCFontByteArray (const std::string & inUtf8Str);
63 
64 
65  // INSTANCE METHODS
66  public:
72  virtual bool HasGlyphFor608CodePoint (const NTV2_CC608_CodePoint in608CodePoint) const;
73 
80  virtual UWord * GetGlyphFor608CodePoint (const NTV2_CC608_CodePoint in608CodePoint) const;
81 
90  virtual UWord GetGlyphRowDots (const NTV2GlyphIndex inGlyphIndex, const unsigned inRow) const;
91 
98  virtual UByte GetCCFontCharCode (const NTV2_CC608_CodePoint in608CodePoint) const;
99 
106  virtual NTV2CodePointSet GetCodePointsForCCFontCharCode (const UByte inCharCode) const;
107 
113  virtual inline bool IsValidGlyphIndex (const NTV2GlyphIndex inGlyphIndex) const {return inGlyphIndex < GetGlyphCount ();}
114 
119  virtual inline UWord GetGlyphCount (void) const {return mGlyphCount;}
120 
125  virtual inline std::string GetName (void) const {return mFontName;}
126 
131  virtual inline NTV2GlyphIndex GetUnderlineGlyphIndex (void) const {return mUnderlineGlyphIndex;}
132 
137  virtual inline NTV2GlyphIndex GetNoUnderlineSpaceGlyphIndex (void) const {return mNoUnderlineSpaceGlyphIndex;}
138 
143  virtual inline UByte GetUnderlineCharacterCode (void) const {return GlyphIndexToCharacterCode (mUnderlineGlyphIndex);}
144 
149  virtual inline UByte GetNoUnderlineSpaceCharacterCode (void) const {return GlyphIndexToCharacterCode (mNoUnderlineSpaceGlyphIndex);}
150 
156  virtual inline UWord GetUnderlineStartingDotRow (void) const {return GetTopMarginDotCount () + GetDotMapHeight () + 2;}
157 
162  virtual inline UWord GetDotMapWidth (void) const {return mDotMapWidth;}
163 
168  virtual inline UWord GetLeftMarginDotCount (void) const {return mLeftMarginDotCount;}
169 
174  virtual inline UWord GetRightMarginDotCount (void) const {return mRightMarginDotCount;}
175 
180  virtual inline UWord GetTotalWidthInDots (void) const {return GetDotMapWidth () + GetLeftMarginDotCount () + GetRightMarginDotCount ();}
181 
186  virtual inline UWord GetDotMapRowCount (void) const {return GetDotMapHeight ();}
187 
192  virtual inline UWord GetDotMapHeight (void) const {return mDotMapHeight;}
193 
198  virtual inline UWord GetTopMarginDotCount (void) const {return mTopMarginDotCount;}
199 
204  virtual inline UWord GetBottomMarginDotCount (void) const {return mBottomMarginDotCount;}
205 
210  virtual inline UWord GetTotalHeightInDots (void) const {return GetDotMapHeight () + GetTopMarginDotCount () + GetBottomMarginDotCount ();}
211 
212 
223  virtual std::string GetGlyphRowDotsAsString (const NTV2GlyphIndex inGlyphIndex, const unsigned inRow) const;
224 
225 
237  virtual std::ostream & PrintGlyphs (std::ostream & inOutStream, const NTV2GlyphIndex inFirstGlyph, const NTV2GlyphIndex inLastGlyph) const;
238 
239 
249  virtual bool RenderGlyph8BitYCbCr (UByte * pDestBuffer,
250  const ULWord inBytesPerRow,
251  const NTV2GlyphIndex inGlyphIndex,
252  const NTV2Line21Attrs & inAttribs,
253  const ULWord inScaledDotWidth = 1,
254  const ULWord inScaledDotHeight = 1) const;
255 
256 
269  virtual bool RenderGlyph8BitRGB (const NTV2PixelFormat inPixelFormat,
270  UByte * pDestBuffer,
271  const ULWord inBytesPerRow,
272  const NTV2GlyphIndex inGlyphIndex,
273  const NTV2Line21Attrs & inAttribs,
274  const ULWord inScaledDotWidth,
275  const ULWord inScaledDotHeight,
276  const bool inIsHD = false) const;
277 
278  explicit NTV2CCFont ();
279  virtual ~NTV2CCFont ();
280 
281  private:
282  // Hidden assignment operator to quiet MSVC warning C4512
283  virtual inline NTV2CCFont & operator = (const NTV2CCFont & inRHS) {(void) inRHS; return *this;}
284 
285  // INSTANCE DATA
286  private:
287  const UWord mGlyphCount;
288  const NTV2GlyphIndex mUnderlineGlyphIndex;
289  const NTV2GlyphIndex mNoUnderlineSpaceGlyphIndex;
290  const UWord mDotMapWidth;
291  const UWord mLeftMarginDotCount;
292  const UWord mRightMarginDotCount;
293  const UWord mDotMapHeight;
294  const UWord mTopMarginDotCount;
295  const UWord mBottomMarginDotCount;
296  const std::string mFontName;
297 
298  }; // NTV2CCFont
299 
300 
307  void DumpCCFont (const NTV2CCFont & inCCFont = NTV2CCFont::GetInstance ());
308 
309 #endif // CCFONT_H
std::set< NTV2_CC608_CodePoint > NTV2CodePointSet
A set of unique CEA-608 caption character code points.
virtual UWord GetTotalHeightInDots(void) const
Returns the total height, in dots, a blitted glyph will consume, including any top and/or bottom marg...
Definition: ccfont.h:210
NTV2FrameBufferFormat
Identifies a particular video frame buffer pixel format. See Device Frame Buffer Formats for details...
Definition: ntv2enums.h:219
virtual UWord GetUnderlineStartingDotRow(void) const
Returns the starting row position of the underline, which is below the dot map. Also takes into accou...
Definition: ccfont.h:156
virtual NTV2GlyphIndex GetUnderlineGlyphIndex(void) const
Returns the underline character&#39;s zero-based glyph index number.
Definition: ccfont.h:131
virtual bool HasGlyphFor608CodePoint(const NTV2_CC608_CodePoint in608CodePoint) const
Returns true if there is a glyph available for the given CEA-608 code point.
virtual std::ostream & PrintGlyphs(std::ostream &inOutStream, const NTV2GlyphIndex inFirstGlyph, const NTV2GlyphIndex inLastGlyph) const
Renders all glyphs in the given range (inclusive) into the specified output stream as multiple rows o...
uint32_t ULWord
Definition: ajatypes.h:223
virtual bool RenderGlyph8BitRGB(const NTV2PixelFormat inPixelFormat, UByte *pDestBuffer, const ULWord inBytesPerRow, const NTV2GlyphIndex inGlyphIndex, const NTV2Line21Attrs &inAttribs, const ULWord inScaledDotWidth, const ULWord inScaledDotHeight, const bool inIsHD=false) const
Renders the given glyph with the given display attributes into the specified 8-bit NTV2_FBF_ARGB dest...
virtual UWord GetGlyphRowDots(const NTV2GlyphIndex inGlyphIndex, const unsigned inRow) const
Returns the 16-bit "dot" bitmap of the row of the character glyph having the given offset...
This is the font used when rendering CEA-608 captions into a frame buffer. I define a "dot" map havin...
Definition: ccfont.h:27
virtual bool IsValidGlyphIndex(const NTV2GlyphIndex inGlyphIndex) const
Returns true if the given glyph index is valid.
Definition: ccfont.h:113
virtual NTV2GlyphIndex GetNoUnderlineSpaceGlyphIndex(void) const
Returns the "no underline space" character&#39;s zero-based glyph index number.
Definition: ccfont.h:137
virtual UWord GetDotMapWidth(void) const
Returns the width of the dot map, in dots.
Definition: ccfont.h:162
static std::string Utf8ToCCFontByteArray(const std::string &inUtf8Str)
Converts the given UTF-8 encoded string into a string of CCFont character codes.
Enumerations for controlling NTV2 devices.
CEA-608 Character Attributes.
virtual UWord GetRightMarginDotCount(void) const
Returns the number of dots of space to appear to the right of each blitted glyph. ...
Definition: ccfont.h:174
Declares the most fundamental data types used by NTV2. Since Windows NT was the first principal devel...
virtual UWord GetGlyphCount(void) const
Returns the number of glyphs available in this caption font.
Definition: ccfont.h:119
static const NTV2CCFont & GetInstance(void)
Returns a constant reference to the NTV2CCFont singleton.
virtual std::string GetName(void) const
Returns the name of this caption font.
Definition: ccfont.h:125
static NTV2GlyphIndex CharacterCodeToGlyphIndex(const UByte inCharacterCode)
Returns the zero-based glyph index number that corresponds to the given character code...
static UByte UnicodeCodePointToCharacterCode(const ULWord inCodePoint)
Returns the character code that corresponds to the given unicode codepoint.
virtual UWord GetBottomMarginDotCount(void) const
Returns the number of dots of space to appear below each blitted glyph.
Definition: ccfont.h:204
ULWord NTV2_CC608_CodePoint
Describes a unique CEA-608 caption character code point in 32 bits: 0xSS00XXYY, where... SS == NTV2Line21CharacterSet XX == CEA608 byte 1 (parity stripped) YY == CEA608 byte 2 (parity stripped)
virtual bool RenderGlyph8BitYCbCr(UByte *pDestBuffer, const ULWord inBytesPerRow, const NTV2GlyphIndex inGlyphIndex, const NTV2Line21Attrs &inAttribs, const ULWord inScaledDotWidth=1, const ULWord inScaledDotHeight=1) const
Renders the given glyph with the given display attributes into the specified 8-bit YCbCr &#39;2vuy&#39; desti...
uint8_t UByte
Definition: ajatypes.h:218
uint16_t NTV2GlyphIndex
A zero-based index number that uniquely identifies a glyph.
Definition: ccfont.h:19
virtual UWord GetLeftMarginDotCount(void) const
Returns the number of dots of space to appear to the left of each blitted glyph.
Definition: ccfont.h:168
virtual std::string GetGlyphRowDotsAsString(const NTV2GlyphIndex inGlyphIndex, const unsigned inRow) const
Returns a UTF-8 encoded string that contains the dot pattern for the given zero-based row number and ...
virtual ~NTV2CCFont()
virtual UByte GetCCFontCharCode(const NTV2_CC608_CodePoint in608CodePoint) const
Returns the "ASCII-like" character code that best represents the given CEA-608 code point...
virtual NTV2CodePointSet GetCodePointsForCCFontCharCode(const UByte inCharCode) const
Returns the set of codepoints that map to a given CCFont character code.
virtual UWord * GetGlyphFor608CodePoint(const NTV2_CC608_CodePoint in608CodePoint) const
Returns a pointer to the "dot" bitmap of the glyph that represents the given CEA-608 code point...
uint16_t UWord
Definition: ajatypes.h:221
void DumpCCFont(const NTV2CCFont &inCCFont=NTV2CCFont::GetInstance())
Dumps all glyphs in the given CC font to stderr in UTF-8. When displayed in a terminal using a monosp...
virtual UWord GetDotMapRowCount(void) const
Returns the height of the dot map, in dot rows.
Definition: ccfont.h:186
virtual UByte GetNoUnderlineSpaceCharacterCode(void) const
Returns the character code of the special "underline space" glyph.
Definition: ccfont.h:149
virtual UByte GetUnderlineCharacterCode(void) const
Returns the character code of the special underline glyph.
Definition: ccfont.h:143
virtual UWord GetDotMapHeight(void) const
Returns the height of the dot map, in dots.
Definition: ccfont.h:192
virtual UWord GetTopMarginDotCount(void) const
Returns the number of dots of space to appear above each blitted glyph.
Definition: ccfont.h:198
static UByte GlyphIndexToCharacterCode(const NTV2GlyphIndex inGlyphIndex)
Returns the character code that corresponds to the given glyph.
virtual UWord GetTotalWidthInDots(void) const
Returns the total width, in dots, a blitted glyph will consume, including any left and/or right margi...
Definition: ccfont.h:180
Declares several data types used with 608/SD captioning.