LibreOffice Module vcl (master) 1
Functions
Sun Font Tools Exported Functions

Functions

int vcl::CountTTCFonts (const char *fname)
 Get the number of fonts contained in a TrueType collection. More...
 
SFErrCodes vcl::OpenTTFontBuffer (const void *pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont **ttf, const FontCharMapRef xCharMap=nullptr)
 TrueTypeFont constructor. More...
 
SFErrCodes vcl::OpenTTFontFile (const char *fname, sal_uInt32 facenum, TrueTypeFont **ttf, const FontCharMapRef xCharMap=nullptr)
 TrueTypeFont constructor. More...
 
void vcl::CloseTTFont (TrueTypeFont *)
 TrueTypeFont destructor. More...
 
int vcl::GetTTGlyphPoints (AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, std::vector< ControlPoint > &pointArray)
 Extracts TrueType control points, and stores them in an allocated array pointed to by *pointArray. More...
 
std::unique_ptr< GlyphDatavcl::GetTTRawGlyphData (AbstractTrueTypeFont *ttf, sal_uInt32 glyphID)
 Extracts raw glyph data from the 'glyf' table and returns it in an allocated GlyphData structure. More...
 
int vcl::GetTTGlyphComponents (AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, std::vector< sal_uInt32 > &glyphlist)
 For a specified glyph adds all component glyphs IDs to the list and return their number. More...
 
void vcl::GetTTNameRecords (AbstractTrueTypeFont const *ttf, std::vector< NameRecord > &nr)
 Extracts all Name Records from the font and stores them in an allocated array of NameRecord structs. More...
 
SFErrCodes vcl::CreateT3FromTTGlyphs (TrueTypeFont *ttf, SvStream *outf, const char *fname, sal_uInt16 const *glyphArray, sal_uInt8 *encoding, int nGlyphs, int wmode)
 Generates a new PostScript Type 3 font and dumps it to outf file. More...
 
SFErrCodes vcl::CreateTTFromTTGlyphs (AbstractTrueTypeFont *ttf, std::vector< sal_uInt8 > &rOutBuffer, sal_uInt16 const *glyphArray, sal_uInt8 const *encoding, int nGlyphs)
 Generates a new TrueType font and dumps it to outf file. More...
 
SFErrCodes vcl::CreateT42FromTTGlyphs (TrueTypeFont *ttf, SvStream *outf, const char *psname, sal_uInt16 const *glyphArray, sal_uInt8 *encoding, int nGlyphs)
 Generates a new PostScript Type42 font and dumps it to outf file. More...
 
void vcl::GetTTGlobalFontInfo (AbstractTrueTypeFont *ttf, TTGlobalFontInfo *info)
 Returns global font information about the TrueType font. More...
 
bool vcl::GetTTGlobalFontHeadInfo (const AbstractTrueTypeFont *ttf, int &xMin, int &yMin, int &xMax, int &yMax, sal_uInt16 &macStyle)
 Returns part of the head table info, normally collected by GetTTGlobalFontInfo. More...
 

Detailed Description

Function Documentation

◆ CloseTTFont()

void VCL_DLLPUBLIC vcl::CloseTTFont ( TrueTypeFont )

TrueTypeFont destructor.

Deallocates the memory.

Definition at line 1258 of file sft.cxx.

Referenced by EmbeddedFontsHelper::sufficientTTFRights(), and TestFontSubset().

◆ CountTTCFonts()

int vcl::CountTTCFonts ( const char *  fname)

Get the number of fonts contained in a TrueType collection.

Parameters
fname- file name
Returns
number of fonts or zero, if file is not a TTC file.

Definition at line 1074 of file sft.cxx.

References FILE, vcl::GetUInt32(), n, SAL_WARN, and vcl::T_ttcf.

◆ CreateT3FromTTGlyphs()

SFErrCodes vcl::CreateT3FromTTGlyphs ( TrueTypeFont ttf,
SvStream outf,
const char *  fname,
sal_uInt16 const *  glyphArray,
sal_uInt8 encoding,
int  nGlyphs,
int  wmode 
)

Generates a new PostScript Type 3 font and dumps it to outf file.

This function substitutes glyph 0 for all glyphIDs that are not found in the font.

