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

Side by Side Diff: chrome/browser/ui/extensions/icon_with_badge_image_source.cc

Issue 1819753003: Allow various font weights in gfx. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac fixes Created 4 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/extensions/icon_with_badge_image_source.h" 5 #include "chrome/browser/ui/extensions/icon_with_badge_image_source.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #else 60 #else
61 const char kPreferredTypeface[] = "Arial"; 61 const char kPreferredTypeface[] = "Arial";
62 #endif 62 #endif
63 63
64 static SkPaint* text_paint = NULL; 64 static SkPaint* text_paint = NULL;
65 if (!text_paint) { 65 if (!text_paint) {
66 text_paint = new SkPaint; 66 text_paint = new SkPaint;
67 text_paint->setAntiAlias(true); 67 text_paint->setAntiAlias(true);
68 text_paint->setTextAlign(SkPaint::kLeft_Align); 68 text_paint->setTextAlign(SkPaint::kLeft_Align);
69 69
70 skia::RefPtr<SkTypeface> typeface = skia::AdoptRef( 70 skia::RefPtr<SkTypeface> typeface =
71 SkTypeface::CreateFromName(kPreferredTypeface, SkTypeface::kBold)); 71 skia::AdoptRef(SkTypeface::CreateFromName(
72 kPreferredTypeface, SkFontStyle(SkTypeface::kBold)));
72 // Skia doesn't do any font fallback---if the user is missing the font then 73 // Skia doesn't do any font fallback---if the user is missing the font then
73 // typeface will be NULL. If we don't do manual fallback then we'll crash. 74 // typeface will be NULL. If we don't do manual fallback then we'll crash.
74 if (typeface) { 75 if (typeface) {
75 text_paint->setFakeBoldText(true); 76 text_paint->setFakeBoldText(true);
76 } else { 77 } else {
77 // Fall back to the system font. We don't bold it because we aren't sure 78 // Fall back to the system font. We don't bold it because we aren't sure
78 // how it will look. 79 // how it will look.
79 // For the most part this code path will only be hit on Linux systems 80 // For the most part this code path will only be hit on Linux systems
80 // that don't have Arial. 81 // that don't have Arial.
81 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 82 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
82 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); 83 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont);
83 typeface = skia::AdoptRef(SkTypeface::CreateFromName( 84 typeface = skia::AdoptRef(SkTypeface::CreateFromName(
84 base_font.GetFontName().c_str(), SkTypeface::kNormal)); 85 base_font.GetFontName().c_str(), SkFontStyle()));
85 DCHECK(typeface); 86 DCHECK(typeface);
86 } 87 }
87 88
88 text_paint->setTypeface(typeface.get()); 89 text_paint->setTypeface(typeface.get());
89 // |text_paint| adds its own ref. Release the ref from CreateFontName. 90 // |text_paint| adds its own ref. Release the ref from CreateFontName.
90 } 91 }
91 return text_paint; 92 return text_paint;
92 } 93 }
93 94
94 gfx::ImageSkiaRep ScaleImageSkiaRep(const gfx::ImageSkiaRep& rep, 95 gfx::ImageSkiaRep ScaleImageSkiaRep(const gfx::ImageSkiaRep& rep,
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 } 290 }
290 291
291 void IconWithBadgeImageSource::PaintBlockedActionDecoration( 292 void IconWithBadgeImageSource::PaintBlockedActionDecoration(
292 gfx::Canvas* canvas) { 293 gfx::Canvas* canvas) {
293 canvas->Save(); 294 canvas->Save();
294 gfx::ImageSkia img = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 295 gfx::ImageSkia img = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
295 IDR_BLOCKED_EXTENSION_SCRIPT); 296 IDR_BLOCKED_EXTENSION_SCRIPT);
296 canvas->DrawImageInt(img, size().width() - img.width(), 0); 297 canvas->DrawImageInt(img, size().width() - img.width(), 0);
297 canvas->Restore(); 298 canvas->Restore();
298 } 299 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698