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

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: Update sfntly version to the one clang friendly 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 // typedef Ptr<Foo> FooPtr; // common short-hand notation
40 // FooPtr obj;
41 // obj.attach(Foo::CreatedInstance()); // ref count = 1
42 // {
43 // FooPtr obj2 = obj; // ref count = 2
44 // } // ref count = 1, obj2 out of scope
45 // obj.release(); // ref count = 0, object destroyed
46
47 class SubsetterImpl {
48 public:
49 SubsetterImpl();
50 ~SubsetterImpl();
51
52 bool LoadFont(const char* font_name,
53 const unsigned char* original_font,
54 size_t font_size);
55 int SubsetFont(const unsigned int* glyph_ids,
56 size_t glyph_count,
57 unsigned char** output_buffer);
58
59 private:
60 Font* FindFont(const char* font_name, const FontArray& font_array);
61 bool HasName(const char* font_name, Font* font);
62 CALLER_ATTACH Font* Subset(const unsigned int* glyph_ids,
63 size_t glyph_count);
64
65 FontFactoryPtr factory_;
66 FontPtr font_;
67 };
68
69 } // namespace sfntly
70
71 #endif // THIRD_PARTY_SFNTLY_SRC_SUBSETTER_SUBSETTER_IMPL_H_
OLDNEW
« no previous file with comments | « third_party/sfntly/src/subsetter/font_subsetter.cc ('k') | third_party/sfntly/src/subsetter/subsetter_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698