Parameters
ttfpointer to the TrueTypeFont structure
outfthe resulting font is written to this stream
fnamefont name for the new font. If it is NULL the PostScript name of the original font will be used
glyphArraypointer to an array of glyphs that are to be extracted from ttf
encodingarray of encoding values. encoding[i] specifies the position of the glyph glyphArray[i] in the encoding vector of the resulting Type3 font
nGlyphsnumber of glyph IDs in glyphArray and encoding values in encoding
wmodewriting mode for the output file: 0 - horizontal, 1 - vertical
Returns
return the value of SFErrCodes enum
See also
SFErrCodes

Definition at line 1564 of file sft.cxx.

References vcl::BadArg, vcl::BSplineToPSPath(), vcl::TrueTypeFont::fsize, vcl::GetInt16(), vcl::GetTTGlyphOutline(), vcl::GetUInt16(), vcl::AbstractTrueTypeFont::glyphCount(), vcl::GlyphNum, i, vcl::modextra, vcl::modname, vcl::modver, n, vcl::O_head, vcl::Ok, vcl::AbstractTrueTypeFont::psname, vcl::TrueTypeFont::ptr, table, vcl::TrueTypeFont::table(), type, vcl::AbstractTrueTypeFont::unitsPerEm(), SvStream::WriteOString(), and vcl::XUnits().

Referenced by FontSubsetInfo::CreateFontSubsetFromSfnt().

◆ CreateT42FromTTGlyphs()

SFErrCodes vcl::CreateT42FromTTGlyphs ( TrueTypeFont ttf,
SvStream outf,
const char *  psname,
sal_uInt16 const *  glyphArray,
sal_uInt8 encoding,
int  nGlyphs 
)

Generates a new PostScript Type42 font and dumps it to outf file.

This function substitutes glyph 0 for all glyphIDs that are not found in the font.

Parameters
ttfpointer to the TrueTypeFont structure
outfoutput stream for a resulting font
psnamePostScript name of the resulting font
glyphArraypointer to an array of glyphs that are to be extracted from ttf. The first element of this array has to be glyph 0 (default glyph)
encodingarray of encoding values. encoding[i] specifies character code for the glyphID glyphArray[i]. Character code 0 usually points to a default glyph (glyphID 0)
nGlyphsnumber of glyph IDs in glyphArray and encoding values in encoding
Returns
SFErrCodes::Ok - no errors SFErrCodes::GlyphNum - too many glyphs (> 255) SFErrCodes::TtFormat - corrupted TrueType fonts
See also
SFErrCodes

hhea

maxp

cvt

prep

fpgm

glyf

Definition at line 2131 of file sft.cxx.

References vcl::TrueTypeCreator::AddTable(), vcl::DumpSfnts(), vcl::AbstractTrueTypeFont::family, vcl::AbstractTrueTypeFont::fileName(), vcl::TrueTypeFont::fsize, vcl::GetInt16(), vcl::GetInt32(), vcl::GetTTRawGlyphData(), vcl::GetUInt16(), vcl::GlyphNum, vcl::HEAD_created_offset, vcl::HEAD_flags_offset, vcl::HEAD_fontDirectionHint_offset, vcl::HEAD_fontRevision_offset, vcl::HEAD_lowestRecPPEM_offset, vcl::HEAD_macStyle_offset, vcl::HEAD_majorVersion_offset, vcl::HEAD_unitsPerEm_offset, vcl::HEAD_xMax_offset, vcl::HEAD_xMin_offset, vcl::HEAD_yMax_offset, vcl::HEAD_yMin_offset, vcl::HHEA_ascender_offset, vcl::HHEA_caretSlopeRise_offset, vcl::HHEA_caretSlopeRun_offset, vcl::HHEA_descender_offset, vcl::HHEA_lineGap_offset, i, vcl::modextra, vcl::modname, vcl::modver, vcl::O_cvt, vcl::O_fpgm, vcl::O_head, vcl::O_hhea, vcl::O_maxp, vcl::O_prep, vcl::Ok, p, vcl::AbstractTrueTypeFont::psname, vcl::TrueTypeFont::ptr, vcl::TrueTypeCreator::StreamToMemory(), vcl::AbstractTrueTypeFont::subfamily, vcl::T_cvt, vcl::T_fpgm, vcl::T_prep, vcl::T_true, vcl::TrueTypeFont::table(), vcl::AbstractTrueTypeFont::unitsPerEm(), SvStream::WriteOString(), and vcl::XUnits().

