OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. | 3 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc.
All rights reserved. |
4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. All rights reserved. |
5 * Copyright (C) 2015 Collabora Ltd. All rights reserved. | 5 * Copyright (C) 2015 Collabora Ltd. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 if (!specifiedSize && fontDescription.keywordSize()) | 322 if (!specifiedSize && fontDescription.keywordSize()) |
323 specifiedSize = FontSize::fontSizeForKeyword(&m_document, fontDescriptio
n.keywordSize(), fontDescription.fixedPitchFontType()); | 323 specifiedSize = FontSize::fontSizeForKeyword(&m_document, fontDescriptio
n.keywordSize(), fontDescription.fixedPitchFontType()); |
324 | 324 |
325 fontDescription.setSpecifiedSize(specifiedSize); | 325 fontDescription.setSpecifiedSize(specifiedSize); |
326 | 326 |
327 checkForGenericFamilyChange(style.fontDescription(), fontDescription); | 327 checkForGenericFamilyChange(style.fontDescription(), fontDescription); |
328 } | 328 } |
329 | 329 |
330 void FontBuilder::updateAdjustedSize(FontDescription& fontDescription, const Lay
outStyle& style, FontSelector* fontSelector) | 330 void FontBuilder::updateAdjustedSize(FontDescription& fontDescription, const Lay
outStyle& style, FontSelector* fontSelector) |
331 { | 331 { |
332 const float sizeAdjust = fontDescription.sizeAdjust(); | |
333 const float specifiedSize = fontDescription.specifiedSize(); | 332 const float specifiedSize = fontDescription.specifiedSize(); |
334 if (!sizeAdjust || !specifiedSize) | 333 if (!fontDescription.hasSizeAdjust() || !specifiedSize) |
335 return; | 334 return; |
336 | 335 |
337 // We need to create a temporal Font to get xHeight of a primary font. | 336 // We need to create a temporal Font to get xHeight of a primary font. |
338 // The aspect value is based on the xHeight of the font for the computed fon
t size, | 337 // The aspect value is based on the xHeight of the font for the computed fon
t size, |
339 // so we need to reset the adjustment. | 338 // so we need to reset the adjustedSize to computedSize. See FontDescription
::effectiveFontSize. |
340 fontDescription.setAdjustedSize(0); | 339 fontDescription.setAdjustedSize(fontDescription.computedSize()); |
341 | 340 |
342 Font font(fontDescription); | 341 Font font(fontDescription); |
343 font.update(fontSelector); | 342 font.update(fontSelector); |
344 if (!font.fontMetrics().hasXHeight()) | 343 if (!font.fontMetrics().hasXHeight()) |
345 return; | 344 return; |
346 | 345 |
| 346 const float sizeAdjust = fontDescription.sizeAdjust(); |
347 float aspectValue = font.fontMetrics().xHeight() / specifiedSize; | 347 float aspectValue = font.fontMetrics().xHeight() / specifiedSize; |
348 float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize; | 348 float adjustedSize = (sizeAdjust / aspectValue) * specifiedSize; |
349 adjustedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effec
tiveZoom(), adjustedSize); | 349 adjustedSize = getComputedSizeFromSpecifiedSize(fontDescription, style.effec
tiveZoom(), adjustedSize); |
350 | 350 |
351 float multiplier = style.textAutosizingMultiplier(); | 351 float multiplier = style.textAutosizingMultiplier(); |
352 if (multiplier > 1) | 352 if (multiplier > 1) |
353 adjustedSize = TextAutosizer::computeAutosizedFontSize(adjustedSize, mul
tiplier); | 353 adjustedSize = TextAutosizer::computeAutosizedFontSize(adjustedSize, mul
tiplier); |
354 fontDescription.setAdjustedSize(adjustedSize); | 354 fontDescription.setAdjustedSize(adjustedSize); |
355 } | 355 } |
356 | 356 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 FontOrientation fontOrientation; | 429 FontOrientation fontOrientation; |
430 NonCJKGlyphOrientation glyphOrientation; | 430 NonCJKGlyphOrientation glyphOrientation; |
431 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation)
; | 431 getFontAndGlyphOrientation(documentStyle, fontOrientation, glyphOrientation)
; |
432 fontDescription.setOrientation(fontOrientation); | 432 fontDescription.setOrientation(fontOrientation); |
433 fontDescription.setNonCJKGlyphOrientation(glyphOrientation); | 433 fontDescription.setNonCJKGlyphOrientation(glyphOrientation); |
434 documentStyle.setFontDescription(fontDescription); | 434 documentStyle.setFontDescription(fontDescription); |
435 documentStyle.font().update(fontSelector); | 435 documentStyle.font().update(fontSelector); |
436 } | 436 } |
437 | 437 |
438 } | 438 } |
OLD | NEW |