KHtml

woff.h
1 /*
2  This file is part of the KDE libraries
3 
4  The Original Code is WOFF font packaging code.
5  Copyright (C) 2009 Mozilla Corporation
6 
7  Contributor(s):
8  Jonathan Kew <[email protected]>
9  Germain Garand <[email protected]>
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Library General Public
13  License as published by the Free Software Foundation; either
14  version 2 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Library General Public License for more details.
20 
21  You should have received a copy of the GNU Library General Public License
22  along with this library; see the file COPYING.LIB. If not, write to
23  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24  Boston, MA 02110-1301, USA.
25 */
26 
27 #ifndef WOFF_H_
28 #define WOFF_H_
29 
30 /* API for the decoding of WOFF (Web Open Font Format) font files */
31 
32 typedef enum {
33  /* Success */
34  eWOFF_ok = 0,
35 
36  /* Errors: no valid result returned */
37  eWOFF_out_of_memory = 1, /* malloc or realloc failed */
38  eWOFF_invalid = 2, /* invalid input file (e.g., bad offset) */
39  eWOFF_compression_failure = 3, /* error in zlib call */
40  eWOFF_bad_signature = 4, /* unrecognized file signature */
41  eWOFF_buffer_too_small = 5, /* the provided buffer is too small */
42  eWOFF_bad_parameter = 6, /* bad parameter (e.g., null source ptr) */
43  eWOFF_illegal_order = 7, /* improperly ordered chunks in WOFF font */
44 
45  /* Warnings: call succeeded but something odd was noticed.
46  Multiple warnings may be OR'd together. */
47  eWOFF_warn_unknown_version = 0x0100, /* unrecognized version of sfnt,
48  not standard TrueType or CFF */
49  eWOFF_warn_checksum_mismatch = 0x0200, /* bad checksum, use with caution;
50  any DSIG will be invalid */
51  eWOFF_warn_misaligned_table = 0x0400, /* table not long-aligned; fixing,
52  but DSIG will be invalid */
53  eWOFF_warn_trailing_data = 0x0800, /* trailing junk discarded,
54  any DSIG may be invalid */
55  eWOFF_warn_unpadded_table = 0x1000, /* sfnt not correctly padded,
56  any DSIG may be invalid */
57  eWOFF_warn_removed_DSIG = 0x2000 /* removed digital signature
58  while fixing checksum errors */
59 } WOFFStatus;
60 
61 /* Note: status parameters must be initialized to eWOFF_ok before calling
62  WOFF functions. If the status parameter contains an error code,
63  functions will return immediately. */
64 
65 #define WOFF_SUCCESS(status) (((status) & 0xff) == eWOFF_ok)
66 #define WOFF_FAILURE(status) (!WOFF_SUCCESS(status))
67 #define WOFF_WARNING(status) ((status) & ~0xff)
68 
69 namespace WOFF
70 {
71 
72 /*****************************************************************************
73  * Returns the size of buffer needed to decode the font (or zero on error).
74  */
75 int getDecodedSize(const char *woffData, int woffLen, int *pStatus);
76 
77 /*****************************************************************************
78  * Decodes WOFF font to a caller-supplied buffer of size bufferLen.
79  * Returns the actual size of the decoded sfnt data in pActualSfntLen
80  * (must be <= bufferLen, otherwise an error will be returned).
81  */
82 void decodeToBuffer(const char *woffData, int woffLen, char *sfntData, int bufferLen,
83  int *pActualSfntLen, int *pStatus);
84 
85 }
86 
87 #endif
Definition: woff.h:69
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 22:48:23 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.