2001-05-08 10:46:10 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 09:17:09 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-05-08 10:46:10 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2001-05-08 10:46:10 +00:00
|
|
|
*
|
2008-04-11 09:17:09 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-05-08 10:46:10 +00:00
|
|
|
*
|
2008-04-11 09:17:09 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-05-08 10:46:10 +00:00
|
|
|
*
|
2008-04-11 09:17:09 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2001-05-08 10:46:10 +00:00
|
|
|
*
|
2008-04-11 09:17:09 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2001-05-08 10:46:10 +00:00
|
|
|
*
|
2008-04-11 09:17:09 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2001-05-08 10:46:10 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @file ttcr.h
|
|
|
|
* @brief TrueType font creator
|
|
|
|
* @author Alexander Gelfenbain
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __TTCR_H
|
|
|
|
#define __TTCR_H
|
|
|
|
|
2009-04-01 11:54:14 +00:00
|
|
|
#include "sft.hxx"
|
2001-05-08 10:46:10 +00:00
|
|
|
|
2009-04-01 11:54:14 +00:00
|
|
|
namespace vcl
|
2001-05-08 10:46:10 +00:00
|
|
|
{
|
|
|
|
typedef struct _TrueTypeCreator TrueTypeCreator;
|
|
|
|
|
|
|
|
/* TrueType data types */
|
|
|
|
typedef struct {
|
2002-08-02 11:11:34 +00:00
|
|
|
sal_uInt16 aw;
|
|
|
|
sal_Int16 lsb;
|
2001-05-08 10:46:10 +00:00
|
|
|
} longHorMetrics;
|
|
|
|
|
|
|
|
/* A generic base class for all TrueType tables */
|
2009-04-01 11:54:14 +00:00
|
|
|
struct TrueTypeTable {
|
2002-08-02 11:11:34 +00:00
|
|
|
sal_uInt32 tag; /* table tag */
|
|
|
|
sal_uInt8 *rawdata; /* raw data allocated by GetRawData_*() */
|
|
|
|
void *data; /* table specific data */
|
2009-04-01 11:54:14 +00:00
|
|
|
};
|
2001-05-08 10:46:10 +00:00
|
|
|
|
|
|
|
/** Error codes for most functions */
|
|
|
|
enum TTCRErrCodes {
|
|
|
|
TTCR_OK = 0, /**< no error */
|
|
|
|
TTCR_ZEROGLYPHS = 1, /**< At least one glyph should be defined */
|
|
|
|
TTCR_UNKNOWN = 2, /**< Unknown TrueType table */
|
|
|
|
TTCR_GLYPHSEQ = 3, /**< Glyph IDs are not sequential in the glyf table */
|
|
|
|
TTCR_NONAMES = 4, /**< 'name' table does not contain any names */
|
|
|
|
TTCR_NAMETOOLONG = 5, /**< 'name' table is too long (string data > 64K) */
|
|
|
|
TTCR_POSTFORMAT = 6 /**< unsupported format of a 'post' table */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ============================================================================
|
|
|
|
*
|
|
|
|
* TrueTypeCreator methods
|
|
|
|
*
|
|
|
|
* ============================================================================ */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TrueTypeCreator constructor.
|
|
|
|
* Allocates all internal structures.
|
|
|
|
*/
|
2002-08-02 11:11:34 +00:00
|
|
|
void TrueTypeCreatorNewEmpty(sal_uInt32 tag, TrueTypeCreator **_this);
|
2001-05-08 10:46:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds a TrueType table to the TrueType creator.
|
|
|
|
* SF_TABLEFORMAT value.
|
|
|
|
* @return value of SFErrCodes type
|
|
|
|
*/
|
|
|
|
int AddTable(TrueTypeCreator *_this, TrueTypeTable *table);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a TrueType table from the TrueType creator if it is stored there.
|
|
|
|
* It also calls a TrueTypeTable destructor.
|
|
|
|
* Note: all generic tables (with tag 0) will be removed if this function is
|
|
|
|
* called with the second argument of 0.
|
|
|
|
* @return value of SFErrCodes type
|
|
|
|
*/
|
2002-08-02 11:11:34 +00:00
|
|
|
void RemoveTable(TrueTypeCreator *_this, sal_uInt32 tag);
|
2001-05-08 10:46:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Writes a TrueType font generated by the TrueTypeCreator to a segment of
|
|
|
|
* memory that this method allocates. When it is not needed anymore the caller
|
|
|
|
* is supposed to call free() on it.
|
|
|
|
* @return value of SFErrCodes type
|
|
|
|
*/
|
2002-08-02 11:11:34 +00:00
|
|
|
int StreamToMemory(TrueTypeCreator *_this, sal_uInt8 **ptr, sal_uInt32 *length);
|
2001-05-08 10:46:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Writes a TrueType font generated by the TrueTypeCreator to a file
|
|
|
|
* @return value of SFErrCodes type
|
|
|
|
*/
|
|
|
|
int StreamToFile(TrueTypeCreator *_this, const char* fname);
|
|
|
|
|
|
|
|
|
|
|
|
/* ============================================================================
|
|
|
|
*
|
|
|
|
* TrueTypeTable methods
|
|
|
|
*
|
|
|
|
* ============================================================================ */
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function converts the data of a TrueType table to a raw array of bytes.
|
|
|
|
* It may allocates the memory for it and returns the size of the raw data in bytes.
|
|
|
|
* If memory is allocated it does not need to be freed by the caller of this function,
|
|
|
|
* since the pointer to it is stored in the TrueTypeTable and it is freed by the destructor
|
|
|
|
* @return TTCRErrCode
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2002-08-02 11:11:34 +00:00
|
|
|
int GetRawData(TrueTypeTable *, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag);
|
2001-05-08 10:46:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Creates a new raw TrueType table. The difference between this constructor and
|
|
|
|
* TrueTypeTableNew_tag constructors is that the latter create structured tables
|
|
|
|
* while this constructor just copies memory pointed to by ptr to its buffer
|
|
|
|
* and stores its length. This constructor is suitable for data that is not
|
|
|
|
* supposed to be processed in any way, just written to the resulting TTF file.
|
|
|
|
*/
|
2002-08-02 11:11:34 +00:00
|
|
|
TrueTypeTable *TrueTypeTableNew(sal_uInt32 tag,
|
|
|
|
sal_uInt32 nbytes,
|
2009-08-27 12:02:29 +00:00
|
|
|
const sal_uInt8* ptr);
|
2001-05-08 10:46:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new 'head' table for a TrueType font.
|
|
|
|
* Allocates memory for it. Since a lot of values in the 'head' table depend on the
|
|
|
|
* rest of the tables in the TrueType font this table should be the last one added
|
|
|
|
* to the font.
|
|
|
|
*/
|
2002-08-02 11:11:34 +00:00
|
|
|
TrueTypeTable *TrueTypeTableNew_head(sal_uInt32 fontRevision,
|
|
|
|
sal_uInt16 flags,
|
|
|
|
sal_uInt16 unitsPerEm,
|
2009-08-27 12:02:29 +00:00
|
|
|
const sal_uInt8 *created,
|
2002-08-02 11:11:34 +00:00
|
|
|
sal_uInt16 macStyle,
|
|
|
|
sal_uInt16 lowestRecPPEM,
|
|
|
|
sal_Int16 fontDirectionHint);
|
2001-05-08 10:46:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new 'hhea' table for a TrueType font.
|
|
|
|
* Allocates memory for it and stores it in the hhea pointer.
|
|
|
|
*/
|
2002-08-02 11:11:34 +00:00
|
|
|
TrueTypeTable *TrueTypeTableNew_hhea(sal_Int16 ascender,
|
|
|
|
sal_Int16 descender,
|
|
|
|
sal_Int16 linegap,
|
|
|
|
sal_Int16 caretSlopeRise,
|
|
|
|
sal_Int16 caretSlopeRun);
|
2001-05-08 10:46:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new empty 'loca' table for a TrueType font.
|
|
|
|
*
|
|
|
|
* INTERNAL: gets called only from ProcessTables();
|
|
|
|
*/
|
|
|
|
TrueTypeTable *TrueTypeTableNew_loca(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new 'maxp' table based on an existing maxp table.
|
|
|
|
* If maxp is 0, a new empty maxp table is created
|
|
|
|
* size specifies the size of existing maxp table for
|
|
|
|
* error-checking purposes
|
|
|
|
*/
|
2009-08-27 12:02:29 +00:00
|
|
|
TrueTypeTable *TrueTypeTableNew_maxp( const sal_uInt8* maxp, int size);
|
2001-05-08 10:46:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new empty 'glyf' table.
|
|
|
|
*/
|
|
|
|
TrueTypeTable *TrueTypeTableNew_glyf(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new empty 'cmap' table.
|
|
|
|
*/
|
|
|
|
TrueTypeTable *TrueTypeTableNew_cmap(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new 'name' table. If n != 0 the table gets populated by
|
|
|
|
* the Name Records stored in the nr array. This function allocates
|
|
|
|
* memory for its own copy of NameRecords, so nr array has to
|
|
|
|
* be explicitly deallocated when it is not needed.
|
|
|
|
*/
|
|
|
|
TrueTypeTable *TrueTypeTableNew_name(int n, NameRecord *nr);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new 'post' table of one of the supported formats
|
|
|
|
*/
|
2002-08-02 11:11:34 +00:00
|
|
|
TrueTypeTable *TrueTypeTableNew_post(sal_uInt32 format,
|
|
|
|
sal_uInt32 italicAngle,
|
|
|
|
sal_Int16 underlinePosition,
|
|
|
|
sal_Int16 underlineThickness,
|
|
|
|
sal_uInt32 isFixedPitch);
|
2001-05-08 10:46:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Table manipulation functions
|
|
|
|
*
|
|
|
|
*------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a character/glyph pair to a cmap table
|
|
|
|
*/
|
2002-08-02 11:11:34 +00:00
|
|
|
void cmapAdd(TrueTypeTable *, sal_uInt32 id, sal_uInt32 c, sal_uInt32 g);
|
2001-05-08 10:46:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a glyph to a glyf table.
|
|
|
|
*
|
|
|
|
* @return glyphID of the glyph in the new font
|
|
|
|
*
|
|
|
|
* NOTE: This function does not duplicate GlyphData, so memory will be
|
|
|
|
* deallocated in the table destructor
|
|
|
|
*/
|
2002-08-02 11:11:34 +00:00
|
|
|
sal_uInt32 glyfAdd(TrueTypeTable *, GlyphData *glyphdata, TrueTypeFont *fnt);
|
2001-05-08 10:46:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Query the number of glyphs currently stored in the 'glyf' table
|
|
|
|
*
|
|
|
|
*/
|
2002-08-02 11:11:34 +00:00
|
|
|
sal_uInt32 glyfCount(const TrueTypeTable *);
|
2001-05-08 10:46:10 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add a Name Record to a name table.
|
|
|
|
* NOTE: This function duplicates NameRecord, so the argument
|
|
|
|
* has to be deallocated by the caller (unlike glyfAdd)
|
|
|
|
*/
|
|
|
|
void nameAdd(TrueTypeTable *, NameRecord *nr);
|
|
|
|
|
2009-04-01 11:54:14 +00:00
|
|
|
} // namespace
|
2001-05-08 10:46:10 +00:00
|
|
|
|
|
|
|
|
2009-04-01 11:54:14 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Destructor for the TrueTypeTable object.
|
2001-05-08 10:46:10 +00:00
|
|
|
*/
|
2009-04-01 11:54:14 +00:00
|
|
|
void TrueTypeTableDispose(vcl::TrueTypeTable *);
|
2001-05-08 10:46:10 +00:00
|
|
|
|
2009-04-01 11:54:14 +00:00
|
|
|
/**
|
|
|
|
* TrueTypeCreator destructor. It calls destructors for all TrueTypeTables added to it.
|
|
|
|
*/
|
|
|
|
void TrueTypeCreatorDispose(vcl::TrueTypeCreator *_this);
|
2001-05-08 10:46:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __TTCR_H */
|