1633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com/*
2633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com * Copyright 2011 Google Inc. All Rights Reserved.
3633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com *
4633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com * Licensed under the Apache License, Version 2.0 (the "License");
5633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com * you may not use this file except in compliance with the License.
6633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com * You may obtain a copy of the License at
7633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com *
8633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com *      http://www.apache.org/licenses/LICENSE-2.0
9633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com *
10633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com * Unless required by applicable law or agreed to in writing, software
11633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com * distributed under the License is distributed on an "AS IS" BASIS,
12633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com * See the License for the specific language governing permissions and
14633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com * limitations under the License.
15633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com */
16633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com// File is originally from Chromium third_party/sfntly/src/subsetter.
17633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com// Use as test case in sfntly so that problems can be caught in upstream early.
185af34fd773f8cfee82321393504f558ddf67c628arthurhsu@google.com#ifndef SFNTLY_CPP_SRC_TEST_FONT_SUBSETTER_H_
195af34fd773f8cfee82321393504f558ddf67c628arthurhsu@google.com#define SFNTLY_CPP_SRC_TEST_FONT_SUBSETTER_H_
20633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com
21f7f392d54b6d5775b089cec2e35304fb0864ef34arthurhsu@google.com#include <stddef.h>
22633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com
23633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.comclass SfntlyWrapper {
24633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com public:
25633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com
26633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  // Font subsetting API
27633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  //
28633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  // Input TTF/TTC/OTF fonts, specify the glyph IDs to subset, and the subset
29633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  // font is returned in |output_buffer| (caller to delete[]).  Return value is
30633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  // the length of output_buffer allocated.
31633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  //
32633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  // If subsetting fails, a negative value is returned.  If none of the glyph
33633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  // IDs specified is found, the function will return 0.
34633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  //
35633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  // |font_name|      Font name, required for TTC files.  If specified NULL,
36633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  //                  the first available font is selected.
37633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  // |original_font|  Original font file contents.
38633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  // |font_size|      Size of |original_font| in bytes.
39633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  // |glyph_ids|      Glyph IDs to subset.  If the specified glyph ID is not
40633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  //                  found in the font file, it will be ignored silently.
41633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  // |glyph_count|    Number of glyph IDs in |glyph_ids|
42633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  // |output_buffer|  Generated subset font.  Caller to delete[].
43633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com  static int SubsetFont(const char* font_name,
44633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com                        const unsigned char* original_font,
45633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com                        size_t font_size,
46633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com                        const unsigned int* glyph_ids,
47633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com                        size_t glyph_count,
48633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com                        unsigned char** output_buffer);
49633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com};
50633131f1440aad16805eefd9ff04455f93429433arthurhsu@google.com
515af34fd773f8cfee82321393504f558ddf67c628arthurhsu@google.com#endif  // SFNTLY_CPP_SRC_TEST_FONT_SUBSETTER_H_
52