summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DEPS2
-rw-r--r--chrome/browser/renderer_host/render_sandbox_host_linux.cc27
-rw-r--r--skia/ext/SkFontHost_fontconfig.cpp6
-rw-r--r--skia/ext/SkFontHost_fontconfig_direct.cpp40
-rw-r--r--skia/ext/SkFontHost_fontconfig_direct.h4
-rw-r--r--skia/ext/SkFontHost_fontconfig_impl.h4
-rw-r--r--skia/ext/SkFontHost_fontconfig_ipc.cpp27
-rw-r--r--skia/ext/SkFontHost_fontconfig_ipc.h4
-rw-r--r--skia/skia.gyp1
9 files changed, 83 insertions, 32 deletions
diff --git a/DEPS b/DEPS
index d243880..a1250d5 100644
--- a/DEPS
+++ b/DEPS
@@ -3,7 +3,7 @@ vars = {
"http://svn.webkit.org/repository/webkit/trunk",
"webkit_revision": "58304",
"ffmpeg_revision": "45437",
- "skia_revision": "536",
+ "skia_revision": "560",
"chromium_git": "http://src.chromium.org/git",
"swig_revision": "40423",
"nacl_revision": "2072",
diff --git a/chrome/browser/renderer_host/render_sandbox_host_linux.cc b/chrome/browser/renderer_host/render_sandbox_host_linux.cc
index 6b81839..cf51b0f 100644
--- a/chrome/browser/renderer_host/render_sandbox_host_linux.cc
+++ b/chrome/browser/renderer_host/render_sandbox_host_linux.cc
@@ -152,8 +152,6 @@ class SandboxIPCProcess {
std::vector<int>& fds) {
bool fileid_valid;
uint32_t fileid;
- bool is_bold, is_italic;
- std::string family;
if (!pickle.ReadBool(&iter, &fileid_valid))
return;
@@ -161,18 +159,33 @@ class SandboxIPCProcess {
if (!pickle.ReadUInt32(&iter, &fileid))
return;
}
+ bool is_bold, is_italic;
if (!pickle.ReadBool(&iter, &is_bold) ||
- !pickle.ReadBool(&iter, &is_italic) ||
- !pickle.ReadString(&iter, &family)) {
+ !pickle.ReadBool(&iter, &is_italic)) {
return;
}
+ uint32_t characters_bytes;
+ if (!pickle.ReadUInt32(&iter, &characters_bytes))
+ return;
+ const char* characters = NULL;
+ if (characters_bytes > 0) {
+ const uint32_t kMaxCharactersBytes = 1 << 10;
+ if (characters_bytes % 1 == 0 || // We expect UTF-16.
+ characters_bytes > kMaxCharactersBytes ||
+ !pickle.ReadBytes(&iter, &characters, characters_bytes))
+ return;
+ }
+
+ std::string family;
+ if (!pickle.ReadString(&iter, &family))
+ return;
+
std::string result_family;
unsigned result_fileid;
-
const bool r = font_config_->Match(
- &result_family, &result_fileid, fileid_valid, fileid, family, &is_bold,
- &is_italic);
+ &result_family, &result_fileid, fileid_valid, fileid, family,
+ characters, characters_bytes, &is_bold, &is_italic);
Pickle reply;
if (!r) {
diff --git a/skia/ext/SkFontHost_fontconfig.cpp b/skia/ext/SkFontHost_fontconfig.cpp
index 470aa7c..97d300b 100644
--- a/skia/ext/SkFontHost_fontconfig.cpp
+++ b/skia/ext/SkFontHost_fontconfig.cpp
@@ -117,6 +117,7 @@ public:
// static
SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
const char familyName[],
+ const void* data, size_t bytelength,
SkTypeface::Style style)
{
std::string resolved_family_name;
@@ -127,7 +128,7 @@ SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
const unsigned fileid = UniqueIdToFileId(familyFace->uniqueID());
if (!GetFcImpl()->Match(
&resolved_family_name, NULL, true /* fileid valid */, fileid, "",
- NULL, NULL)) {
+ NULL, 0, NULL, NULL)) {
return NULL;
}
} else if (familyName) {
@@ -138,7 +139,8 @@ SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
bool italic = style & SkTypeface::kItalic;
unsigned fileid;
if (!GetFcImpl()->Match(NULL, &fileid, false, -1, /* no fileid */
- resolved_family_name, &bold, &italic)) {
+ resolved_family_name, data, bytelength,
+ &bold, &italic)) {
return NULL;
}
const SkTypeface::Style resulting_style = static_cast<SkTypeface::Style>(
diff --git a/skia/ext/SkFontHost_fontconfig_direct.cpp b/skia/ext/SkFontHost_fontconfig_direct.cpp
index ba30031..2e19928 100644
--- a/skia/ext/SkFontHost_fontconfig_direct.cpp
+++ b/skia/ext/SkFontHost_fontconfig_direct.cpp
@@ -22,6 +22,8 @@
#include <fontconfig/fontconfig.h>
+#include "third_party/icu/public/common/unicode/utf16.h"
+
namespace {
// Equivalence classes, used to match the Liberation fonts with their
@@ -77,15 +79,16 @@ FontConfigDirect::FontConfigDirect()
}
// -----------------------------------------------------------------------------
-// Normally we only return exactly the font asked for. In last-resort cases,
-// the request is for one of the basic font names "Sans", "Serif" or
-// "Monospace". This function tells you whether a given request is for such a
-// fallback.
+// Normally we only return exactly the font asked for. In last-resort
+// cases, the request either doesn't specify a font or is one of the
+// basic font names like "Sans", "Serif" or "Monospace". This function
+// tells you whether a given request is for such a fallback.
// -----------------------------------------------------------------------------
static bool IsFallbackFontAllowed(const std::string& family)
{
const char* family_cstr = family.c_str();
- return strcasecmp(family_cstr, "sans") == 0 ||
+ return family.empty() ||
+ strcasecmp(family_cstr, "sans") == 0 ||
strcasecmp(family_cstr, "serif") == 0 ||
strcasecmp(family_cstr, "monospace") == 0;
}
@@ -93,8 +96,9 @@ static bool IsFallbackFontAllowed(const std::string& family)
bool FontConfigDirect::Match(std::string* result_family,
unsigned* result_fileid,
bool fileid_valid, unsigned fileid,
- const std::string& family, bool* is_bold,
- bool* is_italic) {
+ const std::string& family,
+ const void* data, size_t characters_bytes,
+ bool* is_bold, bool* is_italic) {
if (family.length() > kMaxFontFamilyLength)
return false;
@@ -115,6 +119,26 @@ bool FontConfigDirect::Match(std::string* result_family,
FcPatternAddString(pattern, FC_FAMILY, (FcChar8*) family.c_str());
}
+ FcCharSet* charset = NULL;
+ if (data) {
+ charset = FcCharSetCreate();
+ const uint16_t* chars = (const uint16_t*) data;
+ size_t num_chars = characters_bytes / 2;
+ for (size_t i = 0; i < num_chars; ++i) {
+ if (U16_IS_SURROGATE(chars[i])
+ && U16_IS_SURROGATE_LEAD(chars[i])
+ && i != num_chars - 1
+ && U16_IS_TRAIL(chars[i + 1])) {
+ FcCharSetAddChar(charset, U16_GET_SUPPLEMENTARY(chars[i], chars[i+1]));
+ i++;
+ } else {
+ FcCharSetAddChar(charset, chars[i]);
+ }
+ }
+ FcPatternAddCharSet(pattern, FC_CHARSET, charset);
+ FcCharSetDestroy(charset); // pattern now owns it.
+ }
+
FcPatternAddInteger(pattern, FC_WEIGHT,
is_bold && *is_bold ? FC_WEIGHT_BOLD
: FC_WEIGHT_NORMAL);
@@ -203,8 +227,6 @@ bool FontConfigDirect::Match(std::string* result_family,
FcResultMatch)
break;
acceptable_substitute =
- family.empty() ?
- true :
(strcasecmp((char *)post_config_family,
(char *)post_match_family) == 0 ||
// Workaround for Issue 12530:
diff --git a/skia/ext/SkFontHost_fontconfig_direct.h b/skia/ext/SkFontHost_fontconfig_direct.h
index 56bea34..9000292 100644
--- a/skia/ext/SkFontHost_fontconfig_direct.h
+++ b/skia/ext/SkFontHost_fontconfig_direct.h
@@ -31,7 +31,9 @@ class FontConfigDirect : public FontConfigInterface {
// FontConfigInterface implementation. Thread safe.
virtual bool Match(std::string* result_family, unsigned* result_fileid,
bool fileid_valid, unsigned fileid,
- const std::string& family, bool* is_bold, bool* is_italic);
+ const std::string& family,
+ const void* characters, size_t characters_bytes,
+ bool* is_bold, bool* is_italic);
virtual int Open(unsigned fileid);
private:
diff --git a/skia/ext/SkFontHost_fontconfig_impl.h b/skia/ext/SkFontHost_fontconfig_impl.h
index d2f1d5d..cc8dce8 100644
--- a/skia/ext/SkFontHost_fontconfig_impl.h
+++ b/skia/ext/SkFontHost_fontconfig_impl.h
@@ -40,6 +40,8 @@ class FontConfigInterface {
* @param family (optional) the family of the font that we are trying to
* match. If the length of the |family| is greater then
* kMaxFontFamilyLength, this function should immediately return false.
+ * @param characters (optional) UTF-16 characters the font must cover.
+ * @param characters_bytes (optional) number of bytes in |characters|
* @param is_bold (optional, set to NULL to ignore, in/out)
* @param is_italic (optional, set to NULL to ignore, in/out)
* @return true iff successful.
@@ -50,6 +52,8 @@ class FontConfigInterface {
bool fileid_valid,
unsigned fileid,
const std::string& family,
+ const void* characters,
+ size_t characters_bytes,
bool* is_bold,
bool* is_italic) = 0;
diff --git a/skia/ext/SkFontHost_fontconfig_ipc.cpp b/skia/ext/SkFontHost_fontconfig_ipc.cpp
index 01bd393..0c95072 100644
--- a/skia/ext/SkFontHost_fontconfig_ipc.cpp
+++ b/skia/ext/SkFontHost_fontconfig_ipc.cpp
@@ -39,35 +39,40 @@ FontConfigIPC::~FontConfigIPC() {
bool FontConfigIPC::Match(std::string* result_family,
unsigned* result_fileid,
bool fileid_valid, unsigned fileid,
- const std::string& family, bool* is_bold,
- bool* is_italic) {
+ const std::string& family,
+ const void* characters, size_t characters_bytes,
+ bool* is_bold, bool* is_italic) {
if (family.length() > kMaxFontFamilyLength)
- return false;
+ return false;
Pickle request;
request.WriteInt(METHOD_MATCH);
request.WriteBool(fileid_valid);
if (fileid_valid)
- request.WriteUInt32(fileid);
+ request.WriteUInt32(fileid);
request.WriteBool(is_bold && *is_bold);
request.WriteBool(is_bold && *is_italic);
+ request.WriteUInt32(characters_bytes);
+ if (characters_bytes)
+ request.WriteBytes(characters, characters_bytes);
+
request.WriteString(family);
uint8_t reply_buf[512];
const ssize_t r = base::SendRecvMsg(fd_, reply_buf, sizeof(reply_buf), NULL,
request);
if (r == -1)
- return false;
+ return false;
Pickle reply(reinterpret_cast<char*>(reply_buf), r);
void* iter = NULL;
bool result;
if (!reply.ReadBool(&iter, &result))
- return false;
+ return false;
if (!result)
- return false;
+ return false;
uint32_t reply_fileid;
std::string reply_family;
@@ -76,17 +81,17 @@ bool FontConfigIPC::Match(std::string* result_family,
!reply.ReadString(&iter, &reply_family) ||
!reply.ReadBool(&iter, &resulting_bold) ||
!reply.ReadBool(&iter, &resulting_italic)) {
- return false;
+ return false;
}
*result_fileid = reply_fileid;
if (result_family)
- *result_family = reply_family;
+ *result_family = reply_family;
if (is_bold)
- *is_bold = resulting_bold;
+ *is_bold = resulting_bold;
if (is_italic)
- *is_italic = resulting_italic;
+ *is_italic = resulting_italic;
return true;
}
diff --git a/skia/ext/SkFontHost_fontconfig_ipc.h b/skia/ext/SkFontHost_fontconfig_ipc.h
index 30a32e1..6f0c052 100644
--- a/skia/ext/SkFontHost_fontconfig_ipc.h
+++ b/skia/ext/SkFontHost_fontconfig_ipc.h
@@ -33,7 +33,9 @@ class FontConfigIPC : public FontConfigInterface {
// FontConfigInterface implementation.
virtual bool Match(std::string* result_family, unsigned* result_fileid,
bool fileid_valid, unsigned fileid,
- const std::string& family, bool* is_bold, bool* is_italic);
+ const std::string& family,
+ const void* characters, size_t characters_bytes,
+ bool* is_bold, bool* is_italic);
virtual int Open(unsigned fileid);
enum Method {
diff --git a/skia/skia.gyp b/skia/skia.gyp
index d9fb72e..1417a16 100644
--- a/skia/skia.gyp
+++ b/skia/skia.gyp
@@ -597,6 +597,7 @@
'../build/linux/system.gyp:freetype2',
'../third_party/harfbuzz/harfbuzz.gyp:harfbuzz',
'../third_party/harfbuzz/harfbuzz.gyp:harfbuzz_interface',
+ '../third_party/icu/icu.gyp:icuuc',
],
'cflags': [
'-Wno-unused',