From 3560b58de36988e1fba54d9ac341735ab849e913 Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Tue, 27 Mar 2018 18:15:53 +0000 Subject: Revert "Add color fonts." This reverts commit d3b933f3e03d5c22e9e7c56d2110469e41509720. Reason for revert: we're not mirroring experimental/ everywhere. Original change's description: > Add color fonts. > > BUG=skia:7624 > > Change-Id: I1d0974282adce2fd7b13a003309e63593b6e1a9c > Reviewed-on: https://skia-review.googlesource.com/109521 > Commit-Queue: Ben Wagner > Reviewed-by: Mike Klein > Reviewed-by: Herb Derby > Reviewed-on: https://skia-review.googlesource.com/116541 TBR=mtklein@google.com,bungeman@google.com,herb@google.com Change-Id: Ic2d763244cbce663a23eb53321ac45201c466501 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia:7624 Reviewed-on: https://skia-review.googlesource.com/116680 Reviewed-by: Ben Wagner Commit-Queue: Ben Wagner --- tools/fonts/SkTestScalerContext.h | 102 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tools/fonts/SkTestScalerContext.h (limited to 'tools/fonts/SkTestScalerContext.h') diff --git a/tools/fonts/SkTestScalerContext.h b/tools/fonts/SkTestScalerContext.h new file mode 100644 index 0000000000..e62210b2e3 --- /dev/null +++ b/tools/fonts/SkTestScalerContext.h @@ -0,0 +1,102 @@ +/* + * Copyright 2014 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef SkTestScalerContext_DEFINED +#define SkTestScalerContext_DEFINED + +#include "SkFixed.h" +#include "SkPaint.h" +#include "SkPath.h" +#include "SkRefCnt.h" +#include "SkTDArray.h" +#include "SkTypeface.h" + +class SkTestFont; + +struct SkTestFontData { + const SkScalar* fPoints; + const unsigned char* fVerbs; + const unsigned* fCharCodes; + const size_t fCharCodesCount; + const SkFixed* fWidths; + const SkPaint::FontMetrics& fMetrics; + const char* fName; + SkFontStyle fStyle; + sk_sp fCachedFont; +}; + +class SkTestFont : public SkRefCnt { +public: + SkTestFont(const SkTestFontData& ); + virtual ~SkTestFont(); + int codeToIndex(SkUnichar charCode) const; + void init(const SkScalar* pts, const unsigned char* verbs); +private: + const unsigned* fCharCodes; + const size_t fCharCodesCount; + const SkFixed* fWidths; + const SkPaint::FontMetrics& fMetrics; + const char* fName; + SkPath** fPaths; + friend class SkTestTypeface; + typedef SkRefCnt INHERITED; +}; + + +class SkTestTypeface : public SkTypeface { +public: + SkTestTypeface(sk_sp, const SkFontStyle& style); + void getAdvance(SkGlyph* glyph); + void getFontMetrics(SkPaint::FontMetrics* metrics); + void getMetrics(SkGlyph* glyph); + void getPath(SkGlyphID glyph, SkPath* path); +protected: + SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, + const SkDescriptor* desc) const override; + void onFilterRec(SkScalerContextRec* rec) const override; + std::unique_ptr onGetAdvancedMetrics() const override; + + SkStreamAsset* onOpenStream(int* ttcIndex) const override { + return nullptr; + } + + void onGetFontDescriptor(SkFontDescriptor* desc, bool* isLocal) const override; + + int onCharsToGlyphs(const void* chars, Encoding encoding, + uint16_t glyphs[], int glyphCount) const override; + + int onCountGlyphs() const override { + return (int) fTestFont->fCharCodesCount; + } + + int onGetUPEM() const override { + return 2048; + } + + void onGetFamilyName(SkString* familyName) const override; + SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override; + + int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[], + int coordinateCount) const override + { + return 0; + } + + int onGetTableTags(SkFontTableTag tags[]) const override { + return 0; + } + + size_t onGetTableData(SkFontTableTag tag, size_t offset, + size_t length, void* data) const override { + return 0; + } +private: + sk_sp fTestFont; + friend class SkTestScalerContext; +}; + +#endif -- cgit v1.2.3