| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2010, 2011 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov | 3 * Copyright (C) 2006 Alexey Proskuryakov |
| 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 // such fonts meant the same distance, but in the reverse direction. | 206 // such fonts meant the same distance, but in the reverse direction. |
| 207 iDescent = -abs(CGFontGetDescent(m_platformData.cgFont())); | 207 iDescent = -abs(CGFontGetDescent(m_platformData.cgFont())); |
| 208 iLineGap = CGFontGetLeading(m_platformData.cgFont()); | 208 iLineGap = CGFontGetLeading(m_platformData.cgFont()); |
| 209 unitsPerEm = CGFontGetUnitsPerEm(m_platformData.cgFont()); | 209 unitsPerEm = CGFontGetUnitsPerEm(m_platformData.cgFont()); |
| 210 | 210 |
| 211 float pointSize = m_platformData.m_size; | 211 float pointSize = m_platformData.m_size; |
| 212 float ascent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize; | 212 float ascent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize; |
| 213 float descent = -scaleEmToUnits(iDescent, unitsPerEm) * pointSize; | 213 float descent = -scaleEmToUnits(iDescent, unitsPerEm) * pointSize; |
| 214 float lineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize; | 214 float lineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize; |
| 215 float underlineThickness = CTFontGetUnderlineThickness(m_platformData.ctFont
()); | 215 float underlineThickness = CTFontGetUnderlineThickness(m_platformData.ctFont
()); |
| 216 float underlinePosition = CTFontGetUnderlinePosition(m_platformData.ctFont()
); |
| 216 | 217 |
| 217 // We need to adjust Times, Helvetica, and Courier to closely match the | 218 // We need to adjust Times, Helvetica, and Courier to closely match the |
| 218 // vertical metrics of their Microsoft counterparts that are the de facto | 219 // vertical metrics of their Microsoft counterparts that are the de facto |
| 219 // web standard. The AppKit adjustment of 20% is too big and is | 220 // web standard. The AppKit adjustment of 20% is too big and is |
| 220 // incorrectly added to line spacing, so we use a 15% adjustment instead | 221 // incorrectly added to line spacing, so we use a 15% adjustment instead |
| 221 // and add it to the ascent. | 222 // and add it to the ascent. |
| 222 NSString *familyName = [m_platformData.font() familyName]; | 223 NSString *familyName = [m_platformData.font() familyName]; |
| 223 if ([familyName isEqualToString:@"Times"] || [familyName isEqualToString:@"H
elvetica"] || [familyName isEqualToString:@"Courier"]) | 224 if ([familyName isEqualToString:@"Times"] || [familyName isEqualToString:@"H
elvetica"] || [familyName isEqualToString:@"Courier"]) |
| 224 ascent += floorf(((ascent + descent) * 0.15f) + 0.5f); | 225 ascent += floorf(((ascent + descent) * 0.15f) + 0.5f); |
| 225 | 226 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 249 xHeight = scaleEmToUnits(CGFontGetXHeight(m_platformData.cgFont()),
unitsPerEm) * pointSize; | 250 xHeight = scaleEmToUnits(CGFontGetXHeight(m_platformData.cgFont()),
unitsPerEm) * pointSize; |
| 250 } else | 251 } else |
| 251 xHeight = verticalRightOrientationFontData()->fontMetrics().xHeight(); | 252 xHeight = verticalRightOrientationFontData()->fontMetrics().xHeight(); |
| 252 | 253 |
| 253 m_fontMetrics.setUnitsPerEm(unitsPerEm); | 254 m_fontMetrics.setUnitsPerEm(unitsPerEm); |
| 254 m_fontMetrics.setAscent(ascent); | 255 m_fontMetrics.setAscent(ascent); |
| 255 m_fontMetrics.setDescent(descent); | 256 m_fontMetrics.setDescent(descent); |
| 256 m_fontMetrics.setLineGap(lineGap); | 257 m_fontMetrics.setLineGap(lineGap); |
| 257 m_fontMetrics.setXHeight(xHeight); | 258 m_fontMetrics.setXHeight(xHeight); |
| 258 m_fontMetrics.setUnderlineThickness(underlineThickness); | 259 m_fontMetrics.setUnderlineThickness(underlineThickness); |
| 260 m_fontMetrics.setUnderlinePosition(underlinePosition); |
| 259 } | 261 } |
| 260 | 262 |
| 261 static CFDataRef copyFontTableForTag(FontPlatformData& platformData, FourCharCod
e tableName) | 263 static CFDataRef copyFontTableForTag(FontPlatformData& platformData, FourCharCod
e tableName) |
| 262 { | 264 { |
| 263 return CGFontCopyTableForTag(platformData.cgFont(), tableName); | 265 return CGFontCopyTableForTag(platformData.cgFont(), tableName); |
| 264 } | 266 } |
| 265 | 267 |
| 266 void SimpleFontData::platformCharWidthInit() | 268 void SimpleFontData::platformCharWidthInit() |
| 267 { | 269 { |
| 268 m_avgCharWidth = 0; | 270 m_avgCharWidth = 0; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 RetainPtr<CGFontRef> runCGFont(AdoptCF, CTFontCopyGraphicsFont(runFont,
0)); | 439 RetainPtr<CGFontRef> runCGFont(AdoptCF, CTFontCopyGraphicsFont(runFont,
0)); |
| 438 if (!CFEqual(runCGFont.get(), cgFont.get())) | 440 if (!CFEqual(runCGFont.get(), cgFont.get())) |
| 439 return false; | 441 return false; |
| 440 } | 442 } |
| 441 | 443 |
| 442 addResult.storedValue->value = true; | 444 addResult.storedValue->value = true; |
| 443 return true; | 445 return true; |
| 444 } | 446 } |
| 445 | 447 |
| 446 } // namespace WebCore | 448 } // namespace WebCore |
| OLD | NEW |