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

Unified Diff: content/browser/renderer_host/pepper/pepper_truetype_font_list_linux.cc

Issue 13913006: Add Pepper TrueType font API call to enumerate fonts in a given family. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Windows build. Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/pepper/pepper_truetype_font_list_linux.cc
diff --git a/content/browser/renderer_host/pepper/pepper_truetype_font_list_linux.cc b/content/browser/renderer_host/pepper/pepper_truetype_font_list_linux.cc
index 661266d9a8b508606ae90f9c340522cb232719be..24c3f5df2f53a6b49bbc5af5496c3c3086d46182 100644
--- a/content/browser/renderer_host/pepper/pepper_truetype_font_list_linux.cc
+++ b/content/browser/renderer_host/pepper/pepper_truetype_font_list_linux.cc
@@ -9,6 +9,8 @@
#include <string>
+#include "ppapi/proxy/serialized_structs.h"
+
namespace content {
void GetFontFamilies_SlowBlocking(std::vector<std::string>* font_families) {
@@ -17,9 +19,46 @@ void GetFontFamilies_SlowBlocking(std::vector<std::string>* font_families) {
int num_families = 0;
::pango_font_map_list_families(font_map, &families, &num_families);
- for (int i = 0; i < num_families; i++)
+ for (int i = 0; i < num_families; ++i)
font_families->push_back(::pango_font_family_get_name(families[i]));
g_free(families);
}
+void GetFontsInFamily_SlowBlocking(
+ const std::string& family,
+ std::vector<ppapi::proxy::SerializedTrueTypeFontDesc>* fonts_in_family) {
+ PangoFontMap* font_map = ::pango_cairo_font_map_get_default();
+ PangoFontFamily** font_families = NULL;
+ int num_families = 0;
+ ::pango_font_map_list_families(font_map, &font_families, &num_families);
+
+ for (int i = 0; i < num_families; ++i) {
+ PangoFontFamily* font_family = font_families[i];
+ if (family.compare(::pango_font_family_get_name(font_family)) == 0) {
+ PangoFontFace** font_faces = NULL;
+ int num_faces = 0;
+ ::pango_font_family_list_faces(font_family, &font_faces, &num_faces);
+
+ for (int j = 0; j < num_faces; ++j) {
+ PangoFontFace* font_face = font_faces[j];
+ PangoFontDescription* font_desc = ::pango_font_face_describe(font_face);
+ ppapi::proxy::SerializedTrueTypeFontDesc desc;
+ desc.family = family;
+ if (::pango_font_description_get_style(font_desc) == PANGO_STYLE_ITALIC)
+ desc.style = PP_TRUETYPEFONTSTYLE_ITALIC;
+ desc.weight = static_cast<PP_TrueTypeFontWeight_Dev>(
+ ::pango_font_description_get_weight(font_desc));
+ desc.width = static_cast<PP_TrueTypeFontWidth_Dev>(
+ ::pango_font_description_get_stretch(font_desc));
+ // Character set is not part of Pango font description.
+ desc.charset = PP_TRUETYPEFONTCHARSET_DEFAULT;
+
+ fonts_in_family->push_back(desc);
+ }
+ g_free(font_faces);
+ }
+ }
+ g_free(font_families);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698