| 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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 | 586 |
| 587 FcPattern* pattern = FcPatternCreate(); | 587 FcPattern* pattern = FcPatternCreate(); |
| 588 | 588 |
| 589 if (familyName) { | 589 if (familyName) { |
| 590 FcPatternAddString(pattern, FC_FAMILY, (FcChar8*)familyName); | 590 FcPatternAddString(pattern, FC_FAMILY, (FcChar8*)familyName); |
| 591 } | 591 } |
| 592 fcpattern_from_skfontstyle(style, pattern); | 592 fcpattern_from_skfontstyle(style, pattern); |
| 593 | 593 |
| 594 FcPatternAddBool(pattern, FC_SCALABLE, FcTrue); | 594 FcPatternAddBool(pattern, FC_SCALABLE, FcTrue); |
| 595 | 595 |
| 596 // Using hb-ot-font functions for glyph lookup in Chrome does not support |
| 597 // Type1 fonts. |
| 598 FcPatternAddString(pattern, FC_FONTFORMAT, reinterpret_cast<const FcChar8*>(
"TrueType")); |
| 599 FcPatternAddString(pattern, FC_FONTFORMAT, reinterpret_cast<const FcChar8*>(
"CFF")); |
| 600 |
| 596 FcConfigSubstitute(nullptr, pattern, FcMatchPattern); | 601 FcConfigSubstitute(nullptr, pattern, FcMatchPattern); |
| 597 FcDefaultSubstitute(pattern); | 602 FcDefaultSubstitute(pattern); |
| 598 | 603 |
| 599 // Font matching: | 604 // Font matching: |
| 600 // CSS often specifies a fallback list of families: | 605 // CSS often specifies a fallback list of families: |
| 601 // font-family: a, b, c, serif; | 606 // font-family: a, b, c, serif; |
| 602 // However, fontconfig will always do its best to find *a* font when asked | 607 // However, fontconfig will always do its best to find *a* font when asked |
| 603 // for something so we need a way to tell if the match which it has found is | 608 // for something so we need a way to tell if the match which it has found is |
| 604 // "good enough" for us. Otherwise, we can return nullptr which gets piped u
p | 609 // "good enough" for us. Otherwise, we can return nullptr which gets piped u
p |
| 605 // and lets WebKit know to try the next CSS family name. However, fontconfig | 610 // and lets WebKit know to try the next CSS family name. However, fontconfig |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 const char* famName = get_name(match, FC_FAMILY); | 731 const char* famName = get_name(match, FC_FAMILY); |
| 727 if (famName && !find_name(names, famName)) { | 732 if (famName && !find_name(names, famName)) { |
| 728 *names.append() = famName; | 733 *names.append() = famName; |
| 729 *sizes.append() = strlen(famName) + 1; | 734 *sizes.append() = strlen(famName) + 1; |
| 730 } | 735 } |
| 731 } | 736 } |
| 732 | 737 |
| 733 return SkDataTable::MakeCopyArrays((const void*const*)names.begin(), | 738 return SkDataTable::MakeCopyArrays((const void*const*)names.begin(), |
| 734 sizes.begin(), names.count()); | 739 sizes.begin(), names.count()); |
| 735 } | 740 } |
| OLD | NEW |