2017-10-04 16:12:46 -07:00
|
|
|
/* Copyright 2014 Google Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Distributed under MIT license.
|
|
|
|
|
See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* Library for converting WOFF2 format font files to their TTF versions. */
|
2013-11-19 14:32:56 -08:00
|
|
|
|
2014-05-30 09:06:32 +09:00
|
|
|
#ifndef WOFF2_WOFF2_ENC_H_
|
|
|
|
|
#define WOFF2_WOFF2_ENC_H_
|
2013-11-19 14:32:56 -08:00
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <inttypes.h>
|
2014-08-22 08:05:56 -07:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
2013-11-19 14:32:56 -08:00
|
|
|
|
|
|
|
|
namespace woff2 {
|
|
|
|
|
|
2015-07-13 09:08:04 -07:00
|
|
|
struct WOFF2Params {
|
2016-01-28 11:36:18 -08:00
|
|
|
WOFF2Params() : extended_metadata(""), brotli_quality(11),
|
|
|
|
|
allow_transforms(true) {}
|
2015-07-13 09:08:04 -07:00
|
|
|
|
|
|
|
|
string extended_metadata;
|
|
|
|
|
int brotli_quality;
|
2016-01-28 11:36:18 -08:00
|
|
|
bool allow_transforms;
|
2015-07-13 09:08:04 -07:00
|
|
|
};
|
|
|
|
|
|
2013-11-19 14:32:56 -08:00
|
|
|
// Returns an upper bound on the size of the compressed file.
|
|
|
|
|
size_t MaxWOFF2CompressedSize(const uint8_t* data, size_t length);
|
2014-08-22 08:05:56 -07:00
|
|
|
size_t MaxWOFF2CompressedSize(const uint8_t* data, size_t length,
|
|
|
|
|
const string& extended_metadata);
|
2013-11-19 14:32:56 -08:00
|
|
|
|
|
|
|
|
// Compresses the font into the target buffer. *result_length should be at least
|
|
|
|
|
// the value returned by MaxWOFF2CompressedSize(), upon return, it is set to the
|
|
|
|
|
// actual compressed size. Returns true on successful compression.
|
|
|
|
|
bool ConvertTTFToWOFF2(const uint8_t *data, size_t length,
|
|
|
|
|
uint8_t *result, size_t *result_length);
|
2014-08-22 08:05:56 -07:00
|
|
|
bool ConvertTTFToWOFF2(const uint8_t *data, size_t length,
|
|
|
|
|
uint8_t *result, size_t *result_length,
|
2015-07-13 09:08:04 -07:00
|
|
|
const WOFF2Params& params);
|
2014-08-22 08:05:56 -07:00
|
|
|
|
2013-11-19 14:32:56 -08:00
|
|
|
} // namespace woff2
|
|
|
|
|
|
2014-05-30 09:06:32 +09:00
|
|
|
#endif // WOFF2_WOFF2_ENC_H_
|