Referenced by FontSubsetInfo::CreateFontSubsetFromSfnt().

◆ CreateTTFromTTGlyphs()

VCL_DLLPUBLIC SFErrCodes vcl::CreateTTFromTTGlyphs ( AbstractTrueTypeFont ttf,
std::vector< sal_uInt8 > &  rOutBuffer,
sal_uInt16 const *  glyphArray,
sal_uInt8 const *  encoding,
int  nGlyphs 
)

Generates a new TrueType font and dumps it to outf file.

This function substitutes glyph 0 for all glyphIDs that are not found in the font.

Parameters
ttfpointer to the TrueTypeFont structure
fnamefile name for the output TrueType font file
glyphArraypointer to an array of glyphs that are to be extracted from ttf. The first element of this array has to be glyph 0 (default glyph)
encodingarray of encoding values. encoding[i] specifies character code for the glyphID glyphArray[i]. Character code 0 usually points to a default glyph (glyphID 0)
nGlyphsnumber of glyph IDs in glyphArray and encoding values in encoding
flagsor'ed TTCreationFlags
Returns
return the value of SFErrCodes enum
See also
SFErrCodes

name

maxp

hhea

head

glyf

cmap

cvt

prep

fpgm

post

Definition at line 1746 of file sft.cxx.

References vcl::TrueTypeCreator::AddTable(), vcl::GetInt16(), vcl::GetInt32(), vcl::GetTTNameRecords(), vcl::GetTTRawGlyphData(), vcl::GetUInt16(), vcl::GetUInt32(), vcl::HEAD_created_offset, vcl::HEAD_flags_offset, vcl::HEAD_fontDirectionHint_offset, vcl::HEAD_fontRevision_offset, vcl::HEAD_lowestRecPPEM_offset, vcl::HEAD_macStyle_offset, vcl::HEAD_unitsPerEm_offset, vcl::HHEA_ascender_offset, vcl::HHEA_caretSlopeRise_offset, vcl::HHEA_caretSlopeRun_offset, vcl::HHEA_descender_offset, vcl::HHEA_lineGap_offset, i, name, vcl::O_cvt, vcl::O_fpgm, vcl::O_head, vcl::O_hhea, vcl::O_maxp, vcl::O_post, vcl::O_prep, vcl::Ok, p, vcl::POST_isFixedPitch_offset, vcl::POST_italicAngle_offset, vcl::POST_underlinePosition_offset, vcl::POST_underlineThickness_offset, SAL_WARN_IF, vcl::TrueTypeCreator::StreamToMemory(), vcl::T_cvt, vcl::T_fpgm, vcl::T_prep, vcl::T_true, and vcl::AbstractTrueTypeFont::table().

Referenced by vcl::CreateTTFfontSubset(), and TestFontSubset().

◆ GetTTGlobalFontHeadInfo()

VCL_DLLPUBLIC bool vcl::GetTTGlobalFontHeadInfo ( const AbstractTrueTypeFont ttf,
int xMin,
int yMin,
int xMax,
int yMax,
sal_uInt16 &  macStyle 
)

Returns part of the head table info, normally collected by GetTTGlobalFontInfo.

Just implemented separate, because this info not available via Qt API.

Parameters
ttfpointer to a AbstractTrueTypeFont structure
xMinglobal glyph bounding box min X
yMinglobal glyph bounding box min Y
xMaxglobal glyph bounding box max X
yMaxglobal glyph bounding box max Y
macStyleencoded Mac style flags of the font
Returns
true, if table data could be decoded

Definition at line 2263 of file sft.cxx.

References vcl::GetInt16(), vcl::GetUInt16(), vcl::HEAD_macStyle_offset, vcl::HEAD_xMax_offset, vcl::HEAD_xMin_offset, vcl::HEAD_yMax_offset, vcl::HEAD_yMin_offset, vcl::O_head, table, vcl::AbstractTrueTypeFont::table(), vcl::AbstractTrueTypeFont::unitsPerEm(), and vcl::XUnits().

Referenced by vcl::GetTTGlobalFontInfo().

◆ GetTTGlobalFontInfo()

VCL_DLLPUBLIC void vcl::GetTTGlobalFontInfo ( AbstractTrueTypeFont ttf,
TTGlobalFontInfo info 
)

Returns global font information about the TrueType font.

