Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Side by Side Diff: src/ports/SkFontMgr_fontconfig.cpp

Issue 1590223003: Expose API for gx font variation axes. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix FontConfig and Android. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ports/SkFontMgr_android.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkDataTable.h" 8 #include "SkDataTable.h"
9 #include "SkFixed.h" 9 #include "SkFixed.h"
10 #include "SkFontDescriptor.h" 10 #include "SkFontDescriptor.h"
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 SkFontStyle style; 827 SkFontStyle style;
828 bool isFixedWidth = false; 828 bool isFixedWidth = false;
829 if (!fScanner.scanFont(stream, ttcIndex, nullptr, &style, &isFixedWidth, nullptr)) { 829 if (!fScanner.scanFont(stream, ttcIndex, nullptr, &style, &isFixedWidth, nullptr)) {
830 return nullptr; 830 return nullptr;
831 } 831 }
832 832
833 return new SkTypeface_stream(new SkFontData(stream.detach(), ttcIndex, n ullptr, 0), style, 833 return new SkTypeface_stream(new SkFontData(stream.detach(), ttcIndex, n ullptr, 0), style,
834 isFixedWidth); 834 isFixedWidth);
835 } 835 }
836 836
837 SkTypeface* onCreateFromStream(SkStreamAsset* s, const FontParameters& param s) const override {
838 using Scanner = SkTypeface_FreeType::Scanner;
839 SkAutoTDelete<SkStreamAsset> stream(s);
840 bool isFixedPitch;
841 SkFontStyle style;
842 SkString name;
843 Scanner::AxisDefinitions axisDefinitions;
844 if (!fScanner.scanFont(stream, params.getCollectionIndex(), &name, &styl e, &isFixedPitch,
845 &axisDefinitions))
846 {
847 return nullptr;
848 }
849
850 int paramAxisCount;
851 const FontParameters::Axis* paramAxes = params.getAxes(&paramAxisCount);
852 SkAutoSTMalloc<4, SkFixed> axisValues(axisDefinitions.count());
853 Scanner::computeAxisValues(axisDefinitions, paramAxes, paramAxisCount, a xisValues, name);
854
855 SkFontData* data(new SkFontData(stream.detach(), params.getCollectionInd ex(),
856 axisValues.get(), axisDefinitions.count( )));
857 return new SkTypeface_stream(data, style, isFixedPitch);
858 }
859
837 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override { 860 SkTypeface* onCreateFromData(SkData* data, int ttcIndex) const override {
838 return this->createFromStream(new SkMemoryStream(data), ttcIndex); 861 return this->createFromStream(new SkMemoryStream(data), ttcIndex);
839 } 862 }
840 863
841 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override { 864 SkTypeface* onCreateFromFile(const char path[], int ttcIndex) const override {
842 return this->createFromStream(SkStream::NewFromFile(path), ttcIndex); 865 return this->createFromStream(SkStream::NewFromFile(path), ttcIndex);
843 } 866 }
844 867
845 SkTypeface* onCreateFromFontData(SkFontData* fontData) const override { 868 SkTypeface* onCreateFromFontData(SkFontData* fontData) const override {
846 SkStreamAsset* stream(fontData->getStream()); 869 SkStreamAsset* stream(fontData->getStream());
(...skipping 26 matching lines...) Expand all
873 return typeface.detach(); 896 return typeface.detach();
874 } 897 }
875 898
876 return this->matchFamilyStyle(nullptr, style); 899 return this->matchFamilyStyle(nullptr, style);
877 } 900 }
878 }; 901 };
879 902
880 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) { 903 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) {
881 return new SkFontMgr_fontconfig(fc); 904 return new SkFontMgr_fontconfig(fc);
882 } 905 }
OLDNEW
« no previous file with comments | « src/ports/SkFontMgr_android.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698