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

Side by Side Diff: ppapi/cpp/private/flash_font.cc

Issue 10905227: Introduce PPB_Flash_Font. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ppapi/cpp/private/flash_font.h"
6
7 #include "ppapi/c/private/ppb_pdf.h"
8 #include "ppapi/cpp/instance_handle.h"
9 #include "ppapi/cpp/module_impl.h"
10
11 namespace pp {
12
13 namespace {
14
15 // TODO(yzshen): Once PPB_Flash_Font gets to the stable channel, we can remove
16 // the code of using PPB_PDF in this file.
17 template <> const char* interface_name<PPB_PDF>() {
18 return PPB_PDF_INTERFACE;
19 }
20
21 template <> const char* interface_name<PPB_Flash_Font_0_1>() {
22 return PPB_FLASH_FONT_INTERFACE_0_1;
23 }
24
25 class FontFile : public Resource {
26 public:
27 FontFile(PassRef, PP_Resource resource) : Resource(PASS_REF, resource) {
28 }
29
30 virtual ~FontFile() {}
31 };
32
33 } // namespace
34
35 namespace flash {
36
37 // static
38 bool Font::IsAvailable() {
39 return has_interface<PPB_PDF>() || has_interface<PPB_Flash_Font_0_1>();
40 }
41
42 // static
43 Resource Font::GetFontFileWithFallback(
44 const InstanceHandle& instance,
45 const PP_FontDescription_Dev* description,
46 PP_PrivateFontCharset charset) {
47 if (has_interface<PPB_Flash_Font_0_1>()) {
48 return FontFile(PASS_REF,
49 get_interface<PPB_Flash_Font_0_1>()->GetFontFileWithFallback(
50 instance.pp_instance(), description, charset));
51 }
52 if (has_interface<PPB_PDF>()) {
53 return FontFile(PASS_REF,
54 get_interface<PPB_PDF>()->GetFontFileWithFallback(
55 instance.pp_instance(), description, charset));
56 }
57 return Resource();
58 }
59
60 // static
61 bool Font::GetFontTableForPrivateFontFile(const Resource& font_file,
62 uint32_t table,
63 void* output,
64 uint32_t* output_length) {
65 if (has_interface<PPB_Flash_Font_0_1>()) {
66 return !!get_interface<PPB_Flash_Font_0_1>()->
67 GetFontTableForPrivateFontFile(
68 font_file.pp_resource(), table, output, output_length);
69 }
70 if (has_interface<PPB_PDF>()) {
71 return get_interface<PPB_PDF>()->GetFontTableForPrivateFontFile(
72 font_file.pp_resource(), table, output, output_length);
73 }
74 return false;
75 }
76
77 } // namespace flash
78 } // namespace pp
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698