OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/common/badge_util.h" | 5 #include "chrome/common/badge_util.h" |
6 | 6 |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "gfx/canvas_skia.h" | 9 #include "gfx/canvas_skia.h" |
10 #include "gfx/font.h" | 10 #include "gfx/font.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 if (typeface) { | 33 if (typeface) { |
34 text_paint->setFakeBoldText(true); | 34 text_paint->setFakeBoldText(true); |
35 } else { | 35 } else { |
36 // Fall back to the system font. We don't bold it because we aren't sure | 36 // Fall back to the system font. We don't bold it because we aren't sure |
37 // how it will look. | 37 // how it will look. |
38 // For the most part this code path will only be hit on Linux systems | 38 // For the most part this code path will only be hit on Linux systems |
39 // that don't have Arial. | 39 // that don't have Arial. |
40 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 40 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
41 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); | 41 const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont); |
42 typeface = SkTypeface::CreateFromName( | 42 typeface = SkTypeface::CreateFromName( |
43 WideToUTF8(base_font.GetFontName()).c_str(), SkTypeface::kNormal); | 43 UTF16ToUTF8(base_font.GetFontName()).c_str(), SkTypeface::kNormal); |
44 } | 44 } |
45 | 45 |
46 text_paint->setTypeface(typeface); | 46 text_paint->setTypeface(typeface); |
47 // |text_paint| adds its own ref. Release the ref from CreateFontName. | 47 // |text_paint| adds its own ref. Release the ref from CreateFontName. |
48 typeface->unref(); | 48 typeface->unref(); |
49 } | 49 } |
50 return text_paint; | 50 return text_paint; |
51 } | 51 } |
52 | 52 |
53 SkBitmap DrawBadgeIconOverlay(const SkBitmap& icon, | 53 SkBitmap DrawBadgeIconOverlay(const SkBitmap& icon, |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // add 'font_size - 1' to the height. | 90 // add 'font_size - 1' to the height. |
91 SkScalar x = (badge_width - text_width)/2; | 91 SkScalar x = (badge_width - text_width)/2; |
92 SkScalar y = (icon.height() - font_size)/2 + font_size - 1; | 92 SkScalar y = (icon.height() - font_size)/2 + font_size - 1; |
93 canvas->drawText(badge_text.c_str(), badge_text.size(), x, y, *paint); | 93 canvas->drawText(badge_text.c_str(), badge_text.size(), x, y, *paint); |
94 | 94 |
95 // Return the generated image. | 95 // Return the generated image. |
96 return canvas->ExtractBitmap(); | 96 return canvas->ExtractBitmap(); |
97 } | 97 } |
98 | 98 |
99 } // namespace badge_util | 99 } // namespace badge_util |
OLD | NEW |