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)
 TrueTypeFont constructor. More...
 
SFErrCodes vcl::OpenTTFontFile (const char *fname, sal_uInt32 facenum, TrueTypeFont **ttf)
 TrueTypeFont constructor. More...
 
void vcl::CloseTTFont (TrueTypeFont *)
 TrueTypeFont destructor. More...
 
int vcl::GetTTGlyphPoints (TrueTypeFont *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 (TrueTypeFont *ttf, sal_uInt32 glyphID)
 Extracts raw glyph data from the 'glyf' table and returns it in an allocated GlyphData structure. More...
 
int vcl::GetTTGlyphComponents (TrueTypeFont *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 (TrueTypeFont 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 (TrueTypeFont *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 (TrueTypeFont 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...
 
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 )
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 1334 of file sft.cxx.

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

References vcl::TTGlyphMetrics::ah, vcl::TTGlyphMetrics::aw, vcl::BadArg, vcl::BSplineToPSPath(), vcl::TrueTypeFont::fsize, vcl::GetInt16(), vcl::getTable(), vcl::GetTTGlyphOutline(), vcl::GetUInt16(), vcl::GlyphNum, i, vcl::TrueTypeFont::nglyphs, vcl::O_head, vcl::Ok, vcl::PS_CLOSEPATH, vcl::PS_CURVETO, vcl::PS_LINETO, vcl::PS_MOVETO, vcl::PS_NOOP, vcl::TrueTypeFont::psname, vcl::TrueTypeFont::ptr, table, vcl::TrueTypeFont::unitsPerEm, vcl::TTGlyphMetrics::xMax, vcl::TTGlyphMetrics::xMin, vcl::XUnits(), vcl::TTGlyphMetrics::yMax, and vcl::TTGlyphMetrics::yMin.

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

References vcl::AddTable(), vcl::DumpSfnts(), vcl::TrueTypeFont::family, vcl::TrueTypeFont::fname, vcl::TrueTypeFont::fsize, vcl::GetInt16(), vcl::GetInt32(), vcl::getTable(), vcl::getTableSize(), 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, 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, TrueTypeCreatorDispose(), vcl::TrueTypeCreatorNewEmpty(), vcl::TrueTypeTableNew(), vcl::TrueTypeTableNew_glyf(), vcl::TrueTypeTableNew_head(), vcl::TrueTypeTableNew_hhea(), vcl::TrueTypeTableNew_maxp(), vcl::TrueTypeFont::unitsPerEm, and vcl::XUnits().

Referenced by FontSubsetInfo::CreateFontSubsetFromSfnt().

VCL_DLLPUBLIC SFErrCodes vcl::CreateTTFromTTGlyphs ( TrueTypeFont 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 1891 of file sft.cxx.

References vcl::AddTable(), vcl::cmapAdd(), vcl::DisposeNameRecords(), vcl::GetInt16(), vcl::GetInt32(), vcl::getTable(), vcl::getTableSize(), 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, name, vcl::O_cvt, vcl::O_fpgm, vcl::O_head, vcl::O_hhea, vcl::O_maxp, vcl::O_post, vcl::O_prep, vcl::Ok, vcl::POST_isFixedPitch_offset, vcl::POST_italicAngle_offset, vcl::POST_underlinePosition_offset, vcl::POST_underlineThickness_offset, vcl::scalloc(), vcl::StreamToFile(), vcl::T_cvt, vcl::T_fpgm, vcl::T_prep, vcl::T_true, 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().

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

References vcl::TTGlobalFontInfo::ascender, vcl::CMAP_MS_Symbol, vcl::TrueTypeFont::cmapType, vcl::TTGlobalFontInfo::descender, vcl::TTGlobalFontInfo::family, vcl::TrueTypeFont::family, vcl::GetInt16(), vcl::GetInt32(), vcl::getTable(), vcl::getTableSize(), vcl::GetUInt16(), vcl::GetUInt32(), vcl::HEAD_macStyle_offset, vcl::HEAD_xMax_offset, vcl::HEAD_xMin_offset, vcl::HEAD_yMax_offset, vcl::HEAD_yMin_offset, vcl::HHEA_ascender_offset, vcl::HHEA_descender_offset, vcl::HHEA_lineGap_offset, vcl::TTGlobalFontInfo::italicAngle, vcl::TTGlobalFontInfo::linegap, vcl::TTGlobalFontInfo::macStyle, vcl::O_head, vcl::O_hhea, vcl::O_OS2, vcl::O_post, vcl::O_vhea, 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::TTGlobalFontInfo::typeFlags, vcl::TTGlobalFontInfo::typoAscender, vcl::TTGlobalFontInfo::typoDescender, vcl::TTGlobalFontInfo::typoLineGap, vcl::TTGlobalFontInfo::ufamily, vcl::TrueTypeFont::ufamily, vcl::TrueTypeFont::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 ( TrueTypeFont 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 1695 of file sft.cxx.

References vcl::ARG_1_AND_2_ARE_WORDS, vcl::GetInt16(), vcl::getTable(), vcl::GetUInt16(), vcl::TrueTypeFont::goffsets, index, vcl::MORE_COMPONENTS, vcl::TrueTypeFont::nglyphs, vcl::O_glyf, 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 ( TrueTypeFont 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 1690 of file sft.cxx.

References vcl::GetTTGlyphOutline().

Referenced by vcl::GetTTRawGlyphData().

int vcl::GetTTNameRecords ( TrueTypeFont 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 2488 of file sft.cxx.

References vcl::NameRecord::encodingID, vcl::TrueTypeFont::fname, vcl::TrueTypeFont::fsize, vcl::getTable(), vcl::getTableSize(), vcl::GetUInt16(), i, vcl::NameRecord::languageID, vcl::NameRecord::nameID, vcl::O_name, vcl::NameRecord::platformID, vcl::TrueTypeFont::ptr, SAL_WARN, vcl::NameRecord::slen, vcl::NameRecord::sptr, and table.

Referenced by vcl::CreateTTFromTTGlyphs().

GlyphData * vcl::GetTTRawGlyphData ( TrueTypeFont 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 2424 of file sft.cxx.

References vcl::GlyphData::aw, vcl::GlyphData::compflag, vcl::GetInt16(), vcl::getTable(), vcl::getTableSize(), vcl::GetTTGlyphPoints(), vcl::GetUInt16(), vcl::GlyphData::glyphID, vcl::TrueTypeFont::goffsets, i, length, vcl::GlyphData::lsb, vcl::GlyphData::nbytes, vcl::GlyphData::ncontours, vcl::TrueTypeFont::nglyphs, vcl::GlyphData::npoints, vcl::TrueTypeFont::numberOfHMetrics, vcl::O_glyf, vcl::O_hmtx, and vcl::GlyphData::ptr.

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

VCL_DLLPUBLIC std::unique_ptr< sal_uInt16[]> vcl::GetTTSimpleGlyphMetrics ( TrueTypeFont 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 2295 of file sft.cxx.

References vcl::getTable(), vcl::getTableSize(), vcl::GetUInt16(), i, vcl::TrueTypeFont::numberOfHMetrics, vcl::TrueTypeFont::numOfLongVerMetrics, vcl::O_hmtx, vcl::O_vmtx, vcl::TrueTypeFont::unitsPerEm, and vcl::XUnits().

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

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- array of TrueTypeFonts
Returns
value of SFErrCodes enum

Definition at line 1425 of file sft.cxx.

References vcl::allocTrueTypeFont(), vcl::doOpenTTFont(), and vcl::Memory.

Referenced by EmbeddedFontsHelper::sufficientTTFRights().

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

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- array of TrueTypeFonts
Returns
value of SFErrCodes enum

Definition at line 1365 of file sft.cxx.

References vcl::allocTrueTypeFont(), vcl::BadFile, cleanup(), vcl::doOpenTTFont(), vcl::FileIo, and vcl::Memory.