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, ControlPoint **pointArray)
 Extracts TrueType control points, and stores them in an allocated array pointed to by *pointArray. More...
 
GlyphData * vcl::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...
 
int vcl::GetTTNameRecords (AbstractTrueTypeFont const *ttf, NameRecord **nr)
 Extracts all Name Records from the font and stores them in an allocated array of NameRecord structs. More...
 
void vcl::DisposeNameRecords (NameRecord *nr, int n)
 Deallocates previously allocated array of NameRecords. More...
 
SFErrCodes vcl::CreateT3FromTTGlyphs (TrueTypeFont *ttf, FILE *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, const char *fname, 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, FILE *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...
 
std::unique_ptr< sal_uInt16[]> vcl::GetTTSimpleGlyphMetrics (AbstractTrueTypeFont const *ttf, const sal_uInt16 *glyphArray, int nGlyphs, bool vertical)
 Queries glyph metrics. More...
 
void vcl::GetTTGlobalFontInfo (TrueTypeFont *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...
 
void vcl::GetTTFontMetrics (const uint8_t *pHhea, size_t nHhea, const uint8_t *pOs2, size_t nOs2, TTGlobalFontInfo *info)
 Returns fonts metrics. More...
 

Detailed Description

Function Documentation

void VCL_DLLPUBLIC vcl::CloseTTFont ( TrueTypeFont )

TrueTypeFont destructor.

Deallocates the memory.

Definition at line 1155 of file sft.cxx.

Referenced by EmbeddedFontsHelper::sufficientTTFRights().

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 1006 of file sft.cxx.

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

SFErrCodes vcl::CreateT3FromTTGlyphs ( TrueTypeFont ttf,
FILE *  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 1424 of file sft.cxx.

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

Referenced by FontSubsetInfo::CreateFontSubsetFromSfnt().

SFErrCodes vcl::CreateT42FromTTGlyphs ( TrueTypeFont ttf,
FILE *  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 1840 of file sft.cxx.

References vcl::AddTable(), assert(), vcl::DumpSfnts(), vcl::TrueTypeFont::family, vcl::AbstractTrueTypeFont::fileName(), vcl::TrueTypeFont::fsize, vcl::GetInt16(), vcl::GetInt32(), vcl::GetTTRawGlyphData(), vcl::GetUInt16(), vcl::glyfAdd(), vcl::glyfCount(), 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::O_cvt, vcl::O_fpgm, vcl::O_head, vcl::O_hhea, vcl::O_maxp, vcl::O_prep, vcl::Ok, p, vcl::TrueTypeFont::psname, vcl::TrueTypeFont::ptr, vcl::scalloc(), vcl::StreamToMemory(), vcl::TrueTypeFont::subfamily, vcl::T_cvt, vcl::T_fpgm, vcl::T_prep, vcl::T_true, vcl::TrueTypeFont::table(), TrueTypeCreatorDispose(), vcl::TrueTypeCreatorNewEmpty(), vcl::TrueTypeTableNew(), vcl::TrueTypeTableNew_glyf(), vcl::TrueTypeTableNew_head(), vcl::TrueTypeTableNew_hhea(), vcl::TrueTypeTableNew_maxp(), vcl::AbstractTrueTypeFont::unitsPerEm(), and vcl::XUnits().

Referenced by FontSubsetInfo::CreateFontSubsetFromSfnt().

VCL_DLLPUBLIC SFErrCodes vcl::CreateTTFromTTGlyphs ( AbstractTrueTypeFont ttf,
const char *  fname,
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 1577 of file sft.cxx.

References vcl::AddTable(), assert(), vcl::cmapAdd(), vcl::DisposeNameRecords(), vcl::GetInt16(), vcl::GetInt32(), vcl::GetTTNameRecords(), vcl::GetTTRawGlyphData(), vcl::GetUInt16(), vcl::GetUInt32(), vcl::glyfAdd(), 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, n, 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::scalloc(), vcl::StreamToFile(), vcl::T_cvt, vcl::T_fpgm, vcl::T_prep, vcl::T_true, vcl::AbstractTrueTypeFont::table(), TrueTypeCreatorDispose(), vcl::TrueTypeCreatorNewEmpty(), vcl::TrueTypeTableNew(), vcl::TrueTypeTableNew_cmap(), vcl::TrueTypeTableNew_glyf(), vcl::TrueTypeTableNew_head(), vcl::TrueTypeTableNew_hhea(), vcl::TrueTypeTableNew_maxp(), vcl::TrueTypeTableNew_name(), and vcl::TrueTypeTableNew_post().

Referenced by SalGraphics::CreateTTFfontSubset().

void vcl::DisposeNameRecords ( NameRecord nr,
int  n 
)

Deallocates previously allocated array of NameRecords.

Parameters
nrarray of NameRecord structs
nnumber of elements in the array

Definition at line 2238 of file sft.cxx.

References i.

Referenced by vcl::CreateTTFromTTGlyphs().

void vcl::GetTTFontMetrics ( const uint8_t *  pHhea,
size_t  nHhea,
const uint8_t *  pOs2,
size_t  nOs2,
TTGlobalFontInfo info 
)
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 2020 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().

VCL_DLLPUBLIC void vcl::GetTTGlobalFontInfo ( TrueTypeFont 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 2038 of file sft.cxx.

References vcl::TTGlobalFontInfo_::ascender, vcl::TTGlobalFontInfo_::descender, vcl::TTGlobalFontInfo_::family, vcl::TrueTypeFont::family, vcl::AbstractTrueTypeFont::GetCharMap(), vcl::GetInt16(), vcl::GetInt32(), vcl::GetTTGlobalFontHeadInfo(), vcl::GetUInt16(), vcl::GetUInt32(), vcl::HHEA_ascender_offset, vcl::HHEA_descender_offset, vcl::HHEA_lineGap_offset, FontCharMap::isSymbolic(), vcl::TTGlobalFontInfo_::italicAngle, vcl::TTGlobalFontInfo_::linegap, vcl::TTGlobalFontInfo_::macStyle, 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::TrueTypeFont::psname, vcl::TTGlobalFontInfo_::subfamily, vcl::TrueTypeFont::subfamily, vcl::TTGlobalFontInfo_::symbolEncoded, table, vcl::TrueTypeFont::table(), vcl::TTGlobalFontInfo_::typeFlags, vcl::TTGlobalFontInfo_::typoAscender, vcl::TTGlobalFontInfo_::typoDescender, vcl::TTGlobalFontInfo_::typoLineGap, vcl::TTGlobalFontInfo_::ufamily, vcl::TrueTypeFont::ufamily, vcl::AbstractTrueTypeFont::unitsPerEm(), vcl::TTGlobalFontInfo_::usubfamily, vcl::TrueTypeFont::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().

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 1379 of file sft.cxx.

References vcl::ARG_1_AND_2_ARE_WORDS, vcl::GetInt16(), vcl::GetUInt16(), vcl::AbstractTrueTypeFont::glyphCount(), vcl::AbstractTrueTypeFont::glyphOffset(), index, vcl::MORE_COMPONENTS, n, vcl::O_glyf, 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::glyfAdd().

int vcl::GetTTGlyphPoints ( AbstractTrueTypeFont ttf,
sal_uInt32  glyphID,
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 1374 of file sft.cxx.

References vcl::GetTTGlyphOutline().

Referenced by vcl::GetTTRawGlyphData().

int vcl::GetTTNameRecords ( AbstractTrueTypeFont const *  ttf,
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
nrpointer to the array of NameRecord structs
Returns
number of NameRecord structs

Definition at line 2155 of file sft.cxx.

References assert(), vcl::NameRecord::encodingID, vcl::AbstractTrueTypeFont::fileName(), vcl::GetUInt16(), i, vcl::NameRecord::languageID, n, vcl::NameRecord::nameID, vcl::O_name, vcl::NameRecord::platformID, SAL_WARN, vcl::NameRecord::slen, vcl::NameRecord::sptr, table, and vcl::AbstractTrueTypeFont::table().

Referenced by vcl::CreateTTFromTTGlyphs().

GlyphData * vcl::GetTTRawGlyphData ( AbstractTrueTypeFont ttf,
sal_uInt32  glyphID 
)
VCL_DLLPUBLIC std::unique_ptr< sal_uInt16[]> vcl::GetTTSimpleGlyphMetrics ( AbstractTrueTypeFont const *  ttf,
const sal_uInt16 *  glyphArray,
int  nGlyphs,
bool  vertical 
)

Queries glyph metrics.

Allocates an array of advance width/height values and returns it.

Parameters
ttfpointer to the TrueTypeFont structure
glyphArraypointer to an array of glyphs that are to be extracted from ttf
nGlyphsnumber of glyph IDs in glyphArray and encoding values in encoding
verticalwriting mode: false - horizontal, true - vertical

Definition at line 1951 of file sft.cxx.

References vcl::GetUInt16(), vcl::AbstractTrueTypeFont::horzMetricCount(), i, n, vcl::O_hmtx, vcl::O_vmtx, vcl::AbstractTrueTypeFont::table(), vcl::AbstractTrueTypeFont::unitsPerEm(), vcl::AbstractTrueTypeFont::vertMetricCount(), and vcl::XUnits().

Referenced by SalGraphics::CreateTTFfontSubset(), and SalGraphics::GetGlyphWidths().

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 1082 of file sft.cxx.

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

Referenced by EmbeddedFontsHelper::sufficientTTFRights().

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 1022 of file sft.cxx.

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