summaryrefslogtreecommitdiffstats
path: root/skia
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-11 14:19:53 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-11 14:19:53 +0000
commit923fa31b683d2c8059be7481695023348fba58e4 (patch)
treef475a47664c01dd9feb324920a0e7476f742564b /skia
parentc10cdbdd3201adf12e39b873d3075a879625e105 (diff)
downloadchromium_src-923fa31b683d2c8059be7481695023348fba58e4.zip
chromium_src-923fa31b683d2c8059be7481695023348fba58e4.tar.gz
chromium_src-923fa31b683d2c8059be7481695023348fba58e4.tar.bz2
Embed fonts information into resulting PDF file for printing.
BUG=9847 TEST=printing on linux should have right font in pdf Patch contributed by Min-Yu Huang <minyu.huang@gmail.com> Review URL: http://codereview.chromium.org/196071 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25974 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia')
-rw-r--r--skia/ext/vector_platform_device_linux.cc60
1 files changed, 43 insertions, 17 deletions
diff --git a/skia/ext/vector_platform_device_linux.cc b/skia/ext/vector_platform_device_linux.cc
index 3b30ddf..f0afbef 100644
--- a/skia/ext/vector_platform_device_linux.cc
+++ b/skia/ext/vector_platform_device_linux.cc
@@ -6,6 +6,7 @@
#include <cairo.h>
+#include "printing/pdf_ps_metafile_linux.h"
#include "third_party/skia/include/core/SkTypeface.h"
namespace skia {
@@ -258,20 +259,45 @@ void VectorPlatformDevice::drawPosText(const SkDraw& draw,
// Text color.
ApplyPaintColor(paint);
- const uint16_t* glyphIDs = static_cast<const uint16_t*>(text);
-
- // Draw each glyph by its path.
- for (size_t i = 0; i < len / sizeof(uint16_t); ++i) {
- uint16_t glyphID = glyphIDs[i];
- SkPath textPath;
- paint.getTextPath(&glyphID,
- sizeof(uint16_t),
- pos[i * scalarsPerPos],
- (scalarsPerPos == 1) ?
- constY :
- pos[i * scalarsPerPos + 1],
- &textPath);
- drawPath(draw, textPath, paint);
+ const uint16_t* glyph_ids = static_cast<const uint16_t*>(text);
+
+ // The style is either kFill_Style or kStroke_Style.
+ if (paint.getStyle() & SkPaint::kStroke_Style) {
+ ApplyStrokeStyle(paint);
+
+ // Draw each glyph by its path.
+ for (size_t i = 0; i < len / sizeof(uint16_t); ++i) {
+ uint16_t glyph_id = glyph_ids[i];
+ SkPath textPath;
+ paint.getTextPath(&glyph_id,
+ sizeof(uint16_t),
+ pos[i * scalarsPerPos],
+ (scalarsPerPos == 1) ?
+ constY :
+ pos[i * scalarsPerPos + 1],
+ &textPath);
+ drawPath(draw, textPath, paint);
+ }
+ } else { // kFill_Style.
+ // Selects correct font.
+ if (!printing::PdfPsMetafile::SelectFontById(
+ context_, paint.getTypeface()->uniqueID())) {
+ SkASSERT(false);
+ return;
+ }
+ cairo_set_font_size(context_, paint.getTextSize());
+
+ // Draw glyphs.
+ for (size_t i = 0; i < len / sizeof(uint16_t); ++i) {
+ uint16_t glyph_id = glyph_ids[i];
+
+ cairo_glyph_t glyph;
+ glyph.index = glyph_id;
+ glyph.x = pos[i * scalarsPerPos];
+ glyph.y = (scalarsPerPos == 1) ? constY : pos[i * scalarsPerPos + 1];
+
+ cairo_show_glyphs(context_, &glyph, 1);
+ }
}
}
@@ -440,9 +466,9 @@ void VectorPlatformDevice::InternalDrawBitmap(const SkBitmap& bitmap,
SkAutoLockPixels image_lock(bitmap);
cairo_surface_t* bitmap_surface =
- cairo_image_surface_create_for_data(
- reinterpret_cast<unsigned char*>(bitmap.getPixels()),
- CAIRO_FORMAT_ARGB32, src_size_x, src_size_y, bitmap.rowBytes());
+ cairo_image_surface_create_for_data(
+ reinterpret_cast<unsigned char*>(bitmap.getPixels()),
+ CAIRO_FORMAT_ARGB32, src_size_x, src_size_y, bitmap.rowBytes());
cairo_set_source_surface(context_, bitmap_surface, x, y);
cairo_paint_with_alpha(context_, static_cast<double>(alpha) / 255.);