See also
TTGlobalFontInfo
Parameters
ttfpointer to a TrueTypeFont structure
infopointer to a TTGlobalFontInfo structure

Definition at line 2281 of file sft.cxx.

References vcl::TTGlobalFontInfo_::ascender, vcl::TTGlobalFontInfo_::descender, vcl::TTGlobalFontInfo_::family, vcl::AbstractTrueTypeFont::family, vcl::GetInt16(), vcl::GetInt32(), vcl::GetTTGlobalFontHeadInfo(), vcl::GetUInt16(), vcl::GetUInt32(), vcl::HHEA_ascender_offset, vcl::HHEA_descender_offset, vcl::HHEA_lineGap_offset, vcl::AbstractTrueTypeFont::IsMicrosoftSymbolEncoded(), vcl::TTGlobalFontInfo_::italicAngle, vcl::TTGlobalFontInfo_::linegap, vcl::TTGlobalFontInfo_::macStyle, vcl::TTGlobalFontInfo_::microsoftSymbolEncoded, vcl::O_hhea, vcl::O_OS2, vcl::O_post, vcl::OS2_fsType_offset, vcl::OS2_panose_offset, vcl::OS2_panoseNbBytes_offset, vcl::OS2_typoAscender_offset, vcl::OS2_typoDescender_offset, vcl::OS2_typoLineGap_offset, vcl::OS2_usWeightClass_offset, vcl::OS2_usWidthClass_offset, vcl::OS2_V0_length, vcl::OS2_winAscent_offset, vcl::OS2_winDescent_offset, vcl::TTGlobalFontInfo_::panose, vcl::TTGlobalFontInfo_::pitch, vcl::POST_isFixedPitch_offset, vcl::POST_italicAngle_offset, vcl::TTGlobalFontInfo_::psname, vcl::AbstractTrueTypeFont::psname, vcl::TTGlobalFontInfo_::subfamily, vcl::AbstractTrueTypeFont::subfamily, table, vcl::AbstractTrueTypeFont::table(), vcl::TTGlobalFontInfo_::typeFlags, vcl::TTGlobalFontInfo_::typoAscender, vcl::TTGlobalFontInfo_::typoDescender, vcl::TTGlobalFontInfo_::typoLineGap, vcl::TTGlobalFontInfo_::ufamily, vcl::AbstractTrueTypeFont::ufamily, vcl::AbstractTrueTypeFont::unitsPerEm(), vcl::TTGlobalFontInfo_::usubfamily, vcl::AbstractTrueTypeFont::usubfamily, vcl::TTGlobalFontInfo_::weight, vcl::TTGlobalFontInfo_::width, vcl::TTGlobalFontInfo_::winAscent, vcl::TTGlobalFontInfo_::winDescent, vcl::TTGlobalFontInfo_::xMax, vcl::TTGlobalFontInfo_::xMin, vcl::XUnits(), vcl::TTGlobalFontInfo_::yMax, and vcl::TTGlobalFontInfo_::yMin.

Referenced by EmbeddedFontsHelper::sufficientTTFRights(), and TestFontSubset().

◆ GetTTGlyphComponents()

int vcl::GetTTGlyphComponents ( AbstractTrueTypeFont ttf,
sal_uInt32  glyphID,
std::vector< sal_uInt32 > &  glyphlist 
)

For a specified glyph adds all component glyphs IDs to the list and return their number.

If the glyph is a single glyph it has one component glyph (which is added to the list) and the function returns 1. For a composite glyphs it returns the number of component glyphs and adds all of them to the list.

Parameters
ttfpointer to the TrueTypeFont structure
glyphIDGlyph ID
glyphlistlist of glyphs
Returns
number of component glyphs

Definition at line 1487 of file sft.cxx.

References vcl::ARG_1_AND_2_ARE_WORDS, vcl::GetInt16(), vcl::GetTTGlyphComponents(), vcl::GetUInt16(), vcl::AbstractTrueTypeFont::glyphCount(), vcl::AbstractTrueTypeFont::glyphOffset(), index, vcl::MORE_COMPONENTS, n, vcl::O_glyf, SAL_WARN, vcl::AbstractTrueTypeFont::table(), vcl::WE_HAVE_A_SCALE, vcl::WE_HAVE_A_TWO_BY_TWO, and vcl::WE_HAVE_AN_X_AND_Y_SCALE.

