| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Computer, Inc. | 2 * Copyright (C) 2006, 2007 Apple Computer, Inc. |
| 3 * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. All rights reserved. | 3 * Copyright (c) 2006, 2007, 2008, 2009, 2012 Google Inc. 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #include "SkFontMgr.h" | 34 #include "SkFontMgr.h" |
| 35 #include "SkTypeface_win.h" | 35 #include "SkTypeface_win.h" |
| 36 #include "platform/Language.h" | 36 #include "platform/Language.h" |
| 37 #include "platform/RuntimeEnabledFeatures.h" | 37 #include "platform/RuntimeEnabledFeatures.h" |
| 38 #include "platform/fonts/FontDescription.h" | 38 #include "platform/fonts/FontDescription.h" |
| 39 #include "platform/fonts/FontFaceCreationParams.h" | 39 #include "platform/fonts/FontFaceCreationParams.h" |
| 40 #include "platform/fonts/FontPlatformData.h" | 40 #include "platform/fonts/FontPlatformData.h" |
| 41 #include "platform/fonts/SimpleFontData.h" | 41 #include "platform/fonts/SimpleFontData.h" |
| 42 #include "platform/fonts/win/FontFallbackWin.h" | 42 #include "platform/fonts/win/FontFallbackWin.h" |
| 43 #include "wtf/PtrUtil.h" |
| 44 #include <memory> |
| 43 | 45 |
| 44 namespace blink { | 46 namespace blink { |
| 45 | 47 |
| 46 HashMap<String, RefPtr<SkTypeface>>* FontCache::s_sideloadedFonts = 0; | 48 HashMap<String, RefPtr<SkTypeface>>* FontCache::s_sideloadedFonts = 0; |
| 47 | 49 |
| 48 // Cached system font metrics. | 50 // Cached system font metrics. |
| 49 AtomicString* FontCache::s_menuFontFamilyName = 0; | 51 AtomicString* FontCache::s_menuFontFamilyName = 0; |
| 50 int32_t FontCache::s_menuFontHeight = 0; | 52 int32_t FontCache::s_menuFontHeight = 0; |
| 51 AtomicString* FontCache::s_smallCaptionFontFamilyName = 0; | 53 AtomicString* FontCache::s_smallCaptionFontFamilyName = 0; |
| 52 int32_t FontCache::s_smallCaptionFontHeight = 0; | 54 int32_t FontCache::s_smallCaptionFontHeight = 0; |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 familyName.truncate(family.length() - entry.length); | 350 familyName.truncate(family.length() - entry.length); |
| 349 adjustedName = AtomicString(familyName); | 351 adjustedName = AtomicString(familyName); |
| 350 variantStretch = entry.stretch; | 352 variantStretch = entry.stretch; |
| 351 return true; | 353 return true; |
| 352 } | 354 } |
| 353 } | 355 } |
| 354 | 356 |
| 355 return false; | 357 return false; |
| 356 } | 358 } |
| 357 | 359 |
| 358 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip
tion& fontDescription, | 360 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDe
scription& fontDescription, |
| 359 const FontFaceCreationParams& creationParams, float fontSize) | 361 const FontFaceCreationParams& creationParams, float fontSize) |
| 360 { | 362 { |
| 361 ASSERT(creationParams.creationType() == CreateFontByFamily); | 363 ASSERT(creationParams.creationType() == CreateFontByFamily); |
| 362 | 364 |
| 363 CString name; | 365 CString name; |
| 364 RefPtr<SkTypeface> tf = createTypeface(fontDescription, creationParams, name
); | 366 RefPtr<SkTypeface> tf = createTypeface(fontDescription, creationParams, name
); |
| 365 // Windows will always give us a valid pointer here, even if the face name | 367 // Windows will always give us a valid pointer here, even if the face name |
| 366 // is non-existent. We have to double-check and see if the family name was | 368 // is non-existent. We have to double-check and see if the family name was |
| 367 // really used. | 369 // really used. |
| 368 if (!tf || !typefacesMatchesFamily(tf.get(), creationParams.family())) { | 370 if (!tf || !typefacesMatchesFamily(tf.get(), creationParams.family())) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 386 adjustedFontDescription.setStretch(variantStretch); | 388 adjustedFontDescription.setStretch(variantStretch); |
| 387 tf = createTypeface(adjustedFontDescription, adjustedParams, name); | 389 tf = createTypeface(adjustedFontDescription, adjustedParams, name); |
| 388 if (!tf || !typefacesMatchesFamily(tf.get(), adjustedName)) | 390 if (!tf || !typefacesMatchesFamily(tf.get(), adjustedName)) |
| 389 return nullptr; | 391 return nullptr; |
| 390 | 392 |
| 391 } else { | 393 } else { |
| 392 return nullptr; | 394 return nullptr; |
| 393 } | 395 } |
| 394 } | 396 } |
| 395 | 397 |
| 396 OwnPtr<FontPlatformData> result = adoptPtr(new FontPlatformData(tf, | 398 std::unique_ptr<FontPlatformData> result = wrapUnique(new FontPlatformData(t
f, |
| 397 name.data(), | 399 name.data(), |
| 398 fontSize, | 400 fontSize, |
| 399 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc
ription.isSyntheticBold(), | 401 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc
ription.isSyntheticBold(), |
| 400 ((fontDescription.style() == FontStyleItalic || fontDescription.style()
== FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(), | 402 ((fontDescription.style() == FontStyleItalic || fontDescription.style()
== FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(), |
| 401 fontDescription.orientation())); | 403 fontDescription.orientation())); |
| 402 | 404 |
| 403 struct FamilyMinSize { | 405 struct FamilyMinSize { |
| 404 const wchar_t* family; | 406 const wchar_t* family; |
| 405 unsigned minSize; | 407 unsigned minSize; |
| 406 }; | 408 }; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 if (typefacesMatchesFamily(tf.get(), family)) { | 447 if (typefacesMatchesFamily(tf.get(), family)) { |
| 446 result->setMinSizeForSubpixel(minSizeForSubpixelForFont); | 448 result->setMinSizeForSubpixel(minSizeForSubpixelForFont); |
| 447 break; | 449 break; |
| 448 } | 450 } |
| 449 } | 451 } |
| 450 | 452 |
| 451 return result; | 453 return result; |
| 452 } | 454 } |
| 453 | 455 |
| 454 } // namespace blink | 456 } // namespace blink |
| OLD | NEW |