| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009-2015 Google Inc. | 2 * Copyright 2009-2015 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 /* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */ | 8 /* migrated from chrome/src/skia/ext/SkFontHost_fontconfig_direct.cpp */ |
| 9 | 9 |
| 10 #include "SkBuffer.h" | 10 #include "SkBuffer.h" |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 | 590 |
| 591 FcPattern* pattern = FcPatternCreate(); | 591 FcPattern* pattern = FcPatternCreate(); |
| 592 | 592 |
| 593 if (familyName) { | 593 if (familyName) { |
| 594 FcPatternAddString(pattern, FC_FAMILY, (FcChar8*)familyName); | 594 FcPatternAddString(pattern, FC_FAMILY, (FcChar8*)familyName); |
| 595 } | 595 } |
| 596 fcpattern_from_skfontstyle(style, pattern); | 596 fcpattern_from_skfontstyle(style, pattern); |
| 597 | 597 |
| 598 FcPatternAddBool(pattern, FC_SCALABLE, FcTrue); | 598 FcPatternAddBool(pattern, FC_SCALABLE, FcTrue); |
| 599 | 599 |
| 600 #ifdef SK_FONT_CONFIG_INTERFACE_ONLY_ALLOW_SFNT_FONTS | |
| 601 FcPatternAddString(pattern, FC_FONTFORMAT, reinterpret_cast<const FcChar8*>(
kFontFormatTrueType)); | |
| 602 FcPatternAddString(pattern, FC_FONTFORMAT, reinterpret_cast<const FcChar8*>(
kFontFormatCFF)); | |
| 603 #endif | |
| 604 | |
| 605 FcConfigSubstitute(nullptr, pattern, FcMatchPattern); | 600 FcConfigSubstitute(nullptr, pattern, FcMatchPattern); |
| 606 FcDefaultSubstitute(pattern); | 601 FcDefaultSubstitute(pattern); |
| 607 | 602 |
| 608 // Font matching: | 603 // Font matching: |
| 609 // CSS often specifies a fallback list of families: | 604 // CSS often specifies a fallback list of families: |
| 610 // font-family: a, b, c, serif; | 605 // font-family: a, b, c, serif; |
| 611 // However, fontconfig will always do its best to find *a* font when asked | 606 // However, fontconfig will always do its best to find *a* font when asked |
| 612 // for something so we need a way to tell if the match which it has found is | 607 // for something so we need a way to tell if the match which it has found is |
| 613 // "good enough" for us. Otherwise, we can return nullptr which gets piped u
p | 608 // "good enough" for us. Otherwise, we can return nullptr which gets piped u
p |
| 614 // and lets WebKit know to try the next CSS family name. However, fontconfig | 609 // and lets WebKit know to try the next CSS family name. However, fontconfig |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 const char* famName = get_string(match, FC_FAMILY); | 726 const char* famName = get_string(match, FC_FAMILY); |
| 732 if (famName && !find_name(names, famName)) { | 727 if (famName && !find_name(names, famName)) { |
| 733 *names.append() = famName; | 728 *names.append() = famName; |
| 734 *sizes.append() = strlen(famName) + 1; | 729 *sizes.append() = strlen(famName) + 1; |
| 735 } | 730 } |
| 736 } | 731 } |
| 737 | 732 |
| 738 return SkDataTable::MakeCopyArrays((const void*const*)names.begin(), | 733 return SkDataTable::MakeCopyArrays((const void*const*)names.begin(), |
| 739 sizes.begin(), names.count()); | 734 sizes.begin(), names.count()); |
| 740 } | 735 } |
| OLD | NEW |