aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ports
diff options
context:
space:
mode:
authorGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-25 19:36:11 +0000
committerGravatar bungeman@google.com <bungeman@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-03-25 19:36:11 +0000
commitfe74765f0d302669ae49e68074492bdfe0ce6e6f (patch)
tree8c01548e791a0dde4e1b762a3b75852ce9eab501 /src/ports
parent2daa365123528219fae3b63791a8fd3d197a9ce2 (diff)
Change fixedWidth to fixedPitch and implement on Windows.
Diffstat (limited to 'src/ports')
-rw-r--r--src/ports/SkFontHost_FreeType.cpp6
-rw-r--r--src/ports/SkFontHost_FreeType_common.h4
-rw-r--r--src/ports/SkFontHost_android.cpp34
-rw-r--r--src/ports/SkFontHost_linux.cpp30
-rwxr-xr-xsrc/ports/SkFontHost_mac.cpp16
-rwxr-xr-xsrc/ports/SkFontHost_win.cpp3
6 files changed, 48 insertions, 45 deletions
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index e858759e35..f439a278da 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -1310,7 +1310,7 @@ void SkScalerContext_FreeType::generateFontMetrics(SkPaint::FontMetrics* mx,
ability to extract the name+style from a stream, using FreeType's api.
*/
bool find_name_and_attributes(SkStream* stream, SkString* name,
- SkTypeface::Style* style, bool* isFixedWidth) {
+ SkTypeface::Style* style, bool* isFixedPitch) {
FT_Library library;
if (FT_Init_FreeType(&library)) {
return false;
@@ -1357,8 +1357,8 @@ bool find_name_and_attributes(SkStream* stream, SkString* name,
if (style) {
*style = (SkTypeface::Style) tempStyle;
}
- if (isFixedWidth) {
- *isFixedWidth = FT_IS_FIXED_WIDTH(face);
+ if (isFixedPitch) {
+ *isFixedPitch = FT_IS_FIXED_WIDTH(face);
}
FT_Done_Face(face);
diff --git a/src/ports/SkFontHost_FreeType_common.h b/src/ports/SkFontHost_FreeType_common.h
index 00b3bd6a7a..acf9a4ab2b 100644
--- a/src/ports/SkFontHost_FreeType_common.h
+++ b/src/ports/SkFontHost_FreeType_common.h
@@ -47,8 +47,8 @@ private:
class SkTypeface_FreeType : public SkTypeface {
protected:
- SkTypeface_FreeType(Style style, SkFontID uniqueID, bool isFixedWidth)
- : INHERITED(style, uniqueID, isFixedWidth) {}
+ SkTypeface_FreeType(Style style, SkFontID uniqueID, bool isFixedPitch)
+ : INHERITED(style, uniqueID, isFixedPitch) {}
virtual SkScalerContext* onCreateScalerContext(
const SkDescriptor*) const SK_OVERRIDE;
diff --git a/src/ports/SkFontHost_android.cpp b/src/ports/SkFontHost_android.cpp
index 36ef07bd4f..1dc570989b 100644
--- a/src/ports/SkFontHost_android.cpp
+++ b/src/ports/SkFontHost_android.cpp
@@ -32,7 +32,7 @@ static const char* gTestFallbackConfigFile = NULL;
static const char* gTestFontFilePrefix = NULL;
bool find_name_and_attributes(SkStream* stream, SkString* name,
- SkTypeface::Style* style, bool* isFixedWidth);
+ SkTypeface::Style* style, bool* isFixedPitch);
static void GetFullPathForSysFonts(SkString* full, const char name[]) {
if (gTestFontFilePrefix) {
@@ -284,8 +284,8 @@ static void remove_from_names(FamilyRec* emptyFamily) {
class FamilyTypeface : public SkTypeface_FreeType {
public:
FamilyTypeface(Style style, bool sysFont, SkTypeface* familyMember,
- bool isFixedWidth)
- : INHERITED(style, sk_atomic_inc(&gUniqueFontID) + 1, isFixedWidth) {
+ bool isFixedPitch)
+ : INHERITED(style, sk_atomic_inc(&gUniqueFontID) + 1, isFixedPitch) {
fIsSysFont = sysFont;
// our caller has acquired the gFamilyHeadAndNameListMutex so this is safe
@@ -330,8 +330,8 @@ private:
class StreamTypeface : public FamilyTypeface {
public:
StreamTypeface(Style style, bool sysFont, SkTypeface* familyMember,
- SkStream* stream, bool isFixedWidth)
- : INHERITED(style, sysFont, familyMember, isFixedWidth) {
+ SkStream* stream, bool isFixedPitch)
+ : INHERITED(style, sysFont, familyMember, isFixedPitch) {
SkASSERT(stream);
stream->ref();
fStream = stream;
@@ -363,8 +363,8 @@ private:
class FileTypeface : public FamilyTypeface {
public:
FileTypeface(Style style, bool sysFont, SkTypeface* familyMember,
- const char path[], bool isFixedWidth)
- : INHERITED(style, sysFont, familyMember, isFixedWidth) {
+ const char path[], bool isFixedPitch)
+ : INHERITED(style, sysFont, familyMember, isFixedPitch) {
SkString fullpath;
if (sysFont) {
@@ -403,13 +403,13 @@ private:
static bool get_name_and_style(const char path[], SkString* name,
SkTypeface::Style* style,
- bool* isFixedWidth, bool isExpected) {
+ bool* isFixedPitch, bool isExpected) {
SkString fullpath;
GetFullPathForSysFonts(&fullpath, path);
SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(fullpath.c_str()));
if (stream.get()) {
- return find_name_and_attributes(stream, name, style, isFixedWidth);
+ return find_name_and_attributes(stream, name, style, isFixedPitch);
} else {
if (isExpected) {
SkDebugf("---- failed to open <%s> as a font", fullpath.c_str());
@@ -591,14 +591,14 @@ static void init_system_fonts() {
firstInFamily = NULL;
}
- bool isFixedWidth;
+ bool isFixedPitch;
SkString name;
SkTypeface::Style style;
// we expect all the fonts, except the "fallback" fonts
bool isExpected = (rec[i].fNames != gFBNames);
if (!get_name_and_style(rec[i].fFileName, &name, &style,
- &isFixedWidth, isExpected)) {
+ &isFixedPitch, isExpected)) {
// We need to increase gUniqueFontID here so that the unique id of
// each font matches its index in gSystemFonts array, as expected
// by find_uniqueID.
@@ -611,7 +611,7 @@ static void init_system_fonts() {
true, // system-font (cannot delete)
firstInFamily, // what family to join
rec[i].fFileName,
- isFixedWidth) // filename
+ isFixedPitch) // filename
);
#if SK_DEBUG_FONTS
SkDebugf("---- SkTypeface[%d] %s fontID %d",
@@ -698,11 +698,11 @@ static void reload_fallback_fonts() {
if (family->fFileNames[j]) {
// ensure the fallback font exists before adding it to the list
- bool isFixedWidth;
+ bool isFixedPitch;
SkString name;
SkTypeface::Style style;
if (!get_name_and_style(family->fFileNames[j], &name, &style,
- &isFixedWidth, false)) {
+ &isFixedPitch, false)) {
continue;
}
@@ -854,15 +854,15 @@ SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
return NULL;
}
- bool isFixedWidth;
+ bool isFixedPitch;
SkTypeface::Style style;
- if (find_name_and_attributes(stream, NULL, &style, &isFixedWidth)) {
+ if (find_name_and_attributes(stream, NULL, &style, &isFixedPitch)) {
SkAutoMutexAcquire ac(gFamilyHeadAndNameListMutex);
// Make sure system fonts are loaded to comply with the assumption of
// unique id offset by one in find_uniqueID.
load_system_fonts();
- return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream, isFixedWidth));
+ return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream, isFixedPitch));
} else {
return NULL;
}
diff --git a/src/ports/SkFontHost_linux.cpp b/src/ports/SkFontHost_linux.cpp
index f4b5e05065..3fdcf9833e 100644
--- a/src/ports/SkFontHost_linux.cpp
+++ b/src/ports/SkFontHost_linux.cpp
@@ -26,7 +26,7 @@
#endif
bool find_name_and_attributes(SkStream* stream, SkString* name,
- SkTypeface::Style* style, bool* isFixedWidth);
+ SkTypeface::Style* style, bool* isFixedPitch);
///////////////////////////////////////////////////////////////////////////////
@@ -231,8 +231,8 @@ static void remove_from_names(FamilyRec* emptyFamily) {
class FamilyTypeface : public SkTypeface_FreeType {
public:
- FamilyTypeface(Style style, bool sysFont, FamilyRec* family, bool isFixedWidth)
- : INHERITED(style, sk_atomic_inc(&gUniqueFontID) + 1, isFixedWidth) {
+ FamilyTypeface(Style style, bool sysFont, FamilyRec* family, bool isFixedPitch)
+ : INHERITED(style, sk_atomic_inc(&gUniqueFontID) + 1, isFixedPitch) {
fIsSysFont = sysFont;
SkAutoMutexAcquire ac(gFamilyMutex);
@@ -293,8 +293,8 @@ private:
class StreamTypeface : public FamilyTypeface {
public:
StreamTypeface(Style style, bool sysFont, FamilyRec* family,
- SkStream* stream, bool isFixedWidth)
- : INHERITED(style, sysFont, family, isFixedWidth) {
+ SkStream* stream, bool isFixedPitch)
+ : INHERITED(style, sysFont, family, isFixedPitch) {
stream->ref();
fStream = stream;
}
@@ -320,8 +320,8 @@ private:
class FileTypeface : public FamilyTypeface {
public:
FileTypeface(Style style, bool sysFont, FamilyRec* family,
- const char path[], bool isFixedWidth)
- : INHERITED(style, sysFont, family, isFixedWidth) {
+ const char path[], bool isFixedPitch)
+ : INHERITED(style, sysFont, family, isFixedPitch) {
fPath.set(path);
}
@@ -349,10 +349,10 @@ private:
///////////////////////////////////////////////////////////////////////////////
static bool get_name_and_style(const char path[], SkString* name,
- SkTypeface::Style* style, bool* isFixedWidth) {
+ SkTypeface::Style* style, bool* isFixedPitch) {
SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path));
if (stream.get()) {
- return find_name_and_attributes(stream, name, style, isFixedWidth);
+ return find_name_and_attributes(stream, name, style, isFixedPitch);
} else {
SkDebugf("---- failed to open <%s> as a font\n", path);
return false;
@@ -372,11 +372,11 @@ static void load_directory_fonts(const SkString& directory, unsigned int* count)
SkString filename(directory);
filename.append(name);
- bool isFixedWidth;
+ bool isFixedPitch;
SkString realname;
SkTypeface::Style style = SkTypeface::kNormal; // avoid uninitialized warning
- if (!get_name_and_style(filename.c_str(), &realname, &style, &isFixedWidth)) {
+ if (!get_name_and_style(filename.c_str(), &realname, &style, &isFixedPitch)) {
SkDebugf("------ can't load <%s> as a font\n", filename.c_str());
continue;
}
@@ -392,7 +392,7 @@ static void load_directory_fonts(const SkString& directory, unsigned int* count)
true, // system-font (cannot delete)
family, // what family to join
filename.c_str(),
- isFixedWidth) // filename
+ isFixedPitch) // filename
);
if (NULL == family) {
@@ -508,10 +508,10 @@ SkTypeface* SkFontHost::CreateTypefaceFromStream(SkStream* stream) {
return NULL;
}
- bool isFixedWidth;
+ bool isFixedPitch;
SkTypeface::Style style;
- if (find_name_and_attributes(stream, NULL, &style, &isFixedWidth)) {
- return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream, isFixedWidth));
+ if (find_name_and_attributes(stream, NULL, &style, &isFixedPitch)) {
+ return SkNEW_ARGS(StreamTypeface, (style, false, NULL, stream, isFixedPitch));
} else {
return NULL;
}
diff --git a/src/ports/SkFontHost_mac.cpp b/src/ports/SkFontHost_mac.cpp
index b2ebfe47f4..1f13748231 100755
--- a/src/ports/SkFontHost_mac.cpp
+++ b/src/ports/SkFontHost_mac.cpp
@@ -350,7 +350,7 @@ Offscreen::Offscreen() : fRGBSpace(NULL), fCG(NULL) {
///////////////////////////////////////////////////////////////////////////////
-static SkTypeface::Style computeStyleBits(CTFontRef font, bool* isMonospace) {
+static SkTypeface::Style computeStyleBits(CTFontRef font, bool* isFixedPitch) {
unsigned style = SkTypeface::kNormal;
CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(font);
@@ -360,8 +360,8 @@ static SkTypeface::Style computeStyleBits(CTFontRef font, bool* isMonospace) {
if (traits & kCTFontItalicTrait) {
style |= SkTypeface::kItalic;
}
- if (isMonospace) {
- *isMonospace = (traits & kCTFontMonoSpaceTrait) != 0;
+ if (isFixedPitch) {
+ *isFixedPitch = (traits & kCTFontMonoSpaceTrait) != 0;
}
return (SkTypeface::Style)style;
}
@@ -396,9 +396,9 @@ static SkFontID CTFontRef_to_SkFontID(CTFontRef fontRef) {
class SkTypeface_Mac : public SkTypeface {
public:
- SkTypeface_Mac(SkTypeface::Style style, SkFontID fontID, bool isMonospace,
+ SkTypeface_Mac(SkTypeface::Style style, SkFontID fontID, bool isFixedPitch,
CTFontRef fontRef, const char name[])
- : SkTypeface(style, fontID, isMonospace)
+ : SkTypeface(style, fontID, isFixedPitch)
, fName(name)
, fFontRef(fontRef) // caller has already called CFRetain for us
{
@@ -429,11 +429,11 @@ private:
static SkTypeface* NewFromFontRef(CTFontRef fontRef, const char name[]) {
SkASSERT(fontRef);
- bool isMonospace;
- SkTypeface::Style style = computeStyleBits(fontRef, &isMonospace);
+ bool isFixedPitch;
+ SkTypeface::Style style = computeStyleBits(fontRef, &isFixedPitch);
SkFontID fontID = CTFontRef_to_SkFontID(fontRef);
- return new SkTypeface_Mac(style, fontID, isMonospace, fontRef, name);
+ return new SkTypeface_Mac(style, fontID, isFixedPitch, fontRef, name);
}
static SkTypeface* NewFromName(const char familyName[], SkTypeface::Style theStyle) {
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index 23a317de53..3c585e8827 100755
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -189,6 +189,9 @@ public:
::DeleteObject(font);
}
+ // The fixed pitch bit is set if the font is *not* fixed pitch.
+ this->setIsFixedPitch((textMetric.tmPitchAndFamily & TMPF_FIXED_PITCH) == 0);
+
// Used a logfont on a memory context, should never get a device font.
// Therefore all TMPF_DEVICE will be PostScript (cubic) fonts.
fCanBeLCD = !((textMetric.tmPitchAndFamily & TMPF_VECTOR) &&