OLD | NEW |
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 "SkDWrite.h" | 9 #include "SkDWrite.h" |
10 #include "SkDWriteFontFileStream.h" | 10 #include "SkDWriteFontFileStream.h" |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 | 401 |
402 const SkFontIdentity FallbackIdentity() { return fIdentity; } | 402 const SkFontIdentity FallbackIdentity() { return fIdentity; } |
403 | 403 |
404 protected: | 404 protected: |
405 ULONG fRefCount; | 405 ULONG fRefCount; |
406 SkAutoTUnref<const SkRemotableFontMgr_DirectWrite> fOuter; | 406 SkAutoTUnref<const SkRemotableFontMgr_DirectWrite> fOuter; |
407 UINT32 fCharacter; | 407 UINT32 fCharacter; |
408 SkFontIdentity fIdentity; | 408 SkFontIdentity fIdentity; |
409 }; | 409 }; |
410 | 410 |
| 411 #ifdef SK_FM_NEW_MATCH_FAMILY_STYLE_CHARACTER |
| 412 virtual SkFontIdentity matchNameStyleCharacter(const char familyName[], |
| 413 const SkFontStyle&, pattern |
| 414 const char* bcp47[], int bcp4
7Count, |
| 415 SkUnichar character) const SK
_OVERRIDE |
| 416 { |
| 417 #else |
411 virtual SkFontIdentity matchNameStyleCharacter(const char familyName[], | 418 virtual SkFontIdentity matchNameStyleCharacter(const char familyName[], |
412 const SkFontStyle& pattern, | 419 const SkFontStyle& pattern, |
413 const char bpc47[], | 420 const char bcp47_val[], |
414 SkUnichar character) const S
K_OVERRIDE | 421 SkUnichar character) const SK
_OVERRIDE |
415 { | 422 { |
| 423 const char** bcp47 = &bcp47_val; |
| 424 int bcp47Count = bcp47_val ? 1 : 0; |
| 425 #endif |
416 SkFontIdentity identity = { SkFontIdentity::kInvalidDataId }; | 426 SkFontIdentity identity = { SkFontIdentity::kInvalidDataId }; |
417 | 427 |
418 IDWriteFactory* dwFactory = sk_get_dwrite_factory(); | 428 IDWriteFactory* dwFactory = sk_get_dwrite_factory(); |
419 if (NULL == dwFactory) { | 429 if (NULL == dwFactory) { |
420 return identity; | 430 return identity; |
421 } | 431 } |
422 | 432 |
423 // TODO: use IDWriteFactory2::GetSystemFontFallback when available. | 433 // TODO: use IDWriteFactory2::GetSystemFontFallback when available. |
424 | 434 |
425 const DWriteStyle dwStyle(pattern); | 435 const DWriteStyle dwStyle(pattern); |
426 | 436 |
427 SkSMallocWCHAR dwFamilyName; | 437 SkSMallocWCHAR dwFamilyName; |
428 if (NULL == familyName) { | 438 if (NULL == familyName) { |
429 HR_GENERAL(getDefaultFontFamilyName(&dwFamilyName), NULL, identity); | 439 HR_GENERAL(getDefaultFontFamilyName(&dwFamilyName), NULL, identity); |
430 } else { | 440 } else { |
431 HR_GENERAL(sk_cstring_to_wchar(familyName, &dwFamilyName), NULL, ide
ntity); | 441 HR_GENERAL(sk_cstring_to_wchar(familyName, &dwFamilyName), NULL, ide
ntity); |
432 } | 442 } |
433 | 443 |
434 const SkSMallocWCHAR* dwBpc47; | 444 const SkSMallocWCHAR* dwBcp47; |
435 SkSMallocWCHAR dwBpc47Local; | 445 SkSMallocWCHAR dwBcp47Local; |
436 if (NULL == bpc47) { | 446 if (bcp47Count < 1) { |
437 dwBpc47 = &fLocaleName; | 447 dwBcp47 = &fLocaleName; |
438 } else { | 448 } else { |
439 HR_GENERAL(sk_cstring_to_wchar(bpc47, &dwBpc47Local), NULL, identity
); | 449 //TODO: support fallback stack. |
440 dwBpc47 = &dwBpc47Local; | 450 HR_GENERAL(sk_cstring_to_wchar(bcp47[bcp47Count-1], &dwBcp47Local),
NULL, identity); |
| 451 dwBcp47 = &dwBcp47Local; |
441 } | 452 } |
442 | 453 |
443 SkTScopedComPtr<IDWriteTextFormat> fallbackFormat; | 454 SkTScopedComPtr<IDWriteTextFormat> fallbackFormat; |
444 HR_GENERAL(dwFactory->CreateTextFormat(dwFamilyName, | 455 HR_GENERAL(dwFactory->CreateTextFormat(dwFamilyName, |
445 fFontCollection.get(), | 456 fFontCollection.get(), |
446 dwStyle.fWeight, | 457 dwStyle.fWeight, |
447 dwStyle.fSlant, | 458 dwStyle.fSlant, |
448 dwStyle.fWidth, | 459 dwStyle.fWidth, |
449 72.0f, | 460 72.0f, |
450 *dwBpc47, | 461 *dwBcp47, |
451 &fallbackFormat), | 462 &fallbackFormat), |
452 "Could not create text format.", | 463 "Could not create text format.", |
453 identity); | 464 identity); |
454 | 465 |
455 WCHAR str[16]; | 466 WCHAR str[16]; |
456 UINT32 strLen = static_cast<UINT32>( | 467 UINT32 strLen = static_cast<UINT32>( |
457 SkUTF16_FromUnichar(character, reinterpret_cast<uint16_t*>(str))); | 468 SkUTF16_FromUnichar(character, reinterpret_cast<uint16_t*>(str))); |
458 SkTScopedComPtr<IDWriteTextLayout> fallbackLayout; | 469 SkTScopedComPtr<IDWriteTextLayout> fallbackLayout; |
459 HR_GENERAL(dwFactory->CreateTextLayout(str, strLen, fallbackFormat.get()
, | 470 HR_GENERAL(dwFactory->CreateTextLayout(str, strLen, fallbackFormat.get()
, |
460 200.0f, 200.0f, | 471 200.0f, 200.0f, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 } else { | 529 } else { |
519 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); | 530 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N
AME_MAX_LENGTH); |
520 if (localeNameLen) { | 531 if (localeNameLen) { |
521 localeName = localeNameStorage; | 532 localeName = localeNameStorage; |
522 }; | 533 }; |
523 } | 534 } |
524 | 535 |
525 return SkNEW_ARGS(SkRemotableFontMgr_DirectWrite, (sysFontCollection.get(), | 536 return SkNEW_ARGS(SkRemotableFontMgr_DirectWrite, (sysFontCollection.get(), |
526 localeName, localeNameLen
)); | 537 localeName, localeNameLen
)); |
527 } | 538 } |
OLD | NEW |