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

Unified Diff: trunk/src/ports/SkFontHost_FreeType.cpp

Issue 12988002: add virtual SkTypeface::onOpenStream and override that for fontconfig (Closed) Base URL: http://skia.googlecode.com/svn/
Patch Set: Created 7 years, 9 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
« no previous file with comments | « trunk/src/core/SkTypeface.cpp ('k') | trunk/src/ports/SkFontHost_fontconfig.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/ports/SkFontHost_FreeType.cpp
===================================================================
--- trunk/src/ports/SkFontHost_FreeType.cpp (revision 8295)
+++ trunk/src/ports/SkFontHost_FreeType.cpp (working copy)
@@ -260,7 +260,8 @@
// Will return 0 on failure
// Caller must lock gFTMutex before calling this function.
-static SkFaceRec* ref_ft_face(uint32_t fontID) {
+static SkFaceRec* ref_ft_face(const SkTypeface* typeface) {
+ const SkFontID fontID = typeface->uniqueID();
SkFaceRec* rec = gFaceRecHead;
while (rec) {
if (rec->fFontID == fontID) {
@@ -271,10 +272,10 @@
rec = rec->fNext;
}
- SkStream* strm = SkFontHost::OpenStream(fontID);
+ int face_index;
+ SkStream* strm = typeface->openStream(&face_index);
if (NULL == strm) {
- SkDEBUGF(("SkFontHost::OpenStream failed opening %x\n", fontID));
- return 0;
+ return NULL;
}
// this passes ownership of strm to the rec
@@ -295,15 +296,11 @@
args.stream = &rec->fFTStream;
}
- int face_index;
- int length = SkFontHost::GetFileName(fontID, NULL, 0, &face_index);
- FT_Error err = FT_Open_Face(gFTLibrary, &args, length ? face_index : 0,
- &rec->fFace);
-
+ FT_Error err = FT_Open_Face(gFTLibrary, &args, face_index, &rec->fFace);
if (err) { // bad filename, try the default font
fprintf(stderr, "ERROR: unable to open font '%x'\n", fontID);
SkDELETE(rec);
- return 0;
+ return NULL;
} else {
SkASSERT(rec->fFace);
//fprintf(stderr, "Opened font '%s'\n", filename.c_str());
@@ -462,7 +459,7 @@
libInit = gFTLibrary;
}
SkAutoTCallIProc<struct FT_LibraryRec_, FT_Done_FreeType> ftLib(libInit);
- SkFaceRec* rec = ref_ft_face(this->uniqueID());
+ SkFaceRec* rec = ref_ft_face(this);
if (NULL == rec)
return NULL;
FT_Face face = rec->fFace;
@@ -707,7 +704,7 @@
libInit = gFTLibrary;
}
SkAutoTCallIProc<struct FT_LibraryRec_, FT_Done_FreeType> ftLib(libInit);
- SkFaceRec *rec = ref_ft_face(this->uniqueID());
+ SkFaceRec *rec = ref_ft_face(this);
int unitsPerEm = 0;
if (rec != NULL && rec->fFace != NULL) {
@@ -733,7 +730,7 @@
// load the font file
fFTSize = NULL;
fFace = NULL;
- fFaceRec = ref_ft_face(fRec.fFontID);
+ fFaceRec = ref_ft_face(typeface);
if (NULL == fFaceRec) {
return;
}
« no previous file with comments | « trunk/src/core/SkTypeface.cpp ('k') | trunk/src/ports/SkFontHost_fontconfig.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698