2017-02-24 16:15:26 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2018-06-26 15:22:37 +00:00
|
|
|
#ifndef SkFontArguments_DEFINED
|
|
|
|
#define SkFontArguments_DEFINED
|
2017-02-24 16:15:26 +00:00
|
|
|
|
2022-02-17 10:37:49 +00:00
|
|
|
#include "include/core/SkColor.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkScalar.h"
|
|
|
|
#include "include/core/SkTypes.h"
|
2017-02-24 16:15:26 +00:00
|
|
|
|
|
|
|
/** Represents a set of actual arguments for a font. */
|
|
|
|
struct SkFontArguments {
|
|
|
|
struct VariationPosition {
|
|
|
|
struct Coordinate {
|
|
|
|
SkFourByteTag axis;
|
2018-06-26 15:22:37 +00:00
|
|
|
float value;
|
2017-02-24 16:15:26 +00:00
|
|
|
};
|
|
|
|
const Coordinate* coordinates;
|
|
|
|
int coordinateCount;
|
|
|
|
};
|
|
|
|
|
2022-02-17 10:37:49 +00:00
|
|
|
/** Specify a palette to use and overrides for palette entries.
|
|
|
|
*
|
|
|
|
* `overrides` is a list of pairs of palette entry index and color.
|
|
|
|
* The overriden palette entries will use the associated color.
|
|
|
|
* Override pairs with palette entry indices out of range will not be applied.
|
|
|
|
* Later override entries override earlier ones.
|
|
|
|
*/
|
|
|
|
struct Palette {
|
|
|
|
struct Override {
|
|
|
|
int index;
|
|
|
|
SkColor color;
|
|
|
|
};
|
|
|
|
int index;
|
|
|
|
const Override* overrides;
|
|
|
|
int overrideCount;
|
|
|
|
};
|
|
|
|
|
|
|
|
SkFontArguments()
|
|
|
|
: fCollectionIndex(0)
|
|
|
|
, fVariationDesignPosition{nullptr, 0}
|
|
|
|
, fPalette{0, nullptr, 0} {}
|
2017-02-24 16:15:26 +00:00
|
|
|
|
|
|
|
/** Specify the index of the desired font.
|
|
|
|
*
|
|
|
|
* Font formats like ttc, dfont, cff, cid, pfr, t42, t1, and fon may actually be indexed
|
|
|
|
* collections of fonts.
|
|
|
|
*/
|
|
|
|
SkFontArguments& setCollectionIndex(int collectionIndex) {
|
|
|
|
fCollectionIndex = collectionIndex;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Specify a position in the variation design space.
|
|
|
|
*
|
|
|
|
* Any axis not specified will use the default value.
|
|
|
|
* Any specified axis not actually present in the font will be ignored.
|
|
|
|
*
|
|
|
|
* @param position not copied. The value must remain valid for life of SkFontArguments.
|
|
|
|
*/
|
|
|
|
SkFontArguments& setVariationDesignPosition(VariationPosition position) {
|
|
|
|
fVariationDesignPosition.coordinates = position.coordinates;
|
|
|
|
fVariationDesignPosition.coordinateCount = position.coordinateCount;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getCollectionIndex() const {
|
|
|
|
return fCollectionIndex;
|
|
|
|
}
|
2020-07-15 17:05:50 +00:00
|
|
|
|
2017-02-24 16:15:26 +00:00
|
|
|
VariationPosition getVariationDesignPosition() const {
|
|
|
|
return fVariationDesignPosition;
|
|
|
|
}
|
2022-02-17 10:37:49 +00:00
|
|
|
|
|
|
|
SkFontArguments& setPalette(Palette palette) {
|
|
|
|
fPalette.index = palette.index;
|
|
|
|
fPalette.overrides = palette.overrides;
|
|
|
|
fPalette.overrideCount = palette.overrideCount;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
Palette getPalette() const { return fPalette; }
|
|
|
|
|
2017-02-24 16:15:26 +00:00
|
|
|
private:
|
|
|
|
int fCollectionIndex;
|
|
|
|
VariationPosition fVariationDesignPosition;
|
2022-02-17 10:37:49 +00:00
|
|
|
Palette fPalette;
|
2017-02-24 16:15:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|