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