| OLD | NEW |
| (Empty) |
| 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 | |
| 17 #ifndef THIRD_PARTY_SFNTLY_SRC_SUBSETTER_SUBSETTER_IMPL_H_ | |
| 18 #define THIRD_PARTY_SFNTLY_SRC_SUBSETTER_SUBSETTER_IMPL_H_ | |
| 19 | |
| 20 #include "third_party/sfntly/src/sfntly/font.h" | |
| 21 #include "third_party/sfntly/src/sfntly/font_factory.h" | |
| 22 #include "third_party/sfntly/src/sfntly/table/truetype/glyph_table.h" | |
| 23 #include "third_party/sfntly/src/sfntly/table/truetype/loca_table.h" | |
| 24 #include "third_party/sfntly/src/sfntly/tag.h" | |
| 25 | |
| 26 namespace sfntly { | |
| 27 | |
| 28 // Smart pointer usage in sfntly: | |
| 29 // | |
| 30 // sfntly carries a smart pointer implementation like COM. Ref-countable object | |
| 31 // type inherits from RefCounted<>, which have AddRef and Release just like | |
| 32 // IUnknown (but no QueryInterface). Use a Ptr<> based smart pointer to hold | |
| 33 // the object so that the object ref count is handled correctly. | |
| 34 // | |
| 35 // class Foo : public RefCounted<Foo> { | |
| 36 // public: | |
| 37 // static Foo* CreateInstance() { | |
| 38 // Ptr<Foo> obj = new Foo(); // ref count = 1 | |
| 39 // return obj.detach(); | |
| 40 // } | |
| 41 // }; | |
| 42 // typedef Ptr<Foo> FooPtr; // common short-hand notation | |
| 43 // FooPtr obj; | |
| 44 // obj.attach(Foo::CreatedInstance()); // ref count = 1 | |
| 45 // { | |
| 46 // FooPtr obj2 = obj; // ref count = 2 | |
| 47 // } // ref count = 1, obj2 out of scope | |
| 48 // obj.release(); // ref count = 0, object destroyed | |
| 49 | |
| 50 class SubsetterImpl { | |
| 51 public: | |
| 52 SubsetterImpl(); | |
| 53 ~SubsetterImpl(); | |
| 54 | |
| 55 bool LoadFont(const char* font_name, | |
| 56 const unsigned char* original_font, | |
| 57 size_t font_size); | |
| 58 int SubsetFont(const unsigned int* glyph_ids, | |
| 59 size_t glyph_count, | |
| 60 unsigned char** output_buffer); | |
| 61 | |
| 62 private: | |
| 63 CALLER_ATTACH Font* Subset(const IntegerSet& glyph_ids, | |
| 64 GlyphTable* glyf, LocaTable* loca); | |
| 65 | |
| 66 FontFactoryPtr factory_; | |
| 67 FontPtr font_; | |
| 68 }; | |
| 69 | |
| 70 } // namespace sfntly | |
| 71 | |
| 72 #endif // THIRD_PARTY_SFNTLY_SRC_SUBSETTER_SUBSETTER_IMPL_H_ | |
| OLD | NEW |