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

Side by Side Diff: ppapi/cpp/trusted/browser_font_trusted.h

Issue 9360045: Rename PPB_Font to PPB_BrowserFont_Trusted. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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
« no previous file with comments | « ppapi/c/trusted/ppb_browser_font_trusted.h ('k') | ppapi/cpp/trusted/browser_font_trusted.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 #ifndef PPAPI_CPP_TRUSTED_BROWSER_FONT_TRUSTED_H_
6 #define PPAPI_CPP_TRUSTED_BROWSER_FONT_TRUSTED_H_
7
8 #include <string>
9
10 #include "ppapi/c/trusted/ppb_browser_font_trusted.h"
11 #include "ppapi/cpp/resource.h"
12 #include "ppapi/cpp/var.h"
13
14 namespace pp {
15
16 class ImageData;
17 class Instance;
18 class Point;
19 class Rect;
20
21 // BrowserFontDescription ------------------------------------------------------
22
23 class BrowserFontDescription {
24 public:
25 BrowserFontDescription();
26 BrowserFontDescription(const BrowserFontDescription& other);
27 ~BrowserFontDescription();
28
29 BrowserFontDescription& operator=(const BrowserFontDescription& other);
30
31 const PP_BrowserFont_Trusted_Description& pp_font_description() const {
32 return pp_font_description_;
33 }
34
35 Var face() const { return face_; }
36 void set_face(const Var& face) {
37 face_ = face;
38 pp_font_description_.face = face_.pp_var();
39 }
40
41 PP_BrowserFont_Trusted_Family family() const {
42 return pp_font_description_.family;
43 }
44 void set_family(PP_BrowserFont_Trusted_Family f) {
45 pp_font_description_.family = f;
46 }
47
48 uint32_t size() const { return pp_font_description_.size; }
49 void set_size(uint32_t s) { pp_font_description_.size = s; }
50
51 PP_BrowserFont_Trusted_Weight weight() const {
52 return pp_font_description_.weight;
53 }
54 void set_weight(PP_BrowserFont_Trusted_Weight w) {
55 pp_font_description_.weight = w;
56 }
57
58 bool italic() const { return PP_ToBool(pp_font_description_.italic); }
59 void set_italic(bool i) { pp_font_description_.italic = PP_FromBool(i); }
60
61 bool small_caps() const {
62 return PP_ToBool(pp_font_description_.small_caps);
63 }
64 void set_small_caps(bool s) {
65 pp_font_description_.small_caps = PP_FromBool(s);
66 }
67
68 int letter_spacing() const { return pp_font_description_.letter_spacing; }
69 void set_letter_spacing(int s) { pp_font_description_.letter_spacing = s; }
70
71 int word_spacing() const { return pp_font_description_.word_spacing; }
72 void set_word_spacing(int w) { pp_font_description_.word_spacing = w; }
73
74 private:
75 friend class BrowserFont_Trusted;
76
77 Var face_; // Manages memory for pp_font_description_.face
78 PP_BrowserFont_Trusted_Description pp_font_description_;
79 };
80
81 // BrowserFontTextRun ----------------------------------------------------------
82
83 class BrowserFontTextRun {
84 public:
85 BrowserFontTextRun();
86 BrowserFontTextRun(const std::string& text,
87 bool rtl = false,
88 bool override_direction = false);
89 BrowserFontTextRun(const BrowserFontTextRun& other);
90 ~BrowserFontTextRun();
91
92 BrowserFontTextRun& operator=(const BrowserFontTextRun& other);
93
94 const PP_BrowserFont_Trusted_TextRun& pp_text_run() const {
95 return pp_text_run_;
96 }
97
98 private:
99 Var text_; // Manages memory for the reference in pp_text_run_.
100 PP_BrowserFont_Trusted_TextRun pp_text_run_;
101 };
102
103 // BrowserFont_Trusted ---------------------------------------------------------
104
105 // Provides access to system fonts.
106 class BrowserFont_Trusted : public Resource {
107 public:
108 // Creates an is_null() Font object.
109 BrowserFont_Trusted();
110
111 explicit BrowserFont_Trusted(PP_Resource resource);
112 BrowserFont_Trusted(Instance* instance,
113 const BrowserFontDescription& description);
114 BrowserFont_Trusted(const BrowserFont_Trusted& other);
115
116 BrowserFont_Trusted& operator=(const BrowserFont_Trusted& other);
117
118 // PPB_Font methods:
119 static Var GetFontFamilies(Instance* instance);
120 bool Describe(BrowserFontDescription* description,
121 PP_BrowserFont_Trusted_Metrics* metrics) const;
122 bool DrawTextAt(ImageData* dest,
123 const BrowserFontTextRun& text,
124 const Point& position,
125 uint32_t color,
126 const Rect& clip,
127 bool image_data_is_opaque) const;
128 int32_t MeasureText(const BrowserFontTextRun& text) const;
129 uint32_t CharacterOffsetForPixel(const BrowserFontTextRun& text,
130 int32_t pixel_position) const;
131 int32_t PixelOffsetForCharacter(const BrowserFontTextRun& text,
132 uint32_t char_offset) const;
133
134 // Convenience function that assumes a left-to-right string with no clipping.
135 bool DrawSimpleText(ImageData* dest,
136 const std::string& text,
137 const Point& position,
138 uint32_t color,
139 bool image_data_is_opaque = false) const;
140
141 // Convenience function that assumes a left-to-right string.
142 int32_t MeasureSimpleText(const std::string& text) const;
143 };
144
145 } // namespace pp
146
147 #endif // PPAPI_CPP_TRUSTED_BROWSER_FONT_TRUSTED_H_
OLDNEW
« no previous file with comments | « ppapi/c/trusted/ppb_browser_font_trusted.h ('k') | ppapi/cpp/trusted/browser_font_trusted.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698