aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports/SkFontHost_android.cpp
diff options
context:
space:
mode:
authorGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-01 15:36:39 +0000
committerGravatar djsollen@google.com <djsollen@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-01 15:36:39 +0000
commitb0d416c280ee314b42d7e923c33d6e3c2f692874 (patch)
tree597199780c51589aa3f923cb9106f2023da1f72c /src/ports/SkFontHost_android.cpp
parentc1d2a58ec8510b226e080f5415a05723a686aab3 (diff)
Store font family when serializing android fonts.
Review URL: https://codereview.appspot.com/6259063 git-svn-id: http://skia.googlecode.com/svn/trunk@4114 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/ports/SkFontHost_android.cpp')
-rw-r--r--src/ports/SkFontHost_android.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/ports/SkFontHost_android.cpp b/src/ports/SkFontHost_android.cpp
index 70f1c7bce0..e4215e22e8 100644
--- a/src/ports/SkFontHost_android.cpp
+++ b/src/ports/SkFontHost_android.cpp
@@ -139,6 +139,27 @@ static FamilyRec* find_family(const SkTypeface* member) {
return NULL;
}
+// gFamilyHeadAndNameListMutex must already be acquired
+static const char* find_family_name(const SkTypeface* member) {
+ FamilyRec* family = find_family(member);
+ if (NULL == family) {
+ return NULL;
+ }
+
+ NameFamilyPairList& namelist = GetNameList();
+ NameFamilyPair* list = namelist.begin();
+ int count = namelist.count();
+
+ for (int i = 0; i < count; i++) {
+ NameFamilyPair* pair = &list[i];
+ if (pair->fFamily == family) {
+ return pair->fName;
+ }
+ }
+
+ return NULL;
+}
+
/* Returns the matching typeface, or NULL. If a typeface is found, its refcnt
is not modified.
*/
@@ -699,9 +720,12 @@ static void load_system_fonts() {
void SkFontHost::Serialize(const SkTypeface* face, SkWStream* stream) {
SkFontDescriptor descriptor;
- //descriptor.setFontFamilyName();
- descriptor.setFontStyle(face->style());
- descriptor.setFontFileName(((FamilyTypeface*)face)->getUniqueString());
+ {
+ SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
+ descriptor.setFamilyName(find_family_name(face));
+ descriptor.setStyle(face->style());
+ descriptor.setFontFileName(((FamilyTypeface*)face)->getUniqueString());
+ }
descriptor.serialize(stream);
@@ -727,9 +751,9 @@ SkTypeface* SkFontHost::Deserialize(SkStream* stream) {
}
SkFontDescriptor descriptor(stream);
- const char* familyName = descriptor.getFontFamilyName();
+ const char* familyName = descriptor.getFamilyName();
const char* fontFileName = descriptor.getFontFileName();
- const SkTypeface::Style style = descriptor.getFontStyle();
+ const SkTypeface::Style style = descriptor.getStyle();
const uint32_t customFontDataLength = stream->readPackedUInt();
if (customFontDataLength > 0) {