summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authoragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-27 14:59:05 +0000
committeragl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-27 14:59:05 +0000
commitbb91ce763726b984aa69bb1dc3a8eec359753b3b (patch)
treeea25a0160d21a73dd41ed0894f01a20abc5ab15f /skia
parent86b19e614383f1e1779d85da639cc6af3d67ac25 (diff)
downloadchromium_src-bb91ce763726b984aa69bb1dc3a8eec359753b3b.zip
chromium_src-bb91ce763726b984aa69bb1dc3a8eec359753b3b.tar.gz
chromium_src-bb91ce763726b984aa69bb1dc3a8eec359753b3b.tar.bz2
Skia roll 536:560
This also includes Evan's patch: http://codereview.chromium.org/1611033 This roll sits after a revert to Skia's hairline change so, hopefully, doesn't need any rebaselines. The try servers mostly agree although there's one (clip-path-text-and-shape.svg on Windows) that I need to keep on eye on. (That's why I'm landing this before MTV is active.) git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45696 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-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
7 files changed, 62 insertions, 24 deletions
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',