fix base linux build, adding freetype support

git-svn-id: http://skia.googlecode.com/svn/trunk@371 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
reed@android.com 2009-09-28 16:12:48 +00:00
parent 2a645c9e32
commit f2afb67bab
3 changed files with 28 additions and 38 deletions

View File

@ -3,7 +3,7 @@
# setup our defaults
CC := gcc
C_INCLUDES := -Iinclude/config -Iinclude/core -Iinclude/effects -Iinclude/images -Iinclude/utils
CFLAGS := -Wall # -O2
CFLAGS := -Wall -g # -O2
LINKER_OPTS := -lpthread
DEFINES := -DSK_CAN_USE_FLOAT
HIDE = @
@ -59,10 +59,16 @@ ifeq ($(SKIA_BUILD_FOR),mac)
SRC_LIST += src/utils/mac/SkCreateCGImageRef.cpp
SRC_LIST += src/ports/SkFontHost_mac.cpp
else
LINKER_OPTS += -lpng
LINKER_OPTS += -lpng -lfreetype
DEFINES += -DSK_BUILD_FOR_UNIX
SRC_LIST += src/ports/SkFontHost_none.cpp
# needed for freetype support
C_INCLUDES += -I/usr/include/freetype2
SRC_LIST += src/ports/SkFontHost_linux.cpp
SRC_LIST += src/ports/SkFontHost_gamma_none.cpp
SRC_LIST += src/ports/SkFontHost_FreeType.cpp
SRC_LIST += src/ports/SkFontHost_FreeType_Subpixel.cpp
SRC_LIST += src/utils/SkOSFile.cpp
# these are our registry-based factories
SRC_LIST += src/images/SkImageDecoder_Factory.cpp
SRC_LIST += src/images/SkImageEncoder_Factory.cpp

View File

@ -125,13 +125,13 @@ static FamilyRec* find_family(const SkTypeface* member) {
return NULL;
}
static bool valid_uniqueID(uint32_t uniqueID) {
static SkTypeface* find_from_uniqueID(uint32_t uniqueID) {
FamilyRec* curr = gFamilyHead;
while (curr != NULL) {
for (int i = 0; i < 4; i++) {
SkTypeface* face = curr->fFaces[i];
if (face != NULL && face->uniqueID() == uniqueID) {
return true;
return face;
}
}
curr = curr->fNext;
@ -139,6 +139,10 @@ static bool valid_uniqueID(uint32_t uniqueID) {
return false;
}
static bool valid_uniqueID(uint32_t uniqueID) {
return find_from_uniqueID(uniqueID) != NULL;
}
/* Remove reference to this face from its family. If the resulting family
is empty (has no faces), return that family, otherwise return NULL
*/
@ -374,16 +378,16 @@ static SkTypeface* gDefaultNormal;
static void load_system_fonts() {
// check if we've already be called
if (NULL != gDefaultNormal) {
printf("---- default font %p\n", gDefaultNormal);
return;
}
SkOSFile::Iter iter(SK_FONT_FILE_PREFIX, ".ttf");
SkString name;
while (iter.next(&name, false)) {
SkString filename;
GetFullPathForSysFonts(&filename, name.c_str());
// while (filename.size() == 0) { filename.set("/usr/share/fonts/truetype/msttcorefonts/Arial.ttf");
SkString realname;
SkTypeface::Style style;
@ -392,9 +396,9 @@ static void load_system_fonts() {
SkDebugf("------ can't load <%s> as a font\n", filename.c_str());
continue;
}
// SkDebugf("font: <%s> %d <%s>\n", realname.c_str(), style, filename.c_str());
FamilyRec* family = find_familyrec(realname.c_str());
// this constructor puts us into the global gFamilyHead llist
FamilyTypeface* tf = SkNEW_ARGS(FileTypeface,
@ -408,7 +412,7 @@ static void load_system_fonts() {
add_name(realname.c_str(), tf->getFamily());
}
}
// do this after all fonts are loaded. This is our default font, and it
// acts as a sentinel so we only execute load_system_fonts() once
static const char* gDefaultNames[] = {
@ -522,14 +526,14 @@ SkTypeface* SkFontHost::CreateTypeface(const SkTypeface* familyFace,
return tf;
}
SkTypeface* SkFontHost::ValidFontID(uint32_t fontID) {
bool SkFontHost::ValidFontID(uint32_t fontID) {
SkAutoMutexAcquire ac(gFamilyMutex);
return valid_uniqueID(fontID);
}
SkStream* SkFontHost::OpenStream(uint32_t fontID) {
FamilyTypeface* tf = (FamilyTypeface*)SkFontHost::ResolveTypeface(fontID);
FamilyTypeface* tf = (FamilyTypeface*)find_from_uniqueID(fontID);
SkStream* stream = tf ? tf->openStream() : NULL;
if (NULL == stream || stream->getLength() == 0) {
@ -545,28 +549,8 @@ size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length,
return 0;
}
void SkFontHost::CloseStream(uint32_t fontID, SkStream* stream) {
FamilyTypeface* tf = (FamilyTypeface*)SkFontHost::ResolveTypeface(fontID);
if (NULL != tf) {
tf->closeStream(stream);
}
}
SkScalerContext* SkFontHost::CreateFallbackScalerContext(
const SkScalerContext::Rec& rec) {
load_system_fonts();
SkAutoDescriptor ad(sizeof(rec) + SkDescriptor::ComputeOverhead(1));
SkDescriptor* desc = ad.getDesc();
desc->init();
SkScalerContext::Rec* newRec =
(SkScalerContext::Rec*)desc->addEntry(kRec_SkDescriptorTag,
sizeof(rec), &rec);
newRec->fFontID = gFallBackTypeface->uniqueID();
desc->computeChecksum();
return SkFontHost::CreateScalerContext(desc);
uint32_t SkFontHost::NextLogicalFont(uint32_t fontID) {
return 0;
}
///////////////////////////////////////////////////////////////////////////////
@ -588,10 +572,10 @@ SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) {
SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path));
if (stream->isValid()) {
return CreateTypeface(stream);
face = CreateTypefaceFromStream(stream);
}
stream->unref();
return NULL;
return face;
}
///////////////////////////////////////////////////////////////////////////////

View File

@ -51,7 +51,7 @@ bool SkSfntUtils::ReadTable_head(SkFontID fontID, SkSfntTable_head* head) {
head->fFontDirectionHint = parse_be16(p);
head->fIndexToLocFormat = parse_be16(p);
head->fGlyphDataFormat = parse_be16(p);
SkASSERT(p - storage == size);
SkASSERT(p - storage == (long)size);
return true;
}
@ -81,7 +81,7 @@ bool SkSfntUtils::ReadTable_maxp(SkFontID fontID, SkSfntTable_maxp* maxp) {
maxp->fMaxSizeOfInstructions = parse_be16(p);
maxp->fMaxComponentElements = parse_be16(p);
maxp->fMaxComponentDepth = parse_be16(p);
SkASSERT(p - storage == size);
SkASSERT(p - storage == (long)size);
return true;
}