Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: third_party/sfntly/src/subsetter/subsetter_impl.h

Issue 7381004: Add sfntly library for font subsetting used in print preview. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Upload per code review Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
23 namespace sfntly {
24
25 // Smart pointer usage in sfntly:
26 //
27 // sfntly carries a smart pointer implementation like COM. Ref-countable object
28 // type inherits from RefCounted<>, which have AddRef and Release just like
29 // IUnknown (but no QueryInterface). Use a Ptr<> based smart pointer to hold
30 // the object so that the object ref count is handled correctly.
31 //
32 // class Foo : public RefCounted<Foo> {
33 // public:
34 // static Foo* CreateInstance() {
35 // Ptr<Foo> obj = new Foo(); // ref count = 1
36 // return obj.detach();
37 // }
38 // };
39 // FooPtr obj;
40 // obj.attach(Foo::FactoryCreatedInstance()); // ref count = 1
41 // {
42 // FooPtr obj2 = obj; // ref count = 2
43 // } // ref count = 1, obj2 out of scope
44 // obj.release(); // ref count = 0, object destroyed
45
46 class SubsetterImpl {
47 public:
48 SubsetterImpl();
49 ~SubsetterImpl();
50
51 bool LoadFont(const char* font_name,
52 const unsigned char* original_font,
53 size_t font_size);
54 int SubsetFont(const unsigned int* glyph_ids,
55 size_t glyph_count,
56 unsigned char** output_buffer);
57
58 private:
59 Font* FindFont(const char* font_name, const FontArray& font_array);
60 bool HasName(const char* font_name, Font* font);
61 CALLER_ATTACH Font* Subset(const unsigned int* glyph_ids,
62 size_t glyph_count);
63
64 FontFactoryPtr factory_;
65 FontPtr font_;
66 };
67
68 } // namespace sfntly
69
70 #endif // THIRD_PARTY_SFNTLY_SRC_SUBSETTER_SUBSETTER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698