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

Unified Diff: experimental/PdfViewer/SkPdfFont.h

Issue 23020003: pdfviewer: debug code for drawText (show magenta background for text, to show text even when we fai… (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 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 | « experimental/PdfViewer/SkPdfConfig.h ('k') | experimental/PdfViewer/SkPdfFont.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/PdfViewer/SkPdfFont.h
===================================================================
--- experimental/PdfViewer/SkPdfFont.h (revision 10712)
+++ experimental/PdfViewer/SkPdfFont.h (working copy)
@@ -9,7 +9,7 @@
#include "SkTypeface.h"
#include "SkUtils.h"
-#include "SkPdfBasics.h"
+#include "SkPdfGraphicsState.h"
#include "SkPdfUtils.h"
@@ -38,7 +38,7 @@
std::map<std::string, SkPdfStandardFontEntry>& getStandardFonts();
SkTypeface* SkTypefaceFromPdfStandardFont(const char* fontName, bool bold, bool italic);
-SkPdfFont* fontFromName(SkNativeParsedPDF* doc, SkPdfObject* obj, const char* fontName);
+SkPdfFont* fontFromName(SkPdfNativeDoc* doc, SkPdfNativeObject* obj, const char* fontName);
struct SkUnencodedText {
void* text;
@@ -77,13 +77,13 @@
std::map<std::string, SkPdfEncoding*>& getStandardEncodings();
class SkPdfToUnicode {
- SkNativeParsedPDF* fParsed;
+ SkPdfNativeDoc* fParsed;
// TODO(edisonn): hide public members
public:
unsigned short* fCMapEncoding;
unsigned char* fCMapEncodingFlag;
- SkPdfToUnicode(SkNativeParsedPDF* parsed, SkPdfStream* stream);
+ SkPdfToUnicode(SkPdfNativeDoc* parsed, SkPdfStream* stream);
};
@@ -170,7 +170,7 @@
const SkPdfEncoding* encoding() const {return fEncoding;}
- void drawText(const SkDecodedText& text, SkPaint* paint, PdfContext* pdfContext, SkCanvas* canvas) {
+ void drawText(const SkDecodedText& text, SkPaint* paint, SkPdfContext* pdfContext, SkCanvas* canvas) {
for (int i = 0 ; i < text.size(); i++) {
canvas->setMatrix(pdfContext->fGraphicsState.fMatrixTm);
#ifdef PDF_TRACE
@@ -178,6 +178,16 @@
pdfContext->fGraphicsState.fMatrixTm.mapPoints(&point, 1);
printf("DrawText at (%f, %f)\n", SkScalarToDouble(point.x()), SkScalarToDouble(point.y()));
#endif // PDF_TRACE
+
+#ifdef PDF_TRACE_DRAWTEXT
+ SkPaint col;
+ col.setColor(SK_ColorMAGENTA);
+ SkRect rect = SkRect::MakeXYWH(SkDoubleToScalar(0.0), SkDoubleToScalar(0.0), SkDoubleToScalar(10.0), SkDoubleToScalar(10.0));
+ canvas->save();
+ canvas->setMatrix(pdfContext->fGraphicsState.fMatrixTm);
+ canvas->drawRect(rect, col);
+ canvas->restore();
+#endif
double width = drawOneChar(text[i], paint, pdfContext, canvas);
pdfContext->fGraphicsState.fMatrixTm.preTranslate(SkDoubleToScalar(width), SkDoubleToScalar(0.0));
}
@@ -204,23 +214,23 @@
}
};
- static SkPdfFont* fontFromPdfDictionary(SkNativeParsedPDF* doc, SkPdfFontDictionary* dict);
+ static SkPdfFont* fontFromPdfDictionary(SkPdfNativeDoc* doc, SkPdfFontDictionary* dict);
static SkPdfFont* Default() {return fontFromName(NULL, NULL, "TimesNewRoman");}
- static SkPdfType0Font* fontFromType0FontDictionary(SkNativeParsedPDF* doc, SkPdfType0FontDictionary* dict);
- static SkPdfType1Font* fontFromType1FontDictionary(SkNativeParsedPDF* doc, SkPdfType1FontDictionary* dict);
- static SkPdfType3Font* fontFromType3FontDictionary(SkNativeParsedPDF* doc, SkPdfType3FontDictionary* dict);
- static SkPdfTrueTypeFont* fontFromTrueTypeFontDictionary(SkNativeParsedPDF* doc, SkPdfTrueTypeFontDictionary* dict);
- static SkPdfMultiMasterFont* fontFromMultiMasterFontDictionary(SkNativeParsedPDF* doc, SkPdfMultiMasterFontDictionary* dict);
+ static SkPdfType0Font* fontFromType0FontDictionary(SkPdfNativeDoc* doc, SkPdfType0FontDictionary* dict);
+ static SkPdfType1Font* fontFromType1FontDictionary(SkPdfNativeDoc* doc, SkPdfType1FontDictionary* dict);
+ static SkPdfType3Font* fontFromType3FontDictionary(SkPdfNativeDoc* doc, SkPdfType3FontDictionary* dict);
+ static SkPdfTrueTypeFont* fontFromTrueTypeFontDictionary(SkPdfNativeDoc* doc, SkPdfTrueTypeFontDictionary* dict);
+ static SkPdfMultiMasterFont* fontFromMultiMasterFontDictionary(SkPdfNativeDoc* doc, SkPdfMultiMasterFontDictionary* dict);
- static SkPdfFont* fontFromFontDescriptor(SkNativeParsedPDF* doc, SkPdfFontDescriptorDictionary* fd, bool loadFromName = true);
+ static SkPdfFont* fontFromFontDescriptor(SkPdfNativeDoc* doc, SkPdfFontDescriptorDictionary* fd, bool loadFromName = true);
public:
- virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfContext, SkCanvas* canvas) = 0;
+ virtual double drawOneChar(unsigned int ch, SkPaint* paint, SkPdfContext* pdfContext, SkCanvas* canvas) = 0;
virtual void afterWord(SkPaint* paint, SkMatrix* matrix) = 0;
private:
- static SkPdfFont* fontFromPdfDictionaryOnce(SkNativeParsedPDF* doc, SkPdfFontDictionary* dict);
+ static SkPdfFont* fontFromPdfDictionaryOnce(SkPdfNativeDoc* doc, SkPdfFontDictionary* dict);
};
class SkPdfStandardFont : public SkPdfFont {
@@ -230,7 +240,7 @@
SkPdfStandardFont(SkTypeface* typeface) : fTypeface(typeface) {}
public:
- virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfContext, SkCanvas* canvas) {
+ virtual double drawOneChar(unsigned int ch, SkPaint* paint, SkPdfContext* pdfContext, SkCanvas* canvas) {
paint->setTypeface(fTypeface);
paint->setTextEncoding(SkPaint::kUTF8_TextEncoding);
@@ -249,11 +259,11 @@
class SkPdfType0Font : public SkPdfFont {
public:
- SkPdfType0Font(SkNativeParsedPDF* doc, SkPdfType0FontDictionary* dict);
+ SkPdfType0Font(SkPdfNativeDoc* doc, SkPdfType0FontDictionary* dict);
public:
- virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfContext, SkCanvas* canvas) {
+ virtual double drawOneChar(unsigned int ch, SkPaint* paint, SkPdfContext* pdfContext, SkCanvas* canvas) {
return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canvas);
}
@@ -263,16 +273,23 @@
class SkPdfType1Font : public SkPdfFont {
public:
- SkPdfType1Font(SkNativeParsedPDF* doc, SkPdfType1FontDictionary* dict) {
+ SkPdfType1Font(SkPdfNativeDoc* doc, SkPdfType1FontDictionary* dict) {
if (dict->has_FontDescriptor()) {
fBaseFont = SkPdfFont::fontFromFontDescriptor(doc, dict->FontDescriptor(doc));
} else {
fBaseFont = fontFromName(doc, dict, dict->BaseFont(doc).c_str());
}
+
+ if (dict->isEncodingAName(doc)) {
+ fEncoding = SkPdfEncoding::fromName(dict->getEncodingAsName(doc).c_str());
+ } else if (dict->isEncodingADictionary(doc)) {
+ //SkPdfDictionary* dictEnc = dict->getEncodingAsDictionary(doc);
+ }
+ dict->FontDescriptor(doc);
}
public:
- virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfContext, SkCanvas* canvas) {
+ virtual double drawOneChar(unsigned int ch, SkPaint* paint, SkPdfContext* pdfContext, SkCanvas* canvas) {
return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canvas);
}
@@ -283,13 +300,13 @@
class SkPdfTrueTypeFont : public SkPdfType1Font {
public:
- SkPdfTrueTypeFont(SkNativeParsedPDF* doc, SkPdfTrueTypeFontDictionary* dict) : SkPdfType1Font(doc, dict) {
+ SkPdfTrueTypeFont(SkPdfNativeDoc* doc, SkPdfTrueTypeFontDictionary* dict) : SkPdfType1Font(doc, dict) {
}
};
class SkPdfMultiMasterFont : public SkPdfType1Font {
public:
- SkPdfMultiMasterFont(SkNativeParsedPDF* doc, SkPdfMultiMasterFontDictionary* dict) : SkPdfType1Font(doc, dict) {
+ SkPdfMultiMasterFont(SkPdfNativeDoc* doc, SkPdfMultiMasterFontDictionary* dict) : SkPdfType1Font(doc, dict) {
}
};
/*
@@ -324,7 +341,7 @@
class SkPdfType3Font : public SkPdfFont {
struct Type3FontChar {
- SkPdfObject* fObj;
+ SkPdfNativeObject* fObj;
double fWidth;
};
@@ -339,7 +356,7 @@
Type3FontChar* fChars;
public:
- SkPdfType3Font(SkNativeParsedPDF* parsed, SkPdfType3FontDictionary* dict) {
+ SkPdfType3Font(SkPdfNativeDoc* parsed, SkPdfType3FontDictionary* dict) {
fBaseFont = fontFromName(parsed, dict, dict->BaseFont(parsed).c_str());
if (dict->has_Encoding()) {
@@ -400,7 +417,7 @@
}
public:
- virtual double drawOneChar(unsigned int ch, SkPaint* paint, PdfContext* pdfContext, SkCanvas* canvas) {
+ virtual double drawOneChar(unsigned int ch, SkPaint* paint, SkPdfContext* pdfContext, SkCanvas* canvas) {
if (ch < fFirstChar || ch > fLastChar || !fChars[ch - fFirstChar].fObj) {
return fBaseFont->drawOneChar(ToUnicode(ch), paint, pdfContext, canvas);
}
« no previous file with comments | « experimental/PdfViewer/SkPdfConfig.h ('k') | experimental/PdfViewer/SkPdfFont.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698