| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "app/gfx/canvas.h" | 5 #include "app/gfx/canvas.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "app/gfx/font.h" | 9 #include "app/gfx/font.h" |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // DT_RTLREADING. | 99 // DT_RTLREADING. |
| 100 // | 100 // |
| 101 // This heuristic doesn't work for Chrome UI strings since even in RTL | 101 // This heuristic doesn't work for Chrome UI strings since even in RTL |
| 102 // locales, some of those might start with English text but we know they're | 102 // locales, some of those might start with English text but we know they're |
| 103 // localized so we always want them to be right aligned, and their | 103 // localized so we always want them to be right aligned, and their |
| 104 // directionality should be set as DT_RTLREADING. | 104 // directionality should be set as DT_RTLREADING. |
| 105 // | 105 // |
| 106 // Caveat: If the string is purely LTR, don't set DTL_RTLREADING since when | 106 // Caveat: If the string is purely LTR, don't set DTL_RTLREADING since when |
| 107 // the flag is set, LRE-PDF don't have the desired effect of rendering | 107 // the flag is set, LRE-PDF don't have the desired effect of rendering |
| 108 // multiline English-only text as LTR. | 108 // multiline English-only text as LTR. |
| 109 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT && | 109 // |
| 110 (f & DT_RIGHT)) { | 110 // Note that if the caller is explicitly requesting displaying the text |
| 111 if (l10n_util::StringContainsStrongRTLChars(text)) { | 111 // using RTL directionality then we respect that and pass DT_RTLREADING to |
| 112 f |= DT_RTLREADING; | 112 // ::DrawText even if the locale is LTR. |
| 113 } | 113 if ((flags & gfx::Canvas::FORCE_RTL_DIRECTIONALITY) || |
| 114 ((l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) && |
| 115 (f & DT_RIGHT) && l10n_util::StringContainsStrongRTLChars(text))) { |
| 116 f |= DT_RTLREADING; |
| 114 } | 117 } |
| 118 |
| 115 return f; | 119 return f; |
| 116 } | 120 } |
| 117 | 121 |
| 118 } // anonymous namespace | 122 } // anonymous namespace |
| 119 | 123 |
| 120 namespace gfx { | 124 namespace gfx { |
| 121 | 125 |
| 122 Canvas::Canvas(int width, int height, bool is_opaque) | 126 Canvas::Canvas(int width, int height, bool is_opaque) |
| 123 : skia::PlatformCanvas(width, height, is_opaque) { | 127 : skia::PlatformCanvas(width, height, is_opaque) { |
| 124 } | 128 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 text_row[cur_x] |= 0xff << SK_A32_SHIFT; // Make opaque. | 263 text_row[cur_x] |= 0xff << SK_A32_SHIFT; // Make opaque. |
| 260 } | 264 } |
| 261 } | 265 } |
| 262 } | 266 } |
| 263 | 267 |
| 264 // Draw the halo bitmap with blur. | 268 // Draw the halo bitmap with blur. |
| 265 drawBitmap(text_bitmap, SkIntToScalar(x - 1), SkIntToScalar(y - 1)); | 269 drawBitmap(text_bitmap, SkIntToScalar(x - 1), SkIntToScalar(y - 1)); |
| 266 } | 270 } |
| 267 | 271 |
| 268 } // namespace gfx | 272 } // namespace gfx |
| OLD | NEW |