Changeset 73425 in webkit
- Timestamp:
- Dec 6, 2010 9:05:12 PM (13 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r73424 r73425 1 2010-12-06 Hironori Bono <hbono@chromium.org> 2 3 Reviewed by David Levin. 4 5 [Chromium] Refactor FontCacheChromiumWin.cpp 6 https://bugs.webkit.org/show_bug.cgi?id=50611 7 8 This change just moved the helper functions for the WebCore::FontCache class to the beginning of ths file. 9 10 No new tests are added since this is a refactoring. 11 12 * platform/graphics/chromium/FontCacheChromiumWin.cpp: 13 (WebCore::fontDataFromDescriptionAndLogFont): Moved to the beginning of the file. 14 (WebCore::toGDIFontWeight): Moved to the beginning of the file. 15 (WebCore::FillLogFont): Moved to the beginning of the file. 16 (WebCore::TraitsInFamilyProcData::TraitsInFamilyProcData): Moved to the beginning of the file. 17 (WebCore::traitsInFamilyEnumProc): Moved to the beginning of the file. 18 (WebCore::FontCache::platformInit): Moved after the static functions. 19 1 20 2010-12-06 Alexey Marinichev <amarinichev@chromium.org> 2 21 -
trunk/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp
r73116 r73425 50 50 namespace WebCore 51 51 { 52 53 void FontCache::platformInit()54 {55 // Not needed on Windows.56 }57 52 58 53 // FIXME: consider adding to WebKit String class … … 330 325 } 331 326 327 // Tries the given font and save it |outFontFamilyName| if it succeeds. 328 static SimpleFontData* fontDataFromDescriptionAndLogFont(FontCache* fontCache, const FontDescription& fontDescription, const LOGFONT& font, wchar_t* outFontFamilyName) 329 { 330 SimpleFontData* fontData = fontCache->getCachedFontData(fontDescription, font.lfFaceName); 331 if (fontData) 332 memcpy(outFontFamilyName, font.lfFaceName, sizeof(font.lfFaceName)); 333 return fontData; 334 } 335 336 static LONG toGDIFontWeight(FontWeight fontWeight) 337 { 338 static LONG gdiFontWeights[] = { 339 FW_THIN, // FontWeight100 340 FW_EXTRALIGHT, // FontWeight200 341 FW_LIGHT, // FontWeight300 342 FW_NORMAL, // FontWeight400 343 FW_MEDIUM, // FontWeight500 344 FW_SEMIBOLD, // FontWeight600 345 FW_BOLD, // FontWeight700 346 FW_EXTRABOLD, // FontWeight800 347 FW_HEAVY // FontWeight900 348 }; 349 return gdiFontWeights[fontWeight]; 350 } 351 352 static void FillLogFont(const FontDescription& fontDescription, LOGFONT* winfont) 353 { 354 // The size here looks unusual. The negative number is intentional. 355 // Unlike WebKit trunk, we don't multiply the size by 32. That seems to be 356 // some kind of artifact of their CG backend, or something. 357 winfont->lfHeight = -fontDescription.computedPixelSize(); 358 winfont->lfWidth = 0; 359 winfont->lfEscapement = 0; 360 winfont->lfOrientation = 0; 361 winfont->lfUnderline = false; 362 winfont->lfStrikeOut = false; 363 winfont->lfCharSet = DEFAULT_CHARSET; 364 winfont->lfOutPrecision = OUT_TT_ONLY_PRECIS; 365 winfont->lfQuality = ChromiumBridge::layoutTestMode() ? NONANTIALIASED_QUALITY : DEFAULT_QUALITY; // Honor user's desktop settings. 366 winfont->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; 367 winfont->lfItalic = fontDescription.italic(); 368 winfont->lfWeight = toGDIFontWeight(fontDescription.weight()); 369 } 370 371 struct TraitsInFamilyProcData { 372 TraitsInFamilyProcData(const AtomicString& familyName) 373 : m_familyName(familyName) 374 { 375 } 376 377 const AtomicString& m_familyName; 378 HashSet<unsigned> m_traitsMasks; 379 }; 380 381 static int CALLBACK traitsInFamilyEnumProc(CONST LOGFONT* logFont, CONST TEXTMETRIC* metrics, DWORD fontType, LPARAM lParam) 382 { 383 TraitsInFamilyProcData* procData = reinterpret_cast<TraitsInFamilyProcData*>(lParam); 384 385 unsigned traitsMask = 0; 386 traitsMask |= logFont->lfItalic ? FontStyleItalicMask : FontStyleNormalMask; 387 traitsMask |= FontVariantNormalMask; 388 LONG weight = logFont->lfWeight; 389 traitsMask |= weight == FW_THIN ? FontWeight100Mask : 390 weight == FW_EXTRALIGHT ? FontWeight200Mask : 391 weight == FW_LIGHT ? FontWeight300Mask : 392 weight == FW_NORMAL ? FontWeight400Mask : 393 weight == FW_MEDIUM ? FontWeight500Mask : 394 weight == FW_SEMIBOLD ? FontWeight600Mask : 395 weight == FW_BOLD ? FontWeight700Mask : 396 weight == FW_EXTRABOLD ? FontWeight800Mask : 397 FontWeight900Mask; 398 procData->m_traitsMasks.add(traitsMask); 399 return 1; 400 } 401 402 void FontCache::platformInit() 403 { 404 // Not needed on Windows. 405 } 406 332 407 // Given the desired base font, this will create a SimpleFontData for a specific 333 408 // font that can be used to render the given range of characters. … … 422 497 } 423 498 424 // Tries the given font and save it |outFontFamilyName| if it succeeds.425 static SimpleFontData* fontDataFromDescriptionAndLogFont(FontCache* fontCache, const FontDescription& fontDescription, const LOGFONT& font, wchar_t* outFontFamilyName)426 {427 SimpleFontData* fontData = fontCache->getCachedFontData(fontDescription, font.lfFaceName);428 if (fontData)429 memcpy(outFontFamilyName, font.lfFaceName, sizeof(font.lfFaceName));430 return fontData;431 }432 433 499 SimpleFontData* FontCache::getLastResortFallbackFont(const FontDescription& description) 434 500 { … … 485 551 ASSERT_NOT_REACHED(); 486 552 return 0; 487 }488 489 static LONG toGDIFontWeight(FontWeight fontWeight)490 {491 static LONG gdiFontWeights[] = {492 FW_THIN, // FontWeight100493 FW_EXTRALIGHT, // FontWeight200494 FW_LIGHT, // FontWeight300495 FW_NORMAL, // FontWeight400496 FW_MEDIUM, // FontWeight500497 FW_SEMIBOLD, // FontWeight600498 FW_BOLD, // FontWeight700499 FW_EXTRABOLD, // FontWeight800500 FW_HEAVY // FontWeight900501 };502 return gdiFontWeights[fontWeight];503 }504 505 static void FillLogFont(const FontDescription& fontDescription, LOGFONT* winfont)506 {507 // The size here looks unusual. The negative number is intentional.508 // Unlike WebKit trunk, we don't multiply the size by 32. That seems to be509 // some kind of artifact of their CG backend, or something.510 winfont->lfHeight = -fontDescription.computedPixelSize();511 winfont->lfWidth = 0;512 winfont->lfEscapement = 0;513 winfont->lfOrientation = 0;514 winfont->lfUnderline = false;515 winfont->lfStrikeOut = false;516 winfont->lfCharSet = DEFAULT_CHARSET;517 winfont->lfOutPrecision = OUT_TT_ONLY_PRECIS;518 winfont->lfQuality = ChromiumBridge::layoutTestMode() ? NONANTIALIASED_QUALITY : DEFAULT_QUALITY; // Honor user's desktop settings.519 winfont->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;520 winfont->lfItalic = fontDescription.italic();521 winfont->lfWeight = toGDIFontWeight(fontDescription.weight());522 }523 524 struct TraitsInFamilyProcData {525 TraitsInFamilyProcData(const AtomicString& familyName)526 : m_familyName(familyName)527 {528 }529 530 const AtomicString& m_familyName;531 HashSet<unsigned> m_traitsMasks;532 };533 534 static int CALLBACK traitsInFamilyEnumProc(CONST LOGFONT* logFont, CONST TEXTMETRIC* metrics, DWORD fontType, LPARAM lParam)535 {536 TraitsInFamilyProcData* procData = reinterpret_cast<TraitsInFamilyProcData*>(lParam);537 538 unsigned traitsMask = 0;539 traitsMask |= logFont->lfItalic ? FontStyleItalicMask : FontStyleNormalMask;540 traitsMask |= FontVariantNormalMask;541 LONG weight = logFont->lfWeight;542 traitsMask |= weight == FW_THIN ? FontWeight100Mask :543 weight == FW_EXTRALIGHT ? FontWeight200Mask :544 weight == FW_LIGHT ? FontWeight300Mask :545 weight == FW_NORMAL ? FontWeight400Mask :546 weight == FW_MEDIUM ? FontWeight500Mask :547 weight == FW_SEMIBOLD ? FontWeight600Mask :548 weight == FW_BOLD ? FontWeight700Mask :549 weight == FW_EXTRABOLD ? FontWeight800Mask :550 FontWeight900Mask;551 procData->m_traitsMasks.add(traitsMask);552 return 1;553 553 } 554 554
Note: See TracChangeset
for help on using the changeset viewer.