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

Unified Diff: skia/ext/vector_platform_device_emf_win.cc

Issue 11363008: Fix for 128506: Random Chinese/Japanese characters are missing in documents printed via the syst... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 2 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 | « skia/ext/skia_sandbox_support_win.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_emf_win.cc
===================================================================
--- skia/ext/vector_platform_device_emf_win.cc (revision 158204)
+++ skia/ext/vector_platform_device_emf_win.cc (working copy)
@@ -2,12 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "skia/ext/vector_platform_device_emf_win.h"
+
+#include <string>
vandebo (ex-Chrome) 2012/11/01 20:24:23 nit: string goes in second 3, and windows.h goes i
#include <windows.h>
-#include "skia/ext/vector_platform_device_emf_win.h"
-
+#include "base/logging.h"
#include "skia/ext/bitmap_platform_device.h"
#include "skia/ext/skia_utils_win.h"
+#include "third_party/skia/include/core/SkFontHost.h"
#include "third_party/skia/include/core/SkPathEffect.h"
#include "third_party/skia/include/core/SkTemplates.h"
#include "third_party/skia/include/core/SkUtils.h"
@@ -366,6 +369,31 @@
}
}
+bool EnsureExtTextOut(HDC hdc, int x, int y, UINT options, const RECT * lprect,
vandebo (ex-Chrome) 2012/11/01 20:24:23 lprect is always passed in as 0, omit it from this
+ LPCWSTR text, unsigned int characters, const int * lpDx,
+ SkTypeface* const typeface) {
+ bool success = ExtTextOut(hdc, x, y, options, lprect, text, characters, lpDx);
+ if (!success) {
+ if (typeface) {
+ SkFontHost::EnsureTypefaceCharactersAccessible(*typeface,
vandebo (ex-Chrome) 2012/11/01 20:24:23 Maybe this should return a bool. If it didn't do
+ text,
+ characters);
+ success = ExtTextOut(hdc, x, y, options, lprect, text, characters, lpDx);
+ if (!success) {
+ LOGFONT lf;
+ SkLOGFONTFromTypeface(typeface, &lf);
+ VLOG(1) << "SkFontHost::EnsureTypefaceCharactersAccessible FAILED for "
+ << " FaceName = " << lf.lfFaceName
+ << " and characters: " << std::wstring(text, characters);
+ }
+ } else {
+ VLOG(1) << "ExtTextOut FAILED for default FaceName "
+ << " and characters: " << std::wstring(text, characters);
+ }
+ }
+ return success;
+}
+
void VectorPlatformDeviceEmf::drawText(const SkDraw& draw,
const void* text,
size_t byteLength,
@@ -373,13 +401,19 @@
SkScalar y,
const SkPaint& paint) {
SkGDIFontSetup setup;
+ bool useDrawPath = true;
+
if (SkPaint::kUTF8_TextEncoding != paint.getTextEncoding()
&& setup.useGDI(hdc_, paint)) {
UINT options = getTextOutOptions(paint);
UINT count = byteLength >> 1;
- ExtTextOut(hdc_, SkScalarRound(x), SkScalarRound(y + getAscent(paint)),
- options, 0, reinterpret_cast<const wchar_t*>(text), count, NULL);
- } else {
+ useDrawPath = !EnsureExtTextOut(hdc_, SkScalarRound(x),
+ SkScalarRound(y + getAscent(paint)), options, 0,
+ reinterpret_cast<const wchar_t*>(text), count, NULL,
+ paint.getTypeface());
+ }
+
+ if (useDrawPath) {
SkPath path;
paint.getTextPath(text, byteLength, x, y, &path);
drawPath(draw, path, paint);
@@ -407,6 +441,8 @@
int scalarsPerPos,
const SkPaint& paint) {
SkGDIFontSetup setup;
+ bool useDrawText = true;
+
if (2 == scalarsPerPos
&& SkPaint::kUTF8_TextEncoding != paint.getTextEncoding()
&& setup.useGDI(hdc_, paint)) {
@@ -419,9 +455,12 @@
advances[i] = SkScalarRound(pos[2] - pos[0]);
pos += 2;
}
- ExtTextOut(hdc_, startX, startY, getTextOutOptions(paint), 0,
- reinterpret_cast<const wchar_t*>(text), count, advances);
- } else {
+ useDrawText = !EnsureExtTextOut(hdc_, startX, startY,
+ getTextOutOptions(paint), 0, reinterpret_cast<const wchar_t*>(text),
+ count, advances, paint.getTypeface());
+ }
+
+ if (useDrawText) {
size_t (*bytesPerCodePoint)(const char*);
switch (paint.getTextEncoding()) {
case SkPaint::kUTF8_TextEncoding:
« no previous file with comments | « skia/ext/skia_sandbox_support_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698