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 SkFontArguments_DEFINED 9 #define SkFontArguments_DEFINED 10 11 #include "include/core/SkScalar.h" 12 #include "include/core/SkTypes.h" 13 14 /** Represents a set of actual arguments for a font. */ 15 struct SkFontArguments { 16 struct VariationPosition { 17 struct Coordinate { 18 SkFourByteTag axis; 19 float value; 20 }; 21 const Coordinate* coordinates; 22 int coordinateCount; 23 }; 24 SkFontArgumentsSkFontArguments25 SkFontArguments() : fCollectionIndex(0), fVariationDesignPosition{nullptr, 0} {} 26 27 /** Specify the index of the desired font. 28 * 29 * Font formats like ttc, dfont, cff, cid, pfr, t42, t1, and fon may actually be indexed 30 * collections of fonts. 31 */ setCollectionIndexSkFontArguments32 SkFontArguments& setCollectionIndex(int collectionIndex) { 33 fCollectionIndex = collectionIndex; 34 return *this; 35 } 36 37 /** Specify a position in the variation design space. 38 * 39 * Any axis not specified will use the default value. 40 * Any specified axis not actually present in the font will be ignored. 41 * 42 * @param position not copied. The value must remain valid for life of SkFontArguments. 43 */ setVariationDesignPositionSkFontArguments44 SkFontArguments& setVariationDesignPosition(VariationPosition position) { 45 fVariationDesignPosition.coordinates = position.coordinates; 46 fVariationDesignPosition.coordinateCount = position.coordinateCount; 47 return *this; 48 } 49 getCollectionIndexSkFontArguments50 int getCollectionIndex() const { 51 return fCollectionIndex; 52 } 53 getVariationDesignPositionSkFontArguments54 VariationPosition getVariationDesignPosition() const { 55 return fVariationDesignPosition; 56 } 57 private: 58 int fCollectionIndex; 59 VariationPosition fVariationDesignPosition; 60 }; 61 62 #endif 63