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

Unified Diff: skia/ext/vector_platform_device_linux.cc

Issue 196071: Embed fonts information into resulting PDF file for printing. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « printing/pdf_ps_metafile_linux.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: skia/ext/vector_platform_device_linux.cc
===================================================================
--- skia/ext/vector_platform_device_linux.cc (revision 25867)
+++ skia/ext/vector_platform_device_linux.cc (working copy)
@@ -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 @@
// Text color.
ApplyPaintColor(paint);
- const uint16_t* glyphIDs = static_cast<const uint16_t*>(text);
+ const uint16_t* glyph_ids = 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);
+ // 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 @@
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.);
« no previous file with comments | « printing/pdf_ps_metafile_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698