1 /* 2 * Copyright 2017 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 SkAtlasTextFont_DEFINED 9 #define SkAtlasTextFont_DEFINED 10 11 #include "SkFont.h" 12 #include "SkRefCnt.h" 13 #include "SkTypeface.h" 14 15 /** Represents a font at a size. TODO: What else do we need here (skewX, scaleX, vertical, ...)? */ 16 class SK_API SkAtlasTextFont : public SkRefCnt { 17 public: Make(sk_sp<SkTypeface> typeface,SkScalar size)18 static sk_sp<SkAtlasTextFont> Make(sk_sp<SkTypeface> typeface, SkScalar size) { 19 return sk_sp<SkAtlasTextFont>(new SkAtlasTextFont(std::move(typeface), size)); 20 } 21 typeface()22 SkTypeface* typeface() const { return fTypeface.get(); } 23 refTypeface()24 sk_sp<SkTypeface> refTypeface() const { return fTypeface; } 25 size()26 SkScalar size() const { return fSize; } 27 makeFont()28 SkFont makeFont() const { return SkFont(fTypeface, fSize); } 29 30 private: SkAtlasTextFont(sk_sp<SkTypeface> typeface,SkScalar size)31 SkAtlasTextFont(sk_sp<SkTypeface> typeface, SkScalar size) 32 : fTypeface(std::move(typeface)), fSize(size) {} 33 34 sk_sp<SkTypeface> fTypeface; 35 SkScalar fSize; 36 }; 37 38 #endif 39