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

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

Issue 1921903002: Add oblique as a slant. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: static_assert what can be. 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
« no previous file with comments | « src/ports/SkFontMgr_custom.cpp ('k') | src/ports/SkFontMgr_win_dw.cpp » ('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 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 { SkTFixed<FC_WIDTH_SEMICONDENSED>::value, SkTFixed<SkFS::kSemiCondense d_Width>::value }, 338 { SkTFixed<FC_WIDTH_SEMICONDENSED>::value, SkTFixed<SkFS::kSemiCondense d_Width>::value },
339 { SkTFixed<FC_WIDTH_NORMAL>::value, SkTFixed<SkFS::kNormal_Width >::value }, 339 { SkTFixed<FC_WIDTH_NORMAL>::value, SkTFixed<SkFS::kNormal_Width >::value },
340 { SkTFixed<FC_WIDTH_SEMIEXPANDED>::value, SkTFixed<SkFS::kSemiExpanded _Width>::value }, 340 { SkTFixed<FC_WIDTH_SEMIEXPANDED>::value, SkTFixed<SkFS::kSemiExpanded _Width>::value },
341 { SkTFixed<FC_WIDTH_EXPANDED>::value, SkTFixed<SkFS::kExpanded_Wid th>::value }, 341 { SkTFixed<FC_WIDTH_EXPANDED>::value, SkTFixed<SkFS::kExpanded_Wid th>::value },
342 { SkTFixed<FC_WIDTH_EXTRAEXPANDED>::value, SkTFixed<SkFS::kExtraExpande d_Width>::value }, 342 { SkTFixed<FC_WIDTH_EXTRAEXPANDED>::value, SkTFixed<SkFS::kExtraExpande d_Width>::value },
343 { SkTFixed<FC_WIDTH_ULTRAEXPANDED>::value, SkTFixed<SkFS::kUltaExpanded _Width>::value }, 343 { SkTFixed<FC_WIDTH_ULTRAEXPANDED>::value, SkTFixed<SkFS::kUltaExpanded _Width>::value },
344 }; 344 };
345 int width = map_ranges(get_int(pattern, FC_WIDTH, FC_WIDTH_NORMAL), 345 int width = map_ranges(get_int(pattern, FC_WIDTH, FC_WIDTH_NORMAL),
346 widthRanges, SK_ARRAY_COUNT(widthRanges)); 346 widthRanges, SK_ARRAY_COUNT(widthRanges));
347 347
348 SkFS::Slant slant = get_int(pattern, FC_SLANT, FC_SLANT_ROMAN) > 0 348 SkFS::Slant slant = SkFS::kUpright_Slant;
349 ? SkFS::kItalic_Slant 349 switch (get_int(pattern, FC_SLANT, FC_SLANT_ROMAN)) {
350 : SkFS::kUpright_Slant; 350 case FC_SLANT_ROMAN: slant = SkFS::kUpright_Slant; break;
351 case FC_SLANT_ITALIC : slant = SkFS::kItalic_Slant ; break;
352 case FC_SLANT_OBLIQUE: slant = SkFS::kOblique_Slant; break;
353 default: SkASSERT(false); break;
354 }
351 355
352 return SkFontStyle(weight, width, slant); 356 return SkFontStyle(weight, width, slant);
353 } 357 }
354 358
355 static void fcpattern_from_skfontstyle(SkFontStyle style, FcPattern* pattern) { 359 static void fcpattern_from_skfontstyle(SkFontStyle style, FcPattern* pattern) {
356 FCLocker::AssertHeld(); 360 FCLocker::AssertHeld();
357 361
358 typedef SkFontStyle SkFS; 362 typedef SkFontStyle SkFS;
359 363
360 static const MapRanges weightRanges[] = { 364 static const MapRanges weightRanges[] = {
(...skipping 16 matching lines...) Expand all
377 { SkTFixed<SkFS::kCondensed_Width>::value, SkTFixed<FC_WIDTH_CONDEN SED>::value }, 381 { SkTFixed<SkFS::kCondensed_Width>::value, SkTFixed<FC_WIDTH_CONDEN SED>::value },
378 { SkTFixed<SkFS::kSemiCondensed_Width>::value, SkTFixed<FC_WIDTH_SEMICO NDENSED>::value }, 382 { SkTFixed<SkFS::kSemiCondensed_Width>::value, SkTFixed<FC_WIDTH_SEMICO NDENSED>::value },
379 { SkTFixed<SkFS::kNormal_Width>::value, SkTFixed<FC_WIDTH_NORMAL >::value }, 383 { SkTFixed<SkFS::kNormal_Width>::value, SkTFixed<FC_WIDTH_NORMAL >::value },
380 { SkTFixed<SkFS::kSemiExpanded_Width>::value, SkTFixed<FC_WIDTH_SEMIEX PANDED>::value }, 384 { SkTFixed<SkFS::kSemiExpanded_Width>::value, SkTFixed<FC_WIDTH_SEMIEX PANDED>::value },
381 { SkTFixed<SkFS::kExpanded_Width>::value, SkTFixed<FC_WIDTH_EXPAND ED>::value }, 385 { SkTFixed<SkFS::kExpanded_Width>::value, SkTFixed<FC_WIDTH_EXPAND ED>::value },
382 { SkTFixed<SkFS::kExtraExpanded_Width>::value, SkTFixed<FC_WIDTH_EXTRAE XPANDED>::value }, 386 { SkTFixed<SkFS::kExtraExpanded_Width>::value, SkTFixed<FC_WIDTH_EXTRAE XPANDED>::value },
383 { SkTFixed<SkFS::kUltaExpanded_Width>::value, SkTFixed<FC_WIDTH_ULTRAE XPANDED>::value }, 387 { SkTFixed<SkFS::kUltaExpanded_Width>::value, SkTFixed<FC_WIDTH_ULTRAE XPANDED>::value },
384 }; 388 };
385 int width = map_ranges(style.width(), widthRanges, SK_ARRAY_COUNT(widthRange s)); 389 int width = map_ranges(style.width(), widthRanges, SK_ARRAY_COUNT(widthRange s));
386 390
391 int slant = FC_SLANT_ROMAN;
392 switch (style.slant()) {
393 case SkFS::kUpright_Slant: slant = FC_SLANT_ROMAN ; break;
394 case SkFS::kItalic_Slant : slant = FC_SLANT_ITALIC ; break;
395 case SkFS::kOblique_Slant: slant = FC_SLANT_OBLIQUE; break;
396 default: SkASSERT(false); break;
397 }
398
387 FcPatternAddInteger(pattern, FC_WEIGHT, weight); 399 FcPatternAddInteger(pattern, FC_WEIGHT, weight);
388 FcPatternAddInteger(pattern, FC_WIDTH, width); 400 FcPatternAddInteger(pattern, FC_WIDTH , width);
389 FcPatternAddInteger(pattern, FC_SLANT, style.isItalic() ? FC_SLANT_ITALIC : FC_SLANT_ROMAN); 401 FcPatternAddInteger(pattern, FC_SLANT , slant);
390 } 402 }
391 403
392 class SkTypeface_stream : public SkTypeface_FreeType { 404 class SkTypeface_stream : public SkTypeface_FreeType {
393 public: 405 public:
394 /** @param data takes ownership of the font data.*/ 406 /** @param data takes ownership of the font data.*/
395 SkTypeface_stream(SkFontData* data, const SkFontStyle& style, bool fixedWidt h) 407 SkTypeface_stream(SkFontData* data, const SkFontStyle& style, bool fixedWidt h)
396 : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth) 408 : INHERITED(style, SkTypefaceCache::NewFontID(), fixedWidth)
397 , fData(data) 409 , fData(data)
398 { }; 410 { };
399 411
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 return typeface.release(); 933 return typeface.release();
922 } 934 }
923 935
924 return this->matchFamilyStyle(nullptr, style); 936 return this->matchFamilyStyle(nullptr, style);
925 } 937 }
926 }; 938 };
927 939
928 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) { 940 SK_API SkFontMgr* SkFontMgr_New_FontConfig(FcConfig* fc) {
929 return new SkFontMgr_fontconfig(fc); 941 return new SkFontMgr_fontconfig(fc);
930 } 942 }
OLDNEW
« no previous file with comments | « src/ports/SkFontMgr_custom.cpp ('k') | src/ports/SkFontMgr_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698