OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkAdvancedTypefaceMetrics.h" | 9 #include "SkAdvancedTypefaceMetrics.h" |
10 #include "SkBase64.h" | 10 #include "SkBase64.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 | 183 |
184 LOGFONT fLogFont; | 184 LOGFONT fLogFont; |
185 bool fSerializeAsStream; | 185 bool fSerializeAsStream; |
186 bool fCanBeLCD; | 186 bool fCanBeLCD; |
187 | 187 |
188 static LogFontTypeface* Create(const LOGFONT& lf) { | 188 static LogFontTypeface* Create(const LOGFONT& lf) { |
189 SkTypeface::Style style = get_style(lf); | 189 SkTypeface::Style style = get_style(lf); |
190 SkFontID fontID = SkTypefaceCache::NewFontID(); | 190 SkFontID fontID = SkTypefaceCache::NewFontID(); |
191 return new LogFontTypeface(style, fontID, lf); | 191 return new LogFontTypeface(style, fontID, lf); |
192 } | 192 } |
193 | |
194 protected: | |
195 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor*) cons t SK_OVERRIDE; | |
196 virtual void onFilterRec(SkScalerContextRec*) const SK_OVERRIDE; | |
193 }; | 197 }; |
194 | 198 |
195 class FontMemResourceTypeface : public LogFontTypeface { | 199 class FontMemResourceTypeface : public LogFontTypeface { |
196 public: | 200 public: |
197 /** | 201 /** |
198 * Takes ownership of fontMemResource. | 202 * Takes ownership of fontMemResource. |
199 */ | 203 */ |
200 FontMemResourceTypeface(SkTypeface::Style style, SkFontID fontID, const LOGF ONT& lf, HANDLE fontMemResource) : | 204 FontMemResourceTypeface(SkTypeface::Style style, SkFontID fontID, const LOGF ONT& lf, HANDLE fontMemResource) : |
201 LogFontTypeface(style, fontID, lf, true), fFontMemResource(fontMemResour ce) { | 205 LogFontTypeface(style, fontID, lf, true), fFontMemResource(fontMemResour ce) { |
202 } | 206 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 * This guy is public | 271 * This guy is public |
268 */ | 272 */ |
269 void SkLOGFONTFromTypeface(const SkTypeface* face, LOGFONT* lf) { | 273 void SkLOGFONTFromTypeface(const SkTypeface* face, LOGFONT* lf) { |
270 if (NULL == face) { | 274 if (NULL == face) { |
271 *lf = get_default_font(); | 275 *lf = get_default_font(); |
272 } else { | 276 } else { |
273 *lf = static_cast<const LogFontTypeface*>(face)->fLogFont; | 277 *lf = static_cast<const LogFontTypeface*>(face)->fLogFont; |
274 } | 278 } |
275 } | 279 } |
276 | 280 |
277 SkFontID SkFontHost::NextLogicalFont(SkFontID currFontID, SkFontID origFontID) { | 281 SkTypeface* SkFontHost::NextLogicalTypeface(SkFontID currFontID, SkFontID origFo ntID) { |
278 // Zero means that we don't have any fallback fonts for this fontID. | 282 // Zero means that we don't have any fallback fonts for this fontID. |
279 // This function is implemented on Android, but doesn't have much | 283 // This function is implemented on Android, but doesn't have much |
280 // meaning here. | 284 // meaning here. |
281 return 0; | 285 return NULL; |
282 } | 286 } |
283 | 287 |
284 static void ensure_typeface_accessible(SkFontID fontID) { | 288 static void ensure_typeface_accessible(SkFontID fontID) { |
285 LogFontTypeface* face = static_cast<LogFontTypeface*>(SkTypefaceCache::FindB yID(fontID)); | 289 LogFontTypeface* face = static_cast<LogFontTypeface*>(SkTypefaceCache::FindB yID(fontID)); |
286 if (face) { | 290 if (face) { |
287 SkFontHost::EnsureTypefaceAccessible(*face); | 291 SkFontHost::EnsureTypefaceAccessible(*face); |
288 } | 292 } |
289 } | 293 } |
290 | 294 |
291 static void GetLogFontByID(SkFontID fontID, LOGFONT* lf) { | 295 static void GetLogFontByID(SkFontID fontID, LOGFONT* lf) { |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 } | 478 } |
475 *srcRBPtr = srcRB; | 479 *srcRBPtr = srcRB; |
476 // offset to the start of the image | 480 // offset to the start of the image |
477 return (const char*)fBits + (fHeight - glyph.fHeight) * srcRB; | 481 return (const char*)fBits + (fHeight - glyph.fHeight) * srcRB; |
478 } | 482 } |
479 | 483 |
480 ////////////////////////////////////////////////////////////////////////////// | 484 ////////////////////////////////////////////////////////////////////////////// |
481 | 485 |
482 class SkScalerContext_Windows : public SkScalerContext { | 486 class SkScalerContext_Windows : public SkScalerContext { |
483 public: | 487 public: |
484 SkScalerContext_Windows(const SkDescriptor* desc); | 488 SkScalerContext_Windows(SkTypeface*, const SkDescriptor* desc); |
485 virtual ~SkScalerContext_Windows(); | 489 virtual ~SkScalerContext_Windows(); |
486 | 490 |
487 protected: | 491 protected: |
488 virtual unsigned generateGlyphCount() SK_OVERRIDE; | 492 virtual unsigned generateGlyphCount() SK_OVERRIDE; |
489 virtual uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE; | 493 virtual uint16_t generateCharToGlyph(SkUnichar uni) SK_OVERRIDE; |
490 virtual void generateAdvance(SkGlyph* glyph) SK_OVERRIDE; | 494 virtual void generateAdvance(SkGlyph* glyph) SK_OVERRIDE; |
491 virtual void generateMetrics(SkGlyph* glyph) SK_OVERRIDE; | 495 virtual void generateMetrics(SkGlyph* glyph) SK_OVERRIDE; |
492 virtual void generateImage(const SkGlyph& glyph) SK_OVERRIDE; | 496 virtual void generateImage(const SkGlyph& glyph) SK_OVERRIDE; |
493 virtual void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE; | 497 virtual void generatePath(const SkGlyph& glyph, SkPath* path) SK_OVERRIDE; |
494 virtual void generateFontMetrics(SkPaint::FontMetrics* mX, | 498 virtual void generateFontMetrics(SkPaint::FontMetrics* mX, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
542 return CLEARTYPE_QUALITY; | 546 return CLEARTYPE_QUALITY; |
543 default: | 547 default: |
544 if (rec.fFlags & SkScalerContext::kGenA8FromLCD_Flag) { | 548 if (rec.fFlags & SkScalerContext::kGenA8FromLCD_Flag) { |
545 return CLEARTYPE_QUALITY; | 549 return CLEARTYPE_QUALITY; |
546 } else { | 550 } else { |
547 return ANTIALIASED_QUALITY; | 551 return ANTIALIASED_QUALITY; |
548 } | 552 } |
549 } | 553 } |
550 } | 554 } |
551 | 555 |
552 SkScalerContext_Windows::SkScalerContext_Windows(const SkDescriptor* desc) | 556 SkScalerContext_Windows::SkScalerContext_Windows(SkTypeface* typeface, |
553 : SkScalerContext(desc), fDDC(0), fFont(0), fSavefont(0), fSC(0) | 557 » const SkDescriptor* desc) |
bungeman-skia
2013/03/15 16:12:44
A tab??
| |
558 : SkScalerContext(typeface, desc), fDDC(0), fFont(0), fSavefont(0), fSC( 0) | |
554 , fGlyphCount(-1) { | 559 , fGlyphCount(-1) { |
555 SkAutoMutexAcquire ac(gFTMutex); | 560 SkAutoMutexAcquire ac(gFTMutex); |
556 | 561 |
557 fDDC = ::CreateCompatibleDC(NULL); | 562 fDDC = ::CreateCompatibleDC(NULL); |
558 SetGraphicsMode(fDDC, GM_ADVANCED); | 563 SetGraphicsMode(fDDC, GM_ADVANCED); |
559 SetBkMode(fDDC, TRANSPARENT); | 564 SetBkMode(fDDC, TRANSPARENT); |
560 | 565 |
561 // Scaling by the DPI is inconsistent with how Skia draws elsewhere | 566 // Scaling by the DPI is inconsistent with how Skia draws elsewhere |
562 //SkScalar height = -(fRec.fTextSize * GetDeviceCaps(ddc, LOGPIXELSY) / 72); | 567 //SkScalar height = -(fRec.fTextSize * GetDeviceCaps(ddc, LOGPIXELSY) / 72); |
563 LOGFONT lf; | 568 LOGFONT lf; |
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1601 DeleteObject(font); | 1606 DeleteObject(font); |
1602 DeleteDC(hdc); | 1607 DeleteDC(hdc); |
1603 | 1608 |
1604 return stream; | 1609 return stream; |
1605 } | 1610 } |
1606 | 1611 |
1607 size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length, int3 2_t* index) { | 1612 size_t SkFontHost::GetFileName(SkFontID fontID, char path[], size_t length, int3 2_t* index) { |
1608 return 0; | 1613 return 0; |
1609 } | 1614 } |
1610 | 1615 |
1611 SkScalerContext* SkFontHost::CreateScalerContext(const SkDescriptor* desc) { | 1616 SkScalerContext* LogFontTypeface::onCreateScalerContext(const SkDescriptor* desc ) const { |
1612 return SkNEW_ARGS(SkScalerContext_Windows, (desc)); | 1617 return SkNEW_ARGS(SkScalerContext_Windows, (const_cast<LogFontTypeface*>(thi s), desc)); |
1613 } | 1618 } |
1614 | 1619 |
1615 /** Return the closest matching typeface given either an existing family | 1620 /** Return the closest matching typeface given either an existing family |
1616 (specified by a typeface in that family) or by a familyName, and a | 1621 (specified by a typeface in that family) or by a familyName, and a |
1617 requested style. | 1622 requested style. |
1618 1) If familyFace is null, use familyName. | 1623 1) If familyFace is null, use familyName. |
1619 2) If familyName is null, use familyFace. | 1624 2) If familyName is null, use familyFace. |
1620 3) If both are null, return the default font that best matches style | 1625 3) If both are null, return the default font that best matches style |
1621 This MUST not return NULL. | 1626 This MUST not return NULL. |
1622 */ | 1627 */ |
(...skipping 17 matching lines...) Expand all Loading... | |
1640 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { | 1645 SkTypeface* SkFontHost::CreateTypefaceFromFile(const char path[]) { |
1641 SkTypeface* face = NULL; | 1646 SkTypeface* face = NULL; |
1642 SkAutoTUnref<SkFILEStream> stream(SkNEW_ARGS(SkFILEStream, (path))); | 1647 SkAutoTUnref<SkFILEStream> stream(SkNEW_ARGS(SkFILEStream, (path))); |
1643 | 1648 |
1644 if (stream->isValid()) { | 1649 if (stream->isValid()) { |
1645 face = CreateTypefaceFromStream(stream); | 1650 face = CreateTypefaceFromStream(stream); |
1646 } | 1651 } |
1647 return face; | 1652 return face; |
1648 } | 1653 } |
1649 | 1654 |
1650 void SkFontHost::FilterRec(SkScalerContext::Rec* rec, SkTypeface* typeface) { | 1655 void LogFontTypeface::onFilterRec(SkScalerContextRec* rec) const { |
1651 unsigned flagsWeDontSupport = SkScalerContext::kDevKernText_Flag | | 1656 unsigned flagsWeDontSupport = SkScalerContext::kDevKernText_Flag | |
1652 SkScalerContext::kAutohinting_Flag | | 1657 SkScalerContext::kAutohinting_Flag | |
1653 SkScalerContext::kEmbeddedBitmapText_Flag | | 1658 SkScalerContext::kEmbeddedBitmapText_Flag | |
1654 SkScalerContext::kEmbolden_Flag | | 1659 SkScalerContext::kEmbolden_Flag | |
1655 SkScalerContext::kSubpixelPositioning_Flag | | 1660 SkScalerContext::kSubpixelPositioning_Flag | |
1656 SkScalerContext::kLCD_BGROrder_Flag | | 1661 SkScalerContext::kLCD_BGROrder_Flag | |
1657 SkScalerContext::kLCD_Vertical_Flag; | 1662 SkScalerContext::kLCD_Vertical_Flag; |
1658 rec->fFlags &= ~flagsWeDontSupport; | 1663 rec->fFlags &= ~flagsWeDontSupport; |
1659 | 1664 |
1660 SkPaint::Hinting h = rec->getHinting(); | 1665 SkPaint::Hinting h = rec->getHinting(); |
(...skipping 19 matching lines...) Expand all Loading... | |
1680 rec->setHinting(h); | 1685 rec->setHinting(h); |
1681 | 1686 |
1682 // turn this off since GDI might turn A8 into BW! Need a bigger fix. | 1687 // turn this off since GDI might turn A8 into BW! Need a bigger fix. |
1683 #if 0 | 1688 #if 0 |
1684 // Disable LCD when rotated, since GDI's output is ugly | 1689 // Disable LCD when rotated, since GDI's output is ugly |
1685 if (isLCD(*rec) && !isAxisAligned(*rec)) { | 1690 if (isLCD(*rec) && !isAxisAligned(*rec)) { |
1686 rec->fMaskFormat = SkMask::kA8_Format; | 1691 rec->fMaskFormat = SkMask::kA8_Format; |
1687 } | 1692 } |
1688 #endif | 1693 #endif |
1689 | 1694 |
1690 LogFontTypeface* logfontTypeface = static_cast<LogFontTypeface*>(typeface); | 1695 if (!fCanBeLCD && isLCD(*rec)) { |
1691 if (!logfontTypeface->fCanBeLCD && isLCD(*rec)) { | |
1692 rec->fMaskFormat = SkMask::kA8_Format; | 1696 rec->fMaskFormat = SkMask::kA8_Format; |
1693 rec->fFlags &= ~SkScalerContext::kGenA8FromLCD_Flag; | 1697 rec->fFlags &= ~SkScalerContext::kGenA8FromLCD_Flag; |
1694 } | 1698 } |
1695 } | 1699 } |
OLD | NEW |