Changeset 846 for trunk/src/gui/text/qfontengine_ft.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/text/qfontengine_ft.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 52 52 #include "qthreadstorage.h" 53 53 #include <qmath.h> 54 #include <private/qpdf_p.h>55 54 #include <private/qharfbuzz_p.h> 56 55 … … 59 58 #include FT_FREETYPE_H 60 59 #include FT_OUTLINE_H 60 #include FT_SYNTHESIS_H 61 61 #include FT_TRUETYPE_TABLES_H 62 62 #include FT_TYPE1_TABLES_H … … 92 92 #define X_SIZE(face,i) ((face)->available_sizes[i].width << 6) 93 93 #define Y_SIZE(face,i) ((face)->available_sizes[i].height << 6) 94 #endif 95 96 /* FreeType 2.1.10 starts to provide FT_GlyphSlot_Embolden */ 97 #if (FREETYPE_MAJOR*10000+FREETYPE_MINOR*100+FREETYPE_PATCH) >= 20110 98 #define Q_FT_GLYPHSLOT_EMBOLDEN(slot) FT_GlyphSlot_Embolden(slot) 99 #else 100 #define Q_FT_GLYPHSLOT_EMBOLDEN(slot) 94 101 #endif 95 102 … … 618 625 kerning_pairs_loaded = false; 619 626 transform = false; 627 embolden = false; 620 628 antialias = true; 621 629 freetype = 0; 622 default_load_flags = 0;630 default_load_flags = FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; 623 631 default_hint_style = HintNone; 624 632 subpixelType = Subpixel_None; … … 680 688 FT_Face face = lockFace(); 681 689 682 //underline metrics683 690 if (FT_IS_SCALABLE(face)) { 684 line_thickness = QFixed::fromFixed(FT_MulFix(face->underline_thickness, face->size->metrics.y_scale));685 underline_position = QFixed::fromFixed(-FT_MulFix(face->underline_position, face->size->metrics.y_scale));686 691 bool fake_oblique = (fontDef.style != QFont::StyleNormal) && !(face->style_flags & FT_STYLE_FLAG_ITALIC); 687 692 if (fake_oblique) … … 691 696 if (fake_oblique) 692 697 transform = true; 698 // fake bold 699 if ((fontDef.weight == QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD) && !FT_IS_FIXED_WIDTH(face)) 700 embolden = true; 701 // underline metrics 702 line_thickness = QFixed::fromFixed(FT_MulFix(face->underline_thickness, face->size->metrics.y_scale)); 703 underline_position = QFixed::fromFixed(-FT_MulFix(face->underline_position, face->size->metrics.y_scale)); 693 704 } else { 694 705 // copied from QFontEngineQPF … … 747 758 QFontEngineFT::Glyph *QFontEngineFT::loadGlyphMetrics(QGlyphSet *set, uint glyph) const 748 759 { 749 Glyph *g = set->g lyph_data.value(glyph);760 Glyph *g = set->getGlyph(glyph); 750 761 if (g) 751 762 return g; … … 790 801 791 802 FT_GlyphSlot slot = face->glyph; 803 if (embolden) Q_FT_GLYPHSLOT_EMBOLDEN(slot); 792 804 int left = slot->metrics.horiBearingX; 793 805 int right = slot->metrics.horiBearingX + slot->metrics.width; … … 859 871 } 860 872 861 Glyph *g = set->g lyph_data.value(glyph);873 Glyph *g = set->getGlyph(glyph); 862 874 if (g && g->format == format) { 863 875 if (uploadToServer && !g->uploadedToServer) { 864 set-> glyph_data[glyph] = 0;876 set->setGlyph(glyph, 0); 865 877 delete g; 866 878 g = 0; … … 935 947 936 948 FT_GlyphSlot slot = face->glyph; 949 if (embolden) Q_FT_GLYPHSLOT_EMBOLDEN(slot); 937 950 FT_Library library = qt_getFreetype(); 938 951 … … 1159 1172 } 1160 1173 1161 set-> glyph_data[glyph] = g;1174 set->setGlyph(glyph, g); 1162 1175 1163 1176 return g; … … 1183 1196 Properties p = freetype->properties(); 1184 1197 if (p.postscriptName.isEmpty()) { 1185 p.postscriptName = fontDef.family.toUtf8(); 1186 #ifndef QT_NO_PRINTER 1187 p.postscriptName = QPdf::stripSpecialCharacters(p.postscriptName); 1188 #endif 1198 p.postscriptName = QFontEngine::convertToPostscriptFontFamilyName(fontDef.family.toUtf8()); 1189 1199 } 1190 1200 … … 1210 1220 if ((fontDef.style != QFont::StyleNormal) && !(freetype->face->style_flags & FT_STYLE_FLAG_ITALIC)) 1211 1221 s = SynthesizedItalic; 1222 if ((fontDef.weight == QFont::Bold) && !(freetype->face->style_flags & FT_STYLE_FLAG_BOLD)) 1223 s |= SynthesizedBold; 1212 1224 if (fontDef.stretch != 100 && FT_IS_SCALABLE(freetype->face)) 1213 1225 s |= SynthesizedStretch; … … 1369 1381 if (!gs) { 1370 1382 // don't try to load huge fonts 1371 bool draw_as_outline = fontDef.pixelSize * qSqrt( matrix.det()) >= 64;1383 bool draw_as_outline = fontDef.pixelSize * qSqrt(qAbs(matrix.det())) >= 64; 1372 1384 if (draw_as_outline) 1373 1385 return 0; … … 1382 1394 gs = &transformedGlyphSets[0]; 1383 1395 1384 qDeleteAll(gs->glyph_data); 1385 gs->glyph_data.clear(); 1396 gs->clear(); 1386 1397 1387 1398 gs->id = allocateServerGlyphSet(); … … 1399 1410 1400 1411 for (int i = 0; i < num_glyphs; ++i) { 1401 Glyph *glyph = gs->g lyph_data.value(glyphs[i]);1412 Glyph *glyph = gs->getGlyph(glyphs[i]); 1402 1413 if (glyph == 0 || glyph->format != format) { 1403 1414 if (!face) { … … 1551 1562 for ( int i = 0; i < len; ++i ) { 1552 1563 unsigned int uc = getChar(str, i, len); 1553 if (mirrored)1554 uc = QChar::mirroredChar(uc);1555 1564 glyphs->glyphs[glyph_pos] = uc < QFreetypeFace::cmapCacheSize ? freetype->cmapCache[uc] : 0; 1556 1565 if ( !glyphs->glyphs[glyph_pos] ) { … … 1636 1645 if (flags & QTextEngine::DesignMetrics) { 1637 1646 for (int i = 0; i < glyphs->numGlyphs; i++) { 1638 Glyph *g = defaultGlyphSet.g lyph_data.value(glyphs->glyphs[i]);1647 Glyph *g = defaultGlyphSet.getGlyph(glyphs->glyphs[i]); 1639 1648 if (g) { 1640 1649 glyphs->advances_x[i] = QFixed::fromFixed(g->linearAdvance); … … 1649 1658 } else { 1650 1659 for (int i = 0; i < glyphs->numGlyphs; i++) { 1651 Glyph *g = defaultGlyphSet.g lyph_data.value(glyphs->glyphs[i]);1660 Glyph *g = defaultGlyphSet.getGlyph(glyphs->glyphs[i]); 1652 1661 if (g) { 1653 1662 glyphs->advances_x[i] = QFixed(g->advance); … … 1678 1687 QFixed xmax = 0; 1679 1688 for (int i = 0; i < glyphs.numGlyphs; i++) { 1680 Glyph *g = defaultGlyphSet.g lyph_data.value(glyphs.glyphs[i]);1689 Glyph *g = defaultGlyphSet.getGlyph(glyphs.glyphs[i]); 1681 1690 if (!g) { 1682 1691 if (!face) … … 1720 1729 FT_Face face = 0; 1721 1730 glyph_metrics_t overall; 1722 Glyph *g = defaultGlyphSet.g lyph_data.value(glyph);1731 Glyph *g = defaultGlyphSet.getGlyph(glyph); 1723 1732 if (!g) { 1724 1733 face = lockFace(); … … 1784 1793 } 1785 1794 glyphSet = &transformedGlyphSets[0]; 1786 qDeleteAll(glyphSet->glyph_data); 1787 glyphSet->glyph_data.clear(); 1795 glyphSet->clear(); 1788 1796 glyphSet->id = allocateServerGlyphSet(); 1789 1797 glyphSet->transformationMatrix = m; … … 1793 1801 glyphSet = &defaultGlyphSet; 1794 1802 } 1795 Glyph * g = glyphSet->g lyph_data.value(glyph);1803 Glyph * g = glyphSet->getGlyph(glyph); 1796 1804 if (!g) { 1797 1805 face = lockFace(); … … 1882 1890 void QFontEngineFT::removeGlyphFromCache(glyph_t glyph) 1883 1891 { 1884 de lete defaultGlyphSet.glyph_data.take(glyph);1892 defaultGlyphSet.removeGlyphFromCache(glyph); 1885 1893 } 1886 1894 … … 1938 1946 transformationMatrix.xy = 0; 1939 1947 transformationMatrix.yx = 0; 1948 memset(fast_glyph_data, 0, sizeof(fast_glyph_data)); 1949 fast_glyph_count = 0; 1940 1950 } 1941 1951 1942 1952 QFontEngineFT::QGlyphSet::~QGlyphSet() 1943 1953 { 1954 clear(); 1955 } 1956 1957 void QFontEngineFT::QGlyphSet::clear() 1958 { 1959 if (fast_glyph_count > 0) { 1960 for (int i = 0; i < 256; ++i) { 1961 if (fast_glyph_data[i]) { 1962 delete fast_glyph_data[i]; 1963 fast_glyph_data[i] = 0; 1964 } 1965 } 1966 fast_glyph_count = 0; 1967 } 1944 1968 qDeleteAll(glyph_data); 1969 glyph_data.clear(); 1970 } 1971 1972 void QFontEngineFT::QGlyphSet::removeGlyphFromCache(int index) 1973 { 1974 if (index < 256) { 1975 if (fast_glyph_data[index]) { 1976 delete fast_glyph_data[index]; 1977 fast_glyph_data[index] = 0; 1978 if (fast_glyph_count > 0) 1979 --fast_glyph_count; 1980 } 1981 } else { 1982 delete glyph_data.take(index); 1983 } 1984 } 1985 1986 void QFontEngineFT::QGlyphSet::setGlyph(int index, Glyph *glyph) 1987 { 1988 if (index < 256) { 1989 if (!fast_glyph_data[index]) 1990 ++fast_glyph_count; 1991 fast_glyph_data[index] = glyph; 1992 } else { 1993 glyph_data.insert(index, glyph); 1994 } 1945 1995 } 1946 1996
Note:
See TracChangeset
for help on using the changeset viewer.