1/*
2 * Copyright 2011 Google Inc. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16// File is originally from Chromium third_party/sfntly/src/subsetter.
17// Use as test case in sfntly so that problems can be caught in upstream early.
18#ifndef SFNTLY_CPP_SRC_TEST_FONT_SUBSETTER_H_
19#define SFNTLY_CPP_SRC_TEST_FONT_SUBSETTER_H_
20
21#include <stddef.h>
22
23class SfntlyWrapper {
24 public:
25
26 // Font subsetting API
27 //
28 // Input TTF/TTC/OTF fonts, specify the glyph IDs to subset, and the subset
29 // font is returned in |output_buffer| (caller to delete[]). Return value is
30 // the length of output_buffer allocated.
31 //
32 // If subsetting fails, a negative value is returned. If none of the glyph
33 // IDs specified is found, the function will return 0.
34 //
35 // |font_name| Font name, required for TTC files. If specified NULL,
36 // the first available font is selected.
37 // |original_font| Original font file contents.
38 // |font_size| Size of |original_font| in bytes.
39 // |glyph_ids| Glyph IDs to subset. If the specified glyph ID is not
40 // found in the font file, it will be ignored silently.
41 // |glyph_count| Number of glyph IDs in |glyph_ids|
42 // |output_buffer| Generated subset font. Caller to delete[].
43 static int SubsetFont(const char* font_name,
44 const unsigned char* original_font,
45 size_t font_size,
46 const unsigned int* glyph_ids,
47 size_t glyph_count,
48 unsigned char** output_buffer);
49
50
51 // Font subsetting API
52 //
53 // Input TTF/TTC/OTF fonts, specify the glyph IDs to subset, and the subset
54 // font is returned in |output_buffer| (caller to delete[]). Return value is
55 // the length of output_buffer allocated.
56 //
57 // If subsetting fails, a negative value is returned. If none of the glyph
58 // IDs specified is found, the function will return 0.
59 //
60 // |font_name| Font index, ignored for non-TTC files, 0-indexed.
61 // |original_font| Original font file contents.
62 // |font_size| Size of |original_font| in bytes.
63 // |glyph_ids| Glyph IDs to subset. If the specified glyph ID is not
64 // found in the font file, it will be ignored silently.
65 // |glyph_count| Number of glyph IDs in |glyph_ids|
66 // |output_buffer| Generated subset font. Caller to delete[].
67 static int SubsetFont(int font_index,
68 const unsigned char* original_font,
69 size_t font_size,
70 const unsigned int* glyph_ids,
71 size_t glyph_count,
72 unsigned char** output_buffer);
73};
74
75#endif // SFNTLY_CPP_SRC_TEST_FONT_SUBSETTER_H_
76