summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/skia/src/ports/SkFontHost_mac.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/skia/src/ports/SkFontHost_mac.cpp')
-rwxr-xr-xchromium/third_party/skia/src/ports/SkFontHost_mac.cpp75
1 files changed, 34 insertions, 41 deletions
diff --git a/chromium/third_party/skia/src/ports/SkFontHost_mac.cpp b/chromium/third_party/skia/src/ports/SkFontHost_mac.cpp
index fe3fd069817..e00b87b59b4 100755
--- a/chromium/third_party/skia/src/ports/SkFontHost_mac.cpp
+++ b/chromium/third_party/skia/src/ports/SkFontHost_mac.cpp
@@ -149,7 +149,7 @@ static CGFloat CGRectGetWidth_inline(const CGRect& rect) {
///////////////////////////////////////////////////////////////////////////////
static void sk_memset_rect32(uint32_t* ptr, uint32_t value,
- size_t width, size_t height, size_t rowBytes) {
+ int width, int height, size_t rowBytes) {
SkASSERT(width);
SkASSERT(width * sizeof(uint32_t) <= rowBytes);
@@ -1379,6 +1379,11 @@ void SkScalerContext_Mac::generateFontMetrics(SkPaint::FontMetrics* mx,
theMetrics.fXMin = CGToScalar( CGRectGetMinX_inline(theBounds));
theMetrics.fXMax = CGToScalar( CGRectGetMaxX_inline(theBounds));
theMetrics.fXHeight = CGToScalar( CTFontGetXHeight(fCTFont));
+ theMetrics.fUnderlineThickness = CGToScalar( CTFontGetUnderlineThickness(fCTFont));
+ theMetrics.fUnderlinePosition = -CGToScalar( CTFontGetUnderlinePosition(fCTFont));
+
+ theMetrics.fFlags |= SkPaint::FontMetrics::kUnderlineThinknessIsValid_Flag;
+ theMetrics.fFlags |= SkPaint::FontMetrics::kUnderlinePositionIsValid_Flag;
if (mx != NULL) {
*mx = theMetrics;
@@ -1441,7 +1446,7 @@ static SkTypeface* create_from_dataProvider(CGDataProviderRef provider) {
// so the performance impact isn't too bad.
static void populate_glyph_to_unicode_slow(CTFontRef ctFont, CFIndex glyphCount,
SkTDArray<SkUnichar>* glyphToUnicode) {
- glyphToUnicode->setCount(glyphCount);
+ glyphToUnicode->setCount(SkToInt(glyphCount));
SkUnichar* out = glyphToUnicode->begin();
sk_bzero(out, glyphCount * sizeof(SkUnichar));
UniChar unichar = 0;
@@ -1485,7 +1490,7 @@ static void populate_glyph_to_unicode(CTFontRef ctFont, CFIndex glyphCount,
length = 8192;
}
const UInt8* bits = CFDataGetBytePtr(bitmap);
- glyphToUnicode->setCount(glyphCount);
+ glyphToUnicode->setCount(SkToInt(glyphCount));
SkUnichar* out = glyphToUnicode->begin();
sk_bzero(out, glyphCount * sizeof(SkUnichar));
for (int i = 0; i < length; i++) {
@@ -1539,17 +1544,16 @@ SkAdvancedTypefaceMetrics* SkTypeface_Mac::onGetAdvancedTypefaceMetrics(
CFStringToSkString(fontName, &info->fFontName);
}
- info->fMultiMaster = false;
CFIndex glyphCount = CTFontGetGlyphCount(ctFont);
info->fLastGlyphID = SkToU16(glyphCount - 1);
info->fEmSize = CTFontGetUnitsPerEm(ctFont);
+ info->fFlags = SkAdvancedTypefaceMetrics::kEmpty_FontFlag;
+ info->fStyle = 0;
if (perGlyphInfo & SkAdvancedTypefaceMetrics::kToUnicode_PerGlyphInfo) {
populate_glyph_to_unicode(ctFont, glyphCount, &info->fGlyphToUnicode);
}
- info->fStyle = 0;
-
// If it's not a truetype font, mark it as 'other'. Assume that TrueType
// fonts always have both glyf and loca tables. At the least, this is what
// sfntly needs to subset the font. CTFontCopyAttribute() does not always
@@ -1613,10 +1617,7 @@ SkAdvancedTypefaceMetrics* SkTypeface_Mac::onGetAdvancedTypefaceMetrics(
}
}
- if (false) { // TODO: haven't figured out how to know if font is embeddable
- // (information is in the OS/2 table)
- info->fType = SkAdvancedTypefaceMetrics::kNotEmbeddable_Font;
- } else if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) {
+ if (perGlyphInfo & SkAdvancedTypefaceMetrics::kHAdvance_PerGlyphInfo) {
if (info->fStyle & SkAdvancedTypefaceMetrics::kFixedPitch_Style) {
skia_advanced_typeface_metrics_utils::appendRange(&info->fGlyphWidths, 0);
info->fGlyphWidths->fAdvance.append(1, &min_width);
@@ -1625,7 +1626,7 @@ SkAdvancedTypefaceMetrics* SkTypeface_Mac::onGetAdvancedTypefaceMetrics(
} else {
info->fGlyphWidths.reset(
skia_advanced_typeface_metrics_utils::getAdvanceData(ctFont.get(),
- glyphCount,
+ SkToInt(glyphCount),
glyphIDs,
glyphIDsCount,
&getWidthAdvance));
@@ -1724,8 +1725,8 @@ SkStream* SkTypeface_Mac::onOpenStream(int* ttcIndex) const {
entry->tag = SkEndian_SwapBE32(tableTags[tableIndex]);
entry->checksum = SkEndian_SwapBE32(SkOTUtils::CalcTableChecksum((SK_OT_ULONG*)dataPtr,
tableSize));
- entry->offset = SkEndian_SwapBE32(dataPtr - dataStart);
- entry->logicalLength = SkEndian_SwapBE32(tableSize);
+ entry->offset = SkEndian_SwapBE32(SkToU32(dataPtr - dataStart));
+ entry->logicalLength = SkEndian_SwapBE32(SkToU32(tableSize));
dataPtr += (tableSize + 3) & ~3;
++entry;
@@ -1785,7 +1786,7 @@ int SkTypeface_Mac::onGetTableTags(SkFontTableTag tags[]) const {
if (NULL == cfArray) {
return 0;
}
- int count = CFArrayGetCount(cfArray);
+ int count = SkToInt(CFArrayGetCount(cfArray));
if (tags) {
for (int i = 0; i < count; ++i) {
uintptr_t fontTag = reinterpret_cast<uintptr_t>(CFArrayGetValueAtIndex(cfArray, i));
@@ -1832,7 +1833,7 @@ void SkTypeface_Mac::onFilterRec(SkScalerContextRec* rec) const {
}
unsigned flagsWeDontSupport = SkScalerContext::kDevKernText_Flag |
- SkScalerContext::kAutohinting_Flag |
+ SkScalerContext::kForceAutohinting_Flag |
SkScalerContext::kLCD_BGROrder_Flag |
SkScalerContext::kLCD_Vertical_Flag;
@@ -1930,7 +1931,7 @@ int SkTypeface_Mac::onCharsToGlyphs(const void* chars, Encoding encoding,
SkUnichar uni = SkUTF8_NextUnichar(&utf8);
utf16 += SkUTF16_FromUnichar(uni, utf16);
}
- srcCount = utf16 - src;
+ srcCount = SkToInt(utf16 - src);
break;
}
case kUTF16_Encoding: {
@@ -1951,7 +1952,7 @@ int SkTypeface_Mac::onCharsToGlyphs(const void* chars, Encoding encoding,
for (int i = 0; i < glyphCount; ++i) {
utf16 += SkUTF16_FromUnichar(utf32[i], utf16);
}
- srcCount = utf16 - src;
+ srcCount = SkToInt(utf16 - src);
break;
}
}
@@ -1999,7 +2000,7 @@ int SkTypeface_Mac::onCharsToGlyphs(const void* chars, Encoding encoding,
}
int SkTypeface_Mac::onCountGlyphs() const {
- return CTFontGetGlyphCount(fFontRef);
+ return SkToInt(CTFontGetGlyphCount(fFontRef));
}
///////////////////////////////////////////////////////////////////////////////
@@ -2142,7 +2143,7 @@ public:
if (NULL == fArray) {
fArray = CFArrayCreate(NULL, NULL, 0, NULL);
}
- fCount = CFArrayGetCount(fArray);
+ fCount = SkToInt(CFArrayGetCount(fArray));
}
virtual ~SkFontStyleSet_Mac() {
@@ -2208,21 +2209,14 @@ private:
};
class SkFontMgr_Mac : public SkFontMgr {
- int fCount;
CFArrayRef fNames;
+ int fCount;
CFStringRef stringAt(int index) const {
SkASSERT((unsigned)index < (unsigned)fCount);
return (CFStringRef)CFArrayGetValueAtIndex(fNames, index);
}
- void lazyInit() {
- if (NULL == fNames) {
- fNames = SkCTFontManagerCopyAvailableFontFamilyNames();
- fCount = fNames ? CFArrayGetCount(fNames) : 0;
- }
- }
-
static SkFontStyleSet* CreateSet(CFStringRef cfFamilyName) {
AutoCFRelease<CFMutableDictionaryRef> cfAttr(
CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
@@ -2237,20 +2231,20 @@ class SkFontMgr_Mac : public SkFontMgr {
}
public:
- SkFontMgr_Mac() : fCount(0), fNames(NULL) {}
+ SkFontMgr_Mac()
+ : fNames(SkCTFontManagerCopyAvailableFontFamilyNames())
+ , fCount(fNames ? SkToInt(CFArrayGetCount(fNames)) : 0) {}
virtual ~SkFontMgr_Mac() {
CFSafeRelease(fNames);
}
protected:
- virtual int onCountFamilies() SK_OVERRIDE {
- this->lazyInit();
+ virtual int onCountFamilies() const SK_OVERRIDE {
return fCount;
}
- virtual void onGetFamilyName(int index, SkString* familyName) SK_OVERRIDE {
- this->lazyInit();
+ virtual void onGetFamilyName(int index, SkString* familyName) const SK_OVERRIDE {
if ((unsigned)index < (unsigned)fCount) {
CFStringToSkString(this->stringAt(index), familyName);
} else {
@@ -2258,31 +2252,30 @@ protected:
}
}
- virtual SkFontStyleSet* onCreateStyleSet(int index) SK_OVERRIDE {
- this->lazyInit();
+ virtual SkFontStyleSet* onCreateStyleSet(int index) const SK_OVERRIDE {
if ((unsigned)index >= (unsigned)fCount) {
return NULL;
}
return CreateSet(this->stringAt(index));
}
- virtual SkFontStyleSet* onMatchFamily(const char familyName[]) SK_OVERRIDE {
+ virtual SkFontStyleSet* onMatchFamily(const char familyName[]) const SK_OVERRIDE {
AutoCFRelease<CFStringRef> cfName(make_CFString(familyName));
return CreateSet(cfName);
}
virtual SkTypeface* onMatchFamilyStyle(const char familyName[],
- const SkFontStyle&) SK_OVERRIDE {
+ const SkFontStyle&) const SK_OVERRIDE {
return NULL;
}
virtual SkTypeface* onMatchFaceStyle(const SkTypeface* familyMember,
- const SkFontStyle&) SK_OVERRIDE {
+ const SkFontStyle&) const SK_OVERRIDE {
return NULL;
}
virtual SkTypeface* onCreateFromData(SkData* data,
- int ttcIndex) SK_OVERRIDE {
+ int ttcIndex) const SK_OVERRIDE {
AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromData(data));
if (NULL == pr) {
return NULL;
@@ -2291,7 +2284,7 @@ protected:
}
virtual SkTypeface* onCreateFromStream(SkStream* stream,
- int ttcIndex) SK_OVERRIDE {
+ int ttcIndex) const SK_OVERRIDE {
AutoCFRelease<CGDataProviderRef> pr(SkCreateDataProviderFromStream(stream));
if (NULL == pr) {
return NULL;
@@ -2300,7 +2293,7 @@ protected:
}
virtual SkTypeface* onCreateFromFile(const char path[],
- int ttcIndex) SK_OVERRIDE {
+ int ttcIndex) const SK_OVERRIDE {
AutoCFRelease<CGDataProviderRef> pr(CGDataProviderCreateWithFilename(path));
if (NULL == pr) {
return NULL;
@@ -2309,7 +2302,7 @@ protected:
}
virtual SkTypeface* onLegacyCreateTypeface(const char familyName[],
- unsigned styleBits) SK_OVERRIDE {
+ unsigned styleBits) const SK_OVERRIDE {
return create_typeface(NULL, familyName, (SkTypeface::Style)styleBits);
}
};