Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1223)

Side by Side Diff: Source/platform/fonts/mac/FontCacheMac.mm

Issue 879533003: Remove Mac native font type members from FontPlatformData (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removing getNSFont from SimpleFontData Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 3 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
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 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if (character <= 0xFFFF) { 110 if (character <= 0xFFFF) {
111 codeUnits[0] = character; 111 codeUnits[0] = character;
112 codeUnitsLength = 1; 112 codeUnitsLength = 1;
113 } else { 113 } else {
114 codeUnits[0] = U16_LEAD(character); 114 codeUnits[0] = U16_LEAD(character);
115 codeUnits[1] = U16_TRAIL(character); 115 codeUnits[1] = U16_TRAIL(character);
116 codeUnitsLength = 2; 116 codeUnitsLength = 2;
117 } 117 }
118 118
119 const FontPlatformData& platformData = fontDataToSubstitute->platformData(); 119 const FontPlatformData& platformData = fontDataToSubstitute->platformData();
120 NSFont *nsFont = platformData.font(); 120 NSFont* nsFont = const_cast<NSFont*>(reinterpret_cast<const NSFont*>(platfor mData.ctFont()));
Robert Sesek 2015/02/24 16:13:07 Can you create something lke toCTFontRef() or leav
Dominik Röttsches 2015/03/19 15:20:00 Added toNSFont to FontPlatformData.h
121 121
122 NSString *string = [[NSString alloc] initWithCharactersNoCopy:codeUnits leng th:codeUnitsLength freeWhenDone:NO]; 122 NSString *string = [[NSString alloc] initWithCharactersNoCopy:codeUnits leng th:codeUnitsLength freeWhenDone:NO];
123 NSFont *substituteFont = [NSFont findFontLike:nsFont forString:string withRa nge:NSMakeRange(0, codeUnitsLength) inLanguage:nil]; 123 NSFont *substituteFont = [NSFont findFontLike:nsFont forString:string withRa nge:NSMakeRange(0, codeUnitsLength) inLanguage:nil];
124 [string release]; 124 [string release];
125 125
126 // FIXME: Remove this SPI usage: http://crbug.com/255122 126 // FIXME: Remove this SPI usage: http://crbug.com/255122
127 if (!substituteFont && codeUnitsLength == 1) 127 if (!substituteFont && codeUnitsLength == 1)
128 substituteFont = [NSFont findFontLike:nsFont forCharacter:codeUnits[0] i nLanguage:nil]; 128 substituteFont = [NSFont findFontLike:nsFont forCharacter:codeUnits[0] i nLanguage:nil];
129 if (!substituteFont) 129 if (!substituteFont)
130 return nullptr; 130 return nullptr;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 NSFontManager *fontManager = [NSFontManager sharedFontManager]; 211 NSFontManager *fontManager = [NSFontManager sharedFontManager];
212 NSFontTraitMask actualTraits = 0; 212 NSFontTraitMask actualTraits = 0;
213 if (fontDescription.style()) 213 if (fontDescription.style())
214 actualTraits = [fontManager traitsOfFont:nsFont]; 214 actualTraits = [fontManager traitsOfFont:nsFont];
215 NSInteger actualWeight = [fontManager weightOfFont:nsFont]; 215 NSInteger actualWeight = [fontManager weightOfFont:nsFont];
216 216
217 NSFont *platformFont = useHinting() ? [nsFont screenFont] : [nsFont printerF ont]; 217 NSFont *platformFont = useHinting() ? [nsFont screenFont] : [nsFont printerF ont];
218 bool syntheticBold = (isAppKitFontWeightBold(weight) && !isAppKitFontWeightB old(actualWeight)) || fontDescription.isSyntheticBold(); 218 bool syntheticBold = (isAppKitFontWeightBold(weight) && !isAppKitFontWeightB old(actualWeight)) || fontDescription.isSyntheticBold();
219 bool syntheticItalic = ((traits & NSFontItalicTrait) && !(actualTraits & NSF ontItalicTrait)) || fontDescription.isSyntheticItalic(); 219 bool syntheticItalic = ((traits & NSFontItalicTrait) && !(actualTraits & NSF ontItalicTrait)) || fontDescription.isSyntheticItalic();
220 220
221 // FontPlatformData::font() can be null for the case of Chromium out-of-proc ess font loading. 221 // FontPlatformData::typeface() is null in the case of Chromium out-of-proce ss font loading failing.
222 // In that case, we don't want to use the platformData. 222 // Out-of-process loading occurs for registered fonts stored in non-system l ocations.
223 // When loading fails, we do not want to use the returned FontPlatformData s ince it will not have
224 // a valid SkTypeface.
223 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, syntheticBold, syntheticItalic, fontDescription.orientation())); 225 OwnPtr<FontPlatformData> platformData = adoptPtr(new FontPlatformData(platfo rmFont, size, syntheticBold, syntheticItalic, fontDescription.orientation()));
224 if (!platformData->font()) 226 if (!platformData->typeface()) {
225 return 0; 227 return nullptr;
228 }
226 return platformData.leakPtr(); 229 return platformData.leakPtr();
227 } 230 }
228 231
229 } // namespace blink 232 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698