AJA NTV2 SDK  17.5.0.1242
NTV2 SDK 17.5.0.1242
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
NTV2CCFont::GetDotMapWidth
virtual UWord GetDotMapWidth(void) const
Returns the width of the dot map, in dots.
Definition: ccfont.h:162
NTV2CCFont::Utf8ToCCFontByteArray
static std::string Utf8ToCCFontByteArray(const std::string &inUtf8Str)
Converts the given UTF-8 encoded string into a string of CCFont character codes.
ntv2caption608types.h
Declares several data types used with 608/SD captioning.
NTV2CCFont::GetRightMarginDotCount
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
NTV2CCFont::GetNoUnderlineSpaceGlyphIndex
virtual NTV2GlyphIndex GetNoUnderlineSpaceGlyphIndex(void) const
Returns the "no underline space" character's zero-based glyph index number.
Definition: ccfont.h:137
NTV2CCFont
This is the font used when rendering CEA-608 captions into a frame buffer. I define a "dot" map havin...
Definition: ccfont.h:27
NTV2CCFont::UnicodeCodePointToCharacterCode
static UByte UnicodeCodePointToCharacterCode(const ULWord inCodePoint)
Returns the character code that corresponds to the given unicode codepoint.
NTV2CCFont::GetUnderlineCharacterCode
virtual UByte GetUnderlineCharacterCode(void) const
Returns the character code of the special underline glyph.
Definition: ccfont.h:143
NTV2CCFont::NTV2CCFont
NTV2CCFont()
NTV2CCFont::GetDotMapHeight
virtual UWord GetDotMapHeight(void) const
Returns the height of the dot map, in dots.
Definition: ccfont.h:192
NTV2CCFont::CharacterCodeToGlyphIndex
static NTV2GlyphIndex CharacterCodeToGlyphIndex(const UByte inCharacterCode)
Returns the zero-based glyph index number that corresponds to the given character code.
NTV2FrameBufferFormat
NTV2FrameBufferFormat
Identifies a particular video frame buffer format. See Device Frame Buffer Formats for details.
Definition: ntv2enums.h:210
NTV2CCFont::GlyphIndexToCharacterCode
static UByte GlyphIndexToCharacterCode(const NTV2GlyphIndex inGlyphIndex)
Returns the character code that corresponds to the given glyph.
NTV2CCFont::GetTotalWidthInDots
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
NTV2CCFont::RenderGlyph8BitYCbCr
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 '2vuy' desti...
nlohmann::json_abiNLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON_v3_11_NLOHMANN_JSON_VERSION_PATCH::detail::void
j template void())
Definition: json.hpp:4893
ajatypes.h
Declares the most fundamental data types used by NTV2. Since Windows NT was the first principal devel...
NTV2CCFont::~NTV2CCFont
virtual ~NTV2CCFont()
NTV2CCFont::GetTotalHeightInDots
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
ULWord
uint32_t ULWord
Definition: ajatypes.h:255
NTV2CCFont::GetDotMapRowCount
virtual UWord GetDotMapRowCount(void) const
Returns the height of the dot map, in dot rows.
Definition: ccfont.h:186
NTV2CCFont::GetCodePointsForCCFontCharCode
virtual NTV2CodePointSet GetCodePointsForCCFontCharCode(const UByte inCharCode) const
Returns the set of codepoints that map to a given CCFont character code.
NTV2CCFont::GetNoUnderlineSpaceCharacterCode
virtual UByte GetNoUnderlineSpaceCharacterCode(void) const
Returns the character code of the special "underline space" glyph.
Definition: ccfont.h:149
NTV2CCFont::GetUnderlineStartingDotRow
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
UWord
uint16_t UWord
Definition: ajatypes.h:253
ntv2enums.h
Enumerations for controlling NTV2 devices.
NTV2CCFont::HasGlyphFor608CodePoint
virtual bool HasGlyphFor608CodePoint(const NTV2_CC608_CodePoint in608CodePoint) const
Returns true if there is a glyph available for the given CEA-608 code point.
NTV2CCFont::IsValidGlyphIndex
virtual bool IsValidGlyphIndex(const NTV2GlyphIndex inGlyphIndex) const
Returns true if the given glyph index is valid.
Definition: ccfont.h:113
NTV2CCFont::RenderGlyph8BitRGB
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...
NTV2CCFont::GetTopMarginDotCount
virtual UWord GetTopMarginDotCount(void) const
Returns the number of dots of space to appear above each blitted glyph.
Definition: ccfont.h:198
DumpCCFont
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...
NTV2_CC608_CodePoint
ULWord NTV2_CC608_CodePoint
Describes a unique CEA-608 caption character code point in 32 bits: 0xSS00XXYY, where....
Definition: ntv2caption608types.h:276
NTV2GlyphIndex
uint16_t NTV2GlyphIndex
A zero-based index number that uniquely identifies a glyph.
Definition: ccfont.h:19
UByte
uint8_t UByte
Definition: ajatypes.h:250
NTV2CCFont::GetInstance
static const NTV2CCFont & GetInstance(void)
Returns a constant reference to the NTV2CCFont singleton.
NTV2CCFont::GetGlyphCount
virtual UWord GetGlyphCount(void) const
Returns the number of glyphs available in this caption font.
Definition: ccfont.h:119
NTV2CCFont::GetName
virtual std::string GetName(void) const
Returns the name of this caption font.
Definition: ccfont.h:125
NTV2CCFont::GetLeftMarginDotCount
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
NTV2Line21Attributes
CEA-608 Character Attributes.
Definition: ntv2caption608types.h:357
NTV2CCFont::GetBottomMarginDotCount
virtual UWord GetBottomMarginDotCount(void) const
Returns the number of dots of space to appear below each blitted glyph.
Definition: ccfont.h:204
NTV2CCFont::GetGlyphRowDotsAsString
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 ...
NTV2CCFont::GetUnderlineGlyphIndex
virtual NTV2GlyphIndex GetUnderlineGlyphIndex(void) const
Returns the underline character's zero-based glyph index number.
Definition: ccfont.h:131
NTV2CCFont::GetCCFontCharCode
virtual UByte GetCCFontCharCode(const NTV2_CC608_CodePoint in608CodePoint) const
Returns the "ASCII-like" character code that best represents the given CEA-608 code point.
NTV2CCFont::GetGlyphRowDots
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.
NTV2CodePointSet
std::set< NTV2_CC608_CodePoint > NTV2CodePointSet
A set of unique CEA-608 caption character code points.
Definition: ntv2caption608types.h:282
NTV2CCFont::GetGlyphFor608CodePoint
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.
NTV2CCFont::PrintGlyphs
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...