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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.cpp

Issue 1955723004: Implement font-variant-numeric (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 Google Inc. All rights reserved. 2 * Copyright (c) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 case ThirdWidth: 198 case ThirdWidth:
199 m_features.append(twid); 199 m_features.append(twid);
200 break; 200 break;
201 case QuarterWidth: 201 case QuarterWidth:
202 m_features.append(qwid); 202 m_features.append(qwid);
203 break; 203 break;
204 case RegularWidth: 204 case RegularWidth:
205 break; 205 break;
206 } 206 }
207 207
208 // font-variant-numeric:
209 static hb_feature_t lnum = createFeature('l', 'n', 'u', 'm', 1);
210 if (description.variantNumeric().numericFigureValue() == FontVariantNumeric: :LiningNums)
211 m_features.append(lnum);
212
213 static hb_feature_t onum = createFeature('o', 'n', 'u', 'm', 1);
214 if (description.variantNumeric().numericFigureValue() == FontVariantNumeric: :OldstyleNums)
215 m_features.append(onum);
216
217 static hb_feature_t pnum = createFeature('p', 'n', 'u', 'm', 1);
218 if (description.variantNumeric().numericSpacingValue() == FontVariantNumeric ::ProportionalNums)
219 m_features.append(pnum);
220 static hb_feature_t tnum = createFeature('t', 'n', 'u', 'm', 1);
221 if (description.variantNumeric().numericSpacingValue() == FontVariantNumeric ::TabularNums)
222 m_features.append(tnum);
223
224 static hb_feature_t afrc = createFeature('a', 'f', 'r', 'c', 1);
225 if (description.variantNumeric().numericFractionValue() == FontVariantNumeri c::StackedFractions)
226 m_features.append(afrc);
227 static hb_feature_t frac = createFeature('f', 'r', 'a', 'c', 1);
228 if (description.variantNumeric().numericFractionValue() == FontVariantNumeri c::DiagonalFractions)
229 m_features.append(frac);
230
231 static hb_feature_t ordn = createFeature('o', 'r', 'd', 'n', 1);
232 if (description.variantNumeric().ordinalValue() == FontVariantNumeric::Ordin alOn)
233 m_features.append(ordn);
234
235 static hb_feature_t zero = createFeature('z', 'e', 'r', 'o', 1);
236 if (description.variantNumeric().slashedZeroValue() == FontVariantNumeric::S lashedZeroOn)
237 m_features.append(zero);
238
239
208 FontFeatureSettings* settings = description.featureSettings(); 240 FontFeatureSettings* settings = description.featureSettings();
209 if (!settings) 241 if (!settings)
210 return; 242 return;
211 243
212 // TODO(drott): crbug.com/450619 Implement feature resolution instead of 244 // TODO(drott): crbug.com/450619 Implement feature resolution instead of
213 // just appending the font-feature-settings. 245 // just appending the font-feature-settings.
214 unsigned numFeatures = settings->size(); 246 unsigned numFeatures = settings->size();
215 for (unsigned i = 0; i < numFeatures; ++i) { 247 for (unsigned i = 0; i < numFeatures; ++i) {
216 hb_feature_t feature; 248 hb_feature_t feature;
217 const AtomicString& tag = settings->at(i).tag(); 249 const AtomicString& tag = settings->at(i).tag();
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 result->m_width = run->m_width; 699 result->m_width = run->m_width;
668 result->m_numGlyphs = count; 700 result->m_numGlyphs = count;
669 ASSERT(result->m_numGlyphs == count); // no overflow 701 ASSERT(result->m_numGlyphs == count); // no overflow
670 result->m_hasVerticalOffsets = fontData->platformData().isVerticalAnyUpright (); 702 result->m_hasVerticalOffsets = fontData->platformData().isVerticalAnyUpright ();
671 result->m_runs.append(run.release()); 703 result->m_runs.append(run.release());
672 return result.release(); 704 return result.release();
673 } 705 }
674 706
675 707
676 } // namespace blink 708 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/FontVariantNumeric.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698