Chromium Code Reviews| Index: chrome/renderer/print_web_view_helper.cc |
| diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc |
| index 499b1fd09270125e78d39fe1e8117b9f0dd49485..199ffce81ee4905f8892220e7040a6aacca7478b 100644 |
| --- a/chrome/renderer/print_web_view_helper.cc |
| +++ b/chrome/renderer/print_web_view_helper.cc |
| @@ -44,7 +44,6 @@ |
| #if defined(USE_SKIA) |
| #include "skia/ext/vector_canvas.h" |
| #include "skia/ext/vector_platform_device_skia.h" |
| -#include "third_party/skia/include/core/SkTypeface.h" |
| #elif defined(OS_MACOSX) |
| #include <CoreGraphics/CGContext.h> |
| @@ -224,17 +223,38 @@ void PrintHeaderFooterText( |
| printing::VerticalHeaderFooterPosition vertical_position, |
| double offset_to_baseline) { |
| #if defined(USE_SKIA) |
| - size_t text_byte_length = text.length() * sizeof(char16); |
| - double text_width_in_points = SkScalarToDouble(paint.measureText( |
| - text.c_str(), text_byte_length)); |
| - SkPoint point = GetHeaderFooterPosition(webkit_scale_factor, page_layout, |
| - horizontal_position, |
| - vertical_position, offset_to_baseline, |
| - text_width_in_points); |
| - paint.setTextSize(SkDoubleToScalar( |
| - paint.getTextSize() / webkit_scale_factor)); |
| - canvas->drawText(text.c_str(), text_byte_length, point.x(), point.y(), |
| - paint); |
| + // Convert text to glyphs first. |
| + std::vector<uint16_t> glyphs; |
|
jungshik at Google
2012/01/06 22:38:45
Just using an array of glyphs does not work well b
|
| + if (!PrintWebViewHelper::ConvertTextToGlyphs(paint.getTypeface(), |
| + text, &glyphs)) { |
| + // Conversion failed, fall back to draw text. |
| + size_t text_byte_length = text.length() * sizeof(char16); |
| + double text_width_in_points = SkScalarToDouble(paint.measureText( |
| + text.c_str(), text_byte_length)); |
| + SkPoint point = GetHeaderFooterPosition(webkit_scale_factor, page_layout, |
| + horizontal_position, |
| + vertical_position, |
| + offset_to_baseline, |
| + text_width_in_points); |
| + paint.setTextSize(SkDoubleToScalar( |
| + paint.getTextSize() / webkit_scale_factor)); |
| + canvas->drawText(text.c_str(), text_byte_length, point.x(), point.y(), |
| + paint); |
| + } else { |
| + paint.setTextEncoding(SkPaint::kGlyphID_TextEncoding); |
| + size_t glyphs_byte_length = glyphs.size() * sizeof(uint16_t); |
| + double text_width_in_points = SkScalarToDouble(paint.measureText( |
| + &glyphs[0], glyphs_byte_length)); |
| + SkPoint point = GetHeaderFooterPosition(webkit_scale_factor, page_layout, |
| + horizontal_position, |
| + vertical_position, |
| + offset_to_baseline, |
| + text_width_in_points); |
| + paint.setTextSize(SkDoubleToScalar( |
| + paint.getTextSize() / webkit_scale_factor)); |
| + canvas->drawText(&glyphs[0], glyphs_byte_length, point.x(), point.y(), |
| + paint); |
| + } |
| #elif defined(OS_MACOSX) |
| ScopedCFTypeRef<CFStringRef> cf_text(base::SysUTF16ToCFStringRef(text)); |
| ScopedCFTypeRef<CFAttributedStringRef> cf_attr_text( |