| Index: src/ports/SkFontHost_FreeType.cpp
|
| diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
|
| index 19aed66a5c54fe484737baa1090cb5c9bd40a260..1a9c182ca8004571b4f733b917879c6532fce1fb 100644
|
| --- a/src/ports/SkFontHost_FreeType.cpp
|
| +++ b/src/ports/SkFontHost_FreeType.cpp
|
| @@ -11,6 +11,7 @@
|
| #include "SkColorPriv.h"
|
| #include "SkDescriptor.h"
|
| #include "SkFDot6.h"
|
| +#include "SkFontDescriptor.h"
|
| #include "SkFontHost_FreeType_common.h"
|
| #include "SkGlyph.h"
|
| #include "SkMask.h"
|
| @@ -33,6 +34,7 @@
|
| #include FT_FREETYPE_H
|
| #include FT_LCD_FILTER_H
|
| #include FT_MODULE_H
|
| +#include FT_MULTIPLE_MASTERS_H
|
| #include FT_OUTLINE_H
|
| #include FT_SIZES_H
|
| #include FT_SYSTEM_H
|
| @@ -273,6 +275,36 @@ SkFaceRec::SkFaceRec(SkStreamAsset* stream, uint32_t fontID)
|
| fFTStream.close = sk_ft_stream_close;
|
| }
|
|
|
| +static void ft_face_setup_axes(FT_Face face, const decltype(SkFontParameters::fAxis)& axes) {
|
| + if (!(face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS)) {
|
| + return;
|
| + }
|
| + SkDEBUGF(("INFO: font is mm!\n"));
|
| +
|
| + FT_MM_Var* variations = NULL;
|
| + FT_Error err = FT_Get_MM_Var(face, &variations);
|
| + if (err) {
|
| + SkDEBUGF(("INFO: font is mm, but has no variations!\n"));
|
| + return;
|
| + }
|
| + SkAutoFree autoFreeVariations(variations);
|
| +
|
| + if (static_cast<FT_UInt>(axes.count()) != variations->num_axis) {
|
| + SkDEBUGF(("INFO: font is mm, but has different number of variations!\n"));
|
| + return;
|
| + }
|
| +
|
| + SkAutoSTMalloc<16, FT_Fixed> coords(variations->num_axis);
|
| + for (FT_UInt i = 0; i < variations->num_axis; ++i) {
|
| + coords[i] = axes[i];
|
| + }
|
| + err = FT_Set_Var_Design_Coordinates(face, variations->num_axis, coords.get());
|
| + if (err) {
|
| + SkDEBUGF(("INFO: font is mm, but has no variations!\n"));
|
| + return;
|
| + }
|
| +}
|
| +
|
| // Will return 0 on failure
|
| // Caller must lock gFTMutex before calling this function.
|
| static SkFaceRec* ref_ft_face(const SkTypeface* typeface) {
|
| @@ -289,8 +321,8 @@ static SkFaceRec* ref_ft_face(const SkTypeface* typeface) {
|
| rec = rec->fNext;
|
| }
|
|
|
| - int face_index;
|
| - SkStreamAsset* stream = typeface->openStream(&face_index);
|
| + SkFontParameters params;
|
| + SkStreamAsset* stream = typeface->openStream2(¶ms);
|
| if (NULL == stream) {
|
| return NULL;
|
| }
|
| @@ -310,13 +342,16 @@ static SkFaceRec* ref_ft_face(const SkTypeface* typeface) {
|
| args.stream = &rec->fFTStream;
|
| }
|
|
|
| - FT_Error err = FT_Open_Face(gFTLibrary->library(), &args, face_index, &rec->fFace);
|
| + FT_Error err = FT_Open_Face(gFTLibrary->library(), &args, params.fIndex, &rec->fFace);
|
| if (err) { // bad filename, try the default font
|
| SkDEBUGF(("ERROR: unable to open font '%x'\n", fontID));
|
| SkDELETE(rec);
|
| return NULL;
|
| }
|
| SkASSERT(rec->fFace);
|
| +
|
| + ft_face_setup_axes(rec->fFace, params.fAxis);
|
| +
|
| rec->fNext = gFaceRecHead;
|
| gFaceRecHead = rec;
|
| return rec;
|
|
|