| Index: src/ports/SkFontHost_win.cpp
|
| diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
|
| index 348246b89329d49fb481aafe9365ecd1139f1cdc..1290c007a5fd5217d20f4d9fc31ee55d53d3e423 100755
|
| --- a/src/ports/SkFontHost_win.cpp
|
| +++ b/src/ports/SkFontHost_win.cpp
|
| @@ -126,10 +126,20 @@
|
| // lf->lfClipPrecision = 64;
|
| }
|
|
|
| -static SkFontStyle get_style(const LOGFONT& lf) {
|
| - return SkFontStyle(lf.lfWeight,
|
| - lf.lfWidth,
|
| - lf.lfItalic ? SkFontStyle::kItalic_Slant : SkFontStyle::kUpright_Slant);
|
| +static SkTypeface::Style get_style(const LOGFONT& lf) {
|
| + unsigned style = 0;
|
| + if (lf.lfWeight >= FW_BOLD) {
|
| + style |= SkTypeface::kBold;
|
| + }
|
| + if (lf.lfItalic) {
|
| + style |= SkTypeface::kItalic;
|
| + }
|
| + return static_cast<SkTypeface::Style>(style);
|
| +}
|
| +
|
| +static void setStyle(LOGFONT* lf, SkTypeface::Style style) {
|
| + lf->lfWeight = (style & SkTypeface::kBold) != 0 ? FW_BOLD : FW_NORMAL ;
|
| + lf->lfItalic = ((style & SkTypeface::kItalic) != 0);
|
| }
|
|
|
| static inline FIXED SkFixedToFIXED(SkFixed x) {
|
| @@ -207,11 +217,8 @@
|
|
|
| class LogFontTypeface : public SkTypeface {
|
| public:
|
| - LogFontTypeface(const SkFontStyle& style, const LOGFONT& lf, bool serializeAsStream)
|
| - : SkTypeface(style, SkTypefaceCache::NewFontID(), false)
|
| - , fLogFont(lf)
|
| - , fSerializeAsStream(serializeAsStream)
|
| - {
|
| + LogFontTypeface(SkTypeface::Style style, SkFontID fontID, const LOGFONT& lf, bool serializeAsStream = false) :
|
| + SkTypeface(style, fontID, false), fLogFont(lf), fSerializeAsStream(serializeAsStream) {
|
|
|
| // If the font has cubic outlines, it will not be rendered with ClearType.
|
| HFONT font = CreateFontIndirect(&lf);
|
| @@ -248,7 +255,9 @@
|
| bool fCanBeLCD;
|
|
|
| static LogFontTypeface* Create(const LOGFONT& lf) {
|
| - return new LogFontTypeface(get_style(lf), lf, false);
|
| + SkTypeface::Style style = get_style(lf);
|
| + SkFontID fontID = SkTypefaceCache::NewFontID();
|
| + return new LogFontTypeface(style, fontID, lf);
|
| }
|
|
|
| static void EnsureAccessible(const SkTypeface* face) {
|
| @@ -280,7 +289,9 @@
|
| * The created FontMemResourceTypeface takes ownership of fontMemResource.
|
| */
|
| static FontMemResourceTypeface* Create(const LOGFONT& lf, HANDLE fontMemResource) {
|
| - return new FontMemResourceTypeface(get_style(lf), lf, fontMemResource);
|
| + SkTypeface::Style style = get_style(lf);
|
| + SkFontID fontID = SkTypefaceCache::NewFontID();
|
| + return new FontMemResourceTypeface(style, fontID, lf, fontMemResource);
|
| }
|
|
|
| protected:
|
| @@ -294,9 +305,9 @@
|
| /**
|
| * Takes ownership of fontMemResource.
|
| */
|
| - FontMemResourceTypeface(const SkFontStyle& style, const LOGFONT& lf, HANDLE fontMemResource)
|
| - : LogFontTypeface(style, lf, true), fFontMemResource(fontMemResource)
|
| - { }
|
| + FontMemResourceTypeface(SkTypeface::Style style, SkFontID fontID, const LOGFONT& lf, HANDLE fontMemResource) :
|
| + LogFontTypeface(style, fontID, lf, true), fFontMemResource(fontMemResource) {
|
| + }
|
|
|
| HANDLE fFontMemResource;
|
|
|
| @@ -308,7 +319,7 @@
|
| return gDefaultFont;
|
| }
|
|
|
| -static bool FindByLogFont(SkTypeface* face, const SkFontStyle& requestedStyle, void* ctx) {
|
| +static bool FindByLogFont(SkTypeface* face, SkTypeface::Style requestedStyle, void* ctx) {
|
| LogFontTypeface* lface = static_cast<LogFontTypeface*>(face);
|
| const LOGFONT* lf = reinterpret_cast<const LOGFONT*>(ctx);
|
|
|
| @@ -2446,6 +2457,12 @@
|
| return 1; // non-zero means continue
|
| }
|
|
|
| +static SkFontStyle compute_fontstyle(const LOGFONT& lf) {
|
| + return SkFontStyle(lf.lfWeight, SkFontStyle::kNormal_Width,
|
| + lf.lfItalic ? SkFontStyle::kItalic_Slant
|
| + : SkFontStyle::kUpright_Slant);
|
| +}
|
| +
|
| class SkFontStyleSetGDI : public SkFontStyleSet {
|
| public:
|
| SkFontStyleSetGDI(const TCHAR familyName[]) {
|
| @@ -2465,7 +2482,7 @@
|
|
|
| virtual void getStyle(int index, SkFontStyle* fs, SkString* styleName) SK_OVERRIDE {
|
| if (fs) {
|
| - *fs = get_style(fArray[index].elfLogFont);
|
| + *fs = compute_fontstyle(fArray[index].elfLogFont);
|
| }
|
| if (styleName) {
|
| const ENUMLOGFONTEX& ref = fArray[index];
|
| @@ -2568,10 +2585,7 @@
|
| } else {
|
| logfont_for_name(familyName, &lf);
|
| }
|
| -
|
| - SkTypeface::Style style = (SkTypeface::Style)styleBits;
|
| - lf.lfWeight = (style & SkTypeface::kBold) != 0 ? FW_BOLD : FW_NORMAL;
|
| - lf.lfItalic = ((style & SkTypeface::kItalic) != 0);
|
| + setStyle(&lf, (SkTypeface::Style)styleBits);
|
| return SkCreateTypefaceFromLOGFONT(lf);
|
| }
|
|
|
|
|