Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: Source/platform/fonts/skia/FontCustomPlatformDataSkia.cpp

Issue 135903012: Fix synthetic bold/italic for webfonts on windows (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/fast/text/webfont-synthetic-bold.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Computer, Inc. 2 * Copyright (C) 2007 Apple Computer, Inc.
3 * Copyright (c) 2007, 2008, 2009, Google Inc. All rights reserved. 3 * Copyright (c) 2007, 2008, 2009, Google Inc. All rights reserved.
4 * Copyright (C) 2010 Company 100, Inc. 4 * Copyright (C) 2010 Company 100, Inc.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 { 49 {
50 } 50 }
51 51
52 FontCustomPlatformData::~FontCustomPlatformData() 52 FontCustomPlatformData::~FontCustomPlatformData()
53 { 53 {
54 } 54 }
55 55
56 FontPlatformData FontCustomPlatformData::fontPlatformData(float size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant) 56 FontPlatformData FontCustomPlatformData::fontPlatformData(float size, bool bold, bool italic, FontOrientation orientation, FontWidthVariant)
57 { 57 {
58 ASSERT(m_typeface); 58 ASSERT(m_typeface);
59 #if OS(WIN)
60 // FIXME: Skia currently renders synthetic bold and italics with hinting and without
61 // linear metrics on windows. Using CreateFromName and specifying the bold/i talics
62 // style allows for proper rendering of synthetic style. Once Skia has been updated
63 // this workaround will no longer be needed. crbug.com/332958
64 bool syntheticBold = bold && !m_typeface->isBold();
65 bool syntheticItalic = italic && !m_typeface->isItalic();
66 if (syntheticBold || syntheticItalic) {
67 SkString name;
68 m_typeface->getFamilyName(&name);
69
70 int style = SkTypeface::kNormal;
71 if (syntheticBold)
72 style |= SkTypeface::kBold;
73 if (syntheticItalic)
74 style |= SkTypeface::kItalic;
75
76 RefPtr<SkTypeface> typeface = adoptRef(SkTypeface::CreateFromName(name.c _str(), static_cast<SkTypeface::Style>(style)));
77 syntheticBold = false;
78 syntheticItalic = false;
79 return FontPlatformData(typeface.release(), "", size, syntheticBold, syn theticItalic, orientation);
80 }
81 #endif
59 return FontPlatformData(m_typeface.get(), "", size, bold && !m_typeface->isB old(), italic && !m_typeface->isItalic(), orientation); 82 return FontPlatformData(m_typeface.get(), "", size, bold && !m_typeface->isB old(), italic && !m_typeface->isItalic(), orientation);
60 } 83 }
61 84
62 PassOwnPtr<FontCustomPlatformData> FontCustomPlatformData::create(SharedBuffer* buffer) 85 PassOwnPtr<FontCustomPlatformData> FontCustomPlatformData::create(SharedBuffer* buffer)
63 { 86 {
64 ASSERT_ARG(buffer, buffer); 87 ASSERT_ARG(buffer, buffer);
65 88
66 OpenTypeSanitizer sanitizer(buffer); 89 OpenTypeSanitizer sanitizer(buffer);
67 RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize(); 90 RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize();
68 if (!transcodeBuffer) 91 if (!transcodeBuffer)
(...skipping 11 matching lines...) Expand all
80 103
81 return adoptPtr(new FontCustomPlatformData(typeface.release())); 104 return adoptPtr(new FontCustomPlatformData(typeface.release()));
82 } 105 }
83 106
84 bool FontCustomPlatformData::supportsFormat(const String& format) 107 bool FontCustomPlatformData::supportsFormat(const String& format)
85 { 108 {
86 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o pentype") || OpenTypeSanitizer::supportsFormat(format); 109 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o pentype") || OpenTypeSanitizer::supportsFormat(format);
87 } 110 }
88 111
89 } 112 }
OLDNEW
« no previous file with comments | « LayoutTests/fast/text/webfont-synthetic-bold.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698