56 |
56 |
57 #include "qfontengine_ft_p.h" |
57 #include "qfontengine_ft_p.h" |
58 #include <ft2build.h> |
58 #include <ft2build.h> |
59 #include FT_FREETYPE_H |
59 #include FT_FREETYPE_H |
60 #include FT_OUTLINE_H |
60 #include FT_OUTLINE_H |
|
61 #include FT_SYNTHESIS_H |
61 #include FT_TRUETYPE_TABLES_H |
62 #include FT_TRUETYPE_TABLES_H |
62 #include FT_TYPE1_TABLES_H |
63 #include FT_TYPE1_TABLES_H |
63 #include FT_GLYPH_H |
64 #include FT_GLYPH_H |
64 |
65 |
65 #if defined(FT_LCD_FILTER_H) |
66 #if defined(FT_LCD_FILTER_H) |
677 lbearing = rbearing = SHRT_MIN; |
679 lbearing = rbearing = SHRT_MIN; |
678 freetype->computeSize(fontDef, &xsize, &ysize, &defaultGlyphSet.outline_drawing); |
680 freetype->computeSize(fontDef, &xsize, &ysize, &defaultGlyphSet.outline_drawing); |
679 |
681 |
680 FT_Face face = lockFace(); |
682 FT_Face face = lockFace(); |
681 |
683 |
682 //underline metrics |
|
683 if (FT_IS_SCALABLE(face)) { |
684 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 bool fake_oblique = (fontDef.style != QFont::StyleNormal) && !(face->style_flags & FT_STYLE_FLAG_ITALIC); |
685 bool fake_oblique = (fontDef.style != QFont::StyleNormal) && !(face->style_flags & FT_STYLE_FLAG_ITALIC); |
687 if (fake_oblique) |
686 if (fake_oblique) |
688 matrix.xy = 0x10000*3/10; |
687 matrix.xy = 0x10000*3/10; |
689 FT_Set_Transform(face, &matrix, 0); |
688 FT_Set_Transform(face, &matrix, 0); |
690 freetype->matrix = matrix; |
689 freetype->matrix = matrix; |
691 if (fake_oblique) |
690 if (fake_oblique) |
692 transform = true; |
691 transform = true; |
|
692 // fake bold |
|
693 if ((fontDef.weight == QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD) && !FT_IS_FIXED_WIDTH(face)) |
|
694 embolden = true; |
|
695 // underline metrics |
|
696 line_thickness = QFixed::fromFixed(FT_MulFix(face->underline_thickness, face->size->metrics.y_scale)); |
|
697 underline_position = QFixed::fromFixed(-FT_MulFix(face->underline_position, face->size->metrics.y_scale)); |
693 } else { |
698 } else { |
694 // copied from QFontEngineQPF |
699 // copied from QFontEngineQPF |
695 // ad hoc algorithm |
700 // ad hoc algorithm |
696 int score = fontDef.weight * fontDef.pixelSize; |
701 int score = fontDef.weight * fontDef.pixelSize; |
697 line_thickness = score / 700; |
702 line_thickness = score / 700; |
787 g->uploadedToServer = false; |
792 g->uploadedToServer = false; |
788 g->data = 0; |
793 g->data = 0; |
789 } |
794 } |
790 |
795 |
791 FT_GlyphSlot slot = face->glyph; |
796 FT_GlyphSlot slot = face->glyph; |
|
797 if (embolden) FT_GlyphSlot_Embolden(slot); |
792 int left = slot->metrics.horiBearingX; |
798 int left = slot->metrics.horiBearingX; |
793 int right = slot->metrics.horiBearingX + slot->metrics.width; |
799 int right = slot->metrics.horiBearingX + slot->metrics.width; |
794 int top = slot->metrics.horiBearingY; |
800 int top = slot->metrics.horiBearingY; |
795 int bottom = slot->metrics.horiBearingY - slot->metrics.height; |
801 int bottom = slot->metrics.horiBearingY - slot->metrics.height; |
796 if(transform && slot->format != FT_GLYPH_FORMAT_BITMAP) { // freetype doesn't apply the transformation on the metrics |
802 if(transform && slot->format != FT_GLYPH_FORMAT_BITMAP) { // freetype doesn't apply the transformation on the metrics |
1207 int QFontEngineFT::synthesized() const |
1214 int QFontEngineFT::synthesized() const |
1208 { |
1215 { |
1209 int s = 0; |
1216 int s = 0; |
1210 if ((fontDef.style != QFont::StyleNormal) && !(freetype->face->style_flags & FT_STYLE_FLAG_ITALIC)) |
1217 if ((fontDef.style != QFont::StyleNormal) && !(freetype->face->style_flags & FT_STYLE_FLAG_ITALIC)) |
1211 s = SynthesizedItalic; |
1218 s = SynthesizedItalic; |
|
1219 if ((fontDef.weight == QFont::Bold) && !(freetype->face->style_flags & FT_STYLE_FLAG_BOLD)) |
|
1220 s |= SynthesizedBold; |
1212 if (fontDef.stretch != 100 && FT_IS_SCALABLE(freetype->face)) |
1221 if (fontDef.stretch != 100 && FT_IS_SCALABLE(freetype->face)) |
1213 s |= SynthesizedStretch; |
1222 s |= SynthesizedStretch; |
1214 return s; |
1223 return s; |
1215 } |
1224 } |
1216 |
1225 |