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

Side by Side Diff: src/ports/SkFontHost_FreeType.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/core/SkFontMgr.cpp ('k') | src/ports/SkFontHost_FreeType_common.h » ('j') | 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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "SkAdvancedTypefaceMetrics.h" 8 #include "SkAdvancedTypefaceMetrics.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after
1734 (*axes)[i].fTag = ftAxis.tag; 1734 (*axes)[i].fTag = ftAxis.tag;
1735 (*axes)[i].fMinimum = ftAxis.minimum; 1735 (*axes)[i].fMinimum = ftAxis.minimum;
1736 (*axes)[i].fDefault = ftAxis.def; 1736 (*axes)[i].fDefault = ftAxis.def;
1737 (*axes)[i].fMaximum = ftAxis.maximum; 1737 (*axes)[i].fMaximum = ftAxis.maximum;
1738 } 1738 }
1739 } 1739 }
1740 1740
1741 FT_Done_Face(face); 1741 FT_Done_Face(face);
1742 return true; 1742 return true;
1743 } 1743 }
1744
1745 /*static*/ void SkTypeface_FreeType::Scanner::computeAxisValues(
1746 AxisDefinitions axisDefinitions,
1747 const SkFontMgr::FontParameters::Axis* requestedAxes, int requestedAxisCount ,
1748 SkFixed* axisValues,
1749 const SkString& name)
1750 {
1751 for (int i = 0; i < axisDefinitions.count(); ++i) {
1752 const Scanner::AxisDefinition& axisDefinition = axisDefinitions[i];
1753 axisValues[i] = axisDefinition.fDefault;
1754 for (int j = 0; j < requestedAxisCount; ++j) {
1755 const SkFontMgr::FontParameters::Axis& axisSpecified = requestedAxes [j];
1756 if (axisDefinition.fTag == axisSpecified.fTag) {
1757 SkFixed axisValue = SkScalarToFixed(axisSpecified.fStyleValue);
1758 axisValues[i] = SkTPin(axisValue, axisDefinition.fMinimum, axisD efinition.fMaximum);
1759 if (axisValues[i] != axisValue) {
1760 SkDEBUGF(("Requested font axis value out of range: "
1761 "%s '%c%c%c%c' %f; pinned to %f.\n",
1762 name.c_str(),
1763 (axisDefinition.fTag >> 24) & 0xFF,
1764 (axisDefinition.fTag >> 16) & 0xFF,
1765 (axisDefinition.fTag >> 8) & 0xFF,
1766 (axisDefinition.fTag ) & 0xFF,
1767 SkScalarToDouble(axisSpecified.fStyleValue),
1768 SkFixedToDouble(axisValues[i])));
1769 }
1770 break;
1771 }
1772 }
1773 // TODO: warn on defaulted axis?
1774 }
1775
1776 SkDEBUGCODE(
1777 // Check for axis specified, but not matched in font.
1778 for (int i = 0; i < requestedAxisCount; ++i) {
1779 SkFourByteTag skTag = requestedAxes[i].fTag;
1780 bool found = false;
1781 for (int j = 0; j < axisDefinitions.count(); ++j) {
1782 if (skTag == axisDefinitions[j].fTag) {
1783 found = true;
1784 break;
1785 }
1786 }
1787 if (!found) {
1788 SkDEBUGF(("Requested font axis not found: %s '%c%c%c%c'\n",
1789 name.c_str(),
1790 (skTag >> 24) & 0xFF,
1791 (skTag >> 16) & 0xFF,
1792 (skTag >> 8) & 0xFF,
1793 (skTag) & 0xFF));
1794 }
1795 }
1796 )
1797 }
OLDNEW
« no previous file with comments | « src/core/SkFontMgr.cpp ('k') | src/ports/SkFontHost_FreeType_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698