Commit b0fc9528 authored by Andrea Iacovitti's avatar Andrea Iacovitti

Determine minimum font size once, when computing other font sizes.

parent b201d93f
......@@ -513,7 +513,7 @@ void CSSStyleSelector::computeFontSizesFor(int logicalDpiY, int zoomFactor, QVec
float scale = 1.0;
static const float fontFactors[] = {3.0f/5.0f, 3.0f/4.0f, 8.0f/9.0f, 1.0f, 6.0f/5.0f, 3.0f/2.0f, 2.0f, 3.0f};
static const float smallFontFactors[] = {3.0f/4.0f, 5.0f/6.0f, 8.0f/9.0f, 1.0f, 6.0f/5.0f, 3.0f/2.0f, 2.0f, 3.0f};
float mediumFontSize, minFontSize, factor;
float mediumFontSize, factor;
if (!khtml::printpainter) {
scale *= zoomFactor / 100.0;
#ifdef APPLE_CHANGES
......@@ -522,18 +522,18 @@ void CSSStyleSelector::computeFontSizesFor(int logicalDpiY, int zoomFactor, QVec
else
#endif
mediumFontSize = settings->mediumFontSize() * toPix;
minFontSize = settings->minFontSize() * toPix;
m_minFontSize = settings->minFontSize() * toPix;
}
else {
// ### depending on something / configurable ?
mediumFontSize = 12;
minFontSize = 6;
m_minFontSize = 6;
}
const float* factors = scale*mediumFontSize >= 12.5 ? fontFactors : smallFontFactors;
for ( int i = 0; i < MAXFONTSIZES; i++ ) {
factor = scale*factors[i];
fontSizes[i] = int(qMax( mediumFontSize*factor +.5f, minFontSize));
//kDebug( 6080 ) << "index: " << i << " factor: " << factors[i] << " font pix size: " << int(qMax( mediumFontSize*factor +.5f, minFontSize));
fontSizes[i] = qMax(qRound(mediumFontSize * factor), m_minFontSize);
//kDebug( 6080 ) << "index: " << i << " factor: " << factors[i] << " font pix size: " << qMax(qRound(mediumFontSize*factor), m_minFontSize);
}
}
......@@ -3433,13 +3433,7 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
{
FontDef fontDef = style->htmlFont().fontDef;
int oldSize;
float size = 0;
float toPix = logicalDpiY/72.0f;
if (toPix < 96.0f/72.0f)
toPix = 96.0f/72.0f;
float minFontSize = settings->minFontSize() * toPix;
int size = 0;
if(parentNode) {
oldSize = parentStyle->font().pixelSize();
......@@ -3481,28 +3475,29 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
} else {
int type = primitiveValue->primitiveType();
if(type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
if ( !khtml::printpainter && type != CSSPrimitiveValue::CSS_EMS && type != CSSPrimitiveValue::CSS_EXS &&
view && view->part())
size = primitiveValue->computeLengthFloat(parentStyle, logicalDpiY) *
view->part()->fontScaleFactor() / 100.0;
else
size = primitiveValue->computeLengthFloat(parentStyle, logicalDpiY);
}
else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
size = primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE)
* parentStyle->font().pixelSize() / 100.0;
else
if (type > CSSPrimitiveValue::CSS_PERCENTAGE && type < CSSPrimitiveValue::CSS_DEG) {
if (!khtml::printpainter && type != CSSPrimitiveValue::CSS_EMS && type != CSSPrimitiveValue::CSS_EXS &&
view && view->part()) {
size = qRound(primitiveValue->computeLengthFloat(parentStyle, logicalDpiY) * view->part()->fontScaleFactor() / 100.0);
} else {
size = qRound(primitiveValue->computeLengthFloat(parentStyle, logicalDpiY));
}
} else if (type == CSSPrimitiveValue::CSS_PERCENTAGE) {
size = qRound(primitiveValue->floatValue(CSSPrimitiveValue::CSS_PERCENTAGE) * parentStyle->font().pixelSize() / 100.0);
} else {
return;
}
}
// we never want to get smaller than the minimum font size to keep fonts readable
// do not however maximize zero as that is commonly used for fancy layouting purposes
if (size && size < minFontSize) size = minFontSize;
// we never want to get smaller than the minimum font size to keep fonts readable
// do not however maximize zero as that is commonly used for fancy layouting purposes
if (size) {
size = qMax(size, m_minFontSize);
}
}
//kDebug( 6080 ) << "computed raw font size: " << size;
fontDef.size = qRound(size);
fontDef.size = size;
fontDirty |= style->setFontDef( fontDef );
return;
}
......
......@@ -331,6 +331,7 @@ public:
RenderStyle* m_rootDefaultStyle;
QVector<int> m_fontSizes;
QVector<int> m_fixedFontSizes;
int m_minFontSize;
bool fontDirty;
DOM::CSSFontSelector* m_fontSelector;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment