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

Side by Side Diff: src/fonts/SkTestScalerContext.h

Issue 407183003: add portable and canonical font support for DM (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add atexit; rename to create_... Created 6 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 unified diff | Download patch
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | src/fonts/SkTestScalerContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkTestScalerContext_DEFINED 8 #ifndef SkTestScalerContext_DEFINED
9 #define SkTestScalerContext_DEFINED 9 #define SkTestScalerContext_DEFINED
10 10
11 #include "SkPaint.h" 11 #include "SkPaint.h"
12 #include "SkPath.h" 12 #include "SkPath.h"
13 #include "SkRefCnt.h"
13 #include "SkTDArray.h" 14 #include "SkTDArray.h"
14 #include "SkTypeface.h" 15 #include "SkTypeface.h"
15 16
16 SkTypeface* CreateTestTypeface(SkPaint::FontMetrics (*funct)(SkTDArray<SkPath*>& pathArray, 17 class SkTestFont;
17 SkTDArray<SkFixed>& widthArray), 18
18 SkTypeface::Style style); 19 struct SkTestFontData {
20 const SkScalar* fPoints;
21 const unsigned char* fVerbs;
22 const unsigned* fCharCodes;
23 const size_t fCharCodesCount;
24 const SkFixed* fWidths;
25 const SkPaint::FontMetrics& fMetrics;
26 const char* fName;
27 SkTypeface::Style fStyle;
28 SkTestFont* fFontCache;
29 };
30
31 class SkTestFont : public SkRefCnt {
32 public:
33 SK_DECLARE_INST_COUNT(SkTestFont)
34
35 SkTestFont(const SkTestFontData& );
36 virtual ~SkTestFont();
37 int codeToIndex(SkUnichar charCode) const;
38 void init(const SkScalar* pts, const unsigned char* verbs);
39 #ifdef SK_DEBUG // detect missing test font data
40 mutable unsigned char fDebugBits[16];
41 mutable SkUnichar fDebugOverage[8];
42 const char* fDebugName;
43 SkTypeface::Style fDebugStyle;
44 const char* debugFontName() const { return fName; }
45 #endif
46 private:
47 const unsigned* fCharCodes;
48 const size_t fCharCodesCount;
49 const SkFixed* fWidths;
50 const SkPaint::FontMetrics& fMetrics;
51 const char* fName;
52 SkPath** fPaths;
53 friend class SkTestTypeface;
54 typedef SkRefCnt INHERITED;
55 };
56
57
58 class SkTestTypeface : public SkTypeface {
59 public:
60 SkTestTypeface(SkTestFont* , SkTypeface::Style style);
61 virtual ~SkTestTypeface() {
62 SkSafeUnref(fTestFont);
63 }
64 void getAdvance(SkGlyph* glyph);
65 void getFontMetrics(SkPaint::FontMetrics* metrics);
66 void getMetrics(SkGlyph* glyph);
67 void getPath(const SkGlyph& glyph, SkPath* path);
68 protected:
69 virtual SkScalerContext* onCreateScalerContext(const SkDescriptor* desc) con st SK_OVERRIDE;
70 virtual void onFilterRec(SkScalerContextRec* rec) const SK_OVERRIDE;
71 virtual SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
72 SkAdvancedTypefaceMetrics::PerGlyphInfo ,
73 const uint32_t* glyphIDs,
74 uint32_t glyphIDsCount) const SK_OVERRIDE;
75
76 virtual SkStream* onOpenStream(int* ttcIndex) const SK_OVERRIDE {
77 SkASSERT(0); // don't expect to get here
78 return NULL;
79 }
80
81 virtual void onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocal) cons t SK_OVERRIDE;
82
83 virtual int onCharsToGlyphs(const void* chars, Encoding encoding,
84 uint16_t glyphs[], int glyphCount) const SK_OVER RIDE;
85
86 virtual int onCountGlyphs() const SK_OVERRIDE {
87 return (int) fTestFont->fCharCodesCount;
88 }
89
90 virtual int onGetUPEM() const SK_OVERRIDE {
91 SkASSERT(0); // don't expect to get here
92 return 1;
93 }
94
95 virtual SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const SK_ OVERRIDE;
96
97 virtual int onGetTableTags(SkFontTableTag tags[]) const SK_OVERRIDE {
98 return 0;
99 }
100
101 virtual size_t onGetTableData(SkFontTableTag tag, size_t offset,
102 size_t length, void* data) const SK_OVERRIDE {
103 return 0;
104 }
105 private:
106 SkTestFont* fTestFont;
107 friend class SkTestScalerContext;
108 };
109
110 SkTypeface* CreateTestTypeface(const char* name, SkTypeface::Style style);
19 111
20 #endif 112 #endif
OLDNEW
« no previous file with comments | « samplecode/SampleApp.cpp ('k') | src/fonts/SkTestScalerContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698