• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2015 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef RandomScalerContext_DEFINED
9 #define RandomScalerContext_DEFINED
10 
11 #include "include/core/SkTypeface.h"
12 #include "src/core/SkScalerContext.h"
13 
14 /*
15  * This scaler context is for debug only purposes.  It will 'randomly' but deterministically return
16  * LCD / A8 / BW / RBGA masks based off of the Glyph ID
17  */
18 
19 class SkRandomTypeface : public SkTypeface {
20 public:
21     SkRandomTypeface(sk_sp<SkTypeface> proxy, const SkPaint&, bool fakeit);
22 
proxy()23     SkTypeface* proxy() const { return fProxy.get(); }
paint()24     const SkPaint& paint() const { return fPaint; }
25 
26 protected:
27     std::unique_ptr<SkScalerContext> onCreateScalerContext(const SkScalerContextEffects&,
28                                                            const SkDescriptor*) const override;
29     void onFilterRec(SkScalerContextRec*) const override;
30     void getGlyphToUnicodeMap(SkUnichar*) const override;
31     std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override;
32     std::unique_ptr<SkStreamAsset> onOpenStream(int* ttcIndex) const override;
33     sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override;
34     void onGetFontDescriptor(SkFontDescriptor*, bool* isLocal) const override;
35 
36     void onCharsToGlyphs(const SkUnichar* chars, int count, SkGlyphID glyphs[]) const override;
37     int onCountGlyphs() const override;
38     int onGetUPEM() const override;
39 
40     void onGetFamilyName(SkString* familyName) const override;
41     bool onGetPostScriptName(SkString*) const override;
42     SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override;
43 
44     void getPostScriptGlyphNames(SkString*) const override;
45 
46     int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[],
47                                      int coordinateCount) const override;
48     int onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[],
49                                        int parameterCount) const override;
50     int onGetTableTags(SkFontTableTag tags[]) const override;
51     size_t onGetTableData(SkFontTableTag, size_t offset, size_t length, void* data) const override;
52 
53 private:
54     sk_sp<SkTypeface> fProxy;
55     SkPaint           fPaint;
56     bool              fFakeIt;
57 };
58 
59 #endif
60