Referenced by vcl::GetTTGlyphComponents(), and vcl::TrueTypeTableGlyf::glyfAdd().

◆ GetTTGlyphPoints()

int vcl::GetTTGlyphPoints ( AbstractTrueTypeFont ttf,
sal_uInt32  glyphID,
std::vector< ControlPoint > &  pointArray 
)

Extracts TrueType control points, and stores them in an allocated array pointed to by *pointArray.

This function returns the number of extracted points.

Parameters
ttfpointer to the TrueTypeFont structure
glyphIDGlyph ID
pointArrayReturn value - address of the pointer to the first element of the array of points allocated by the function
Returns
Returns the number of points in *pointArray or -1 if glyphID is invalid.

Definition at line 1482 of file sft.cxx.

References vcl::GetTTGlyphOutline().

Referenced by vcl::GetTTRawGlyphData().

◆ GetTTNameRecords()

void vcl::GetTTNameRecords ( AbstractTrueTypeFont const *  ttf,
std::vector< NameRecord > &  nr 
)

Extracts all Name Records from the font and stores them in an allocated array of NameRecord structs.

Parameters
ttfpointer to the TrueTypeFont struct
nrreference to the vector of NameRecord structs

Definition at line 2422 of file sft.cxx.

References vcl::AbstractTrueTypeFont::fileName(), vcl::GetUInt16(), i, n, vcl::O_name, SAL_WARN, table, and vcl::AbstractTrueTypeFont::table().

Referenced by vcl::CreateTTFromTTGlyphs().

◆ GetTTRawGlyphData()

std::unique_ptr< GlyphData > vcl::GetTTRawGlyphData ( AbstractTrueTypeFont ttf,
sal_uInt32  glyphID 
)

Extracts raw glyph data from the 'glyf' table and returns it in an allocated GlyphData structure.

Parameters
ttfpointer to the TrueTypeFont structure
glyphIDGlyph ID
Returns
pointer to an allocated GlyphData structure or NULL if glyphID is not present in the font

Definition at line 2332 of file sft.cxx.

References d, vcl::GetInt16(), vcl::GetTTGlyphPoints(), vcl::GetUInt16(), vcl::AbstractTrueTypeFont::glyphCount(), vcl::AbstractTrueTypeFont::glyphOffset(), vcl::AbstractTrueTypeFont::horzMetricCount(), i, length, m, n, vcl::O_glyf, vcl::O_hmtx, SAL_WARN, and vcl::AbstractTrueTypeFont::table().

Referenced by vcl::CreateT42FromTTGlyphs(), vcl::CreateTTFromTTGlyphs(), and vcl::TrueTypeTableGlyf::glyfAdd().

◆ OpenTTFontBuffer()

SFErrCodes VCL_DLLPUBLIC vcl::OpenTTFontBuffer ( const void *  pBuffer,
sal_uInt32  nLen,
sal_uInt32  facenum,
TrueTypeFont **  ttf,
const FontCharMapRef  xCharMap = nullptr 
)

TrueTypeFont constructor.

The font file has to be provided as a memory buffer and length

Parameters
pBuffer- memory buffer
nLen- size of memory buffer
facenum- logical font number within a TTC file. This value is ignored for TrueType fonts
ttf- returns the opened TrueTypeFont
xCharMap- optional parsed character map
Returns
value of SFErrCodes enum

Definition at line 1194 of file sft.cxx.

References vcl::Memory, and vcl::Ok.

Referenced by EmbeddedFontsHelper::sufficientTTFRights(), and TestFontSubset().

◆ OpenTTFontFile()

SFErrCodes VCL_DLLPUBLIC vcl::OpenTTFontFile ( const char *  fname,
sal_uInt32  facenum,
TrueTypeFont **  ttf,
const FontCharMapRef  xCharMap = nullptr 
)

TrueTypeFont constructor.

Reads the font file and allocates the memory for the structure. on WIN32 the font has to be provided as a memory buffer and length

Parameters
fname- name of TrueType font file
facenum- logical font number within a TTC file. This value is ignored for TrueType fonts
ttf- returns the opened TrueTypeFont
xCharMap- optional parsed character map
Returns
value of SFErrCodes enum

Definition at line 1126 of file sft.cxx.

References vcl::BadFile, cleanup(), close, vcl::FileIo, vcl::Memory, n, and vcl::Ok.