1 --- mozilla/gfx/src/gtk/nsFontMetricsPango.cpp.foo2 2005-06-20 13:12:24.000000000 -0400
2 +++ mozilla/gfx/src/gtk/nsFontMetricsPango.cpp 2005-06-20 10:16:59.000000000 -0400
4 #include "nsUnicharUtils.h"
5 #include "nsQuickSort.h"
7 -#include <pango/pangoxft.h>
8 #include <fontconfig/fontconfig.h>
15 + face = pango_fc_font_lock_face(fcfont);
17 + return NS_ERROR_NOT_AVAILABLE;
20 - XftFont *xftFont = pango_xft_font_get_font(PANGO_FONT(fcfont));
22 - return NS_ERROR_NOT_AVAILABLE;
24 - face = XftLockFace(xftFont);
25 os2 = (TT_OS2 *) FT_Get_Sfnt_Table(face, ft_sfnt_os2);
27 // mEmHeight (size in pixels of EM height)
29 mEmHeight = PR_MAX(1, nscoord(size * f));
32 - mMaxAscent = nscoord(xftFont->ascent * f);
33 + val = MOZ_FT_TRUNC(face->size->metrics.ascender);
34 + mMaxAscent = NSToIntRound(val * f);
37 - mMaxDescent = nscoord(xftFont->descent * f);
38 + val = -MOZ_FT_TRUNC(face->size->metrics.descender);
39 + mMaxDescent = NSToIntRound(val * f);
41 nscoord lineHeight = mMaxAscent + mMaxDescent;
44 mEmDescent = mEmHeight - mEmAscent;
47 - mMaxAdvance = nscoord(xftFont->max_advance_width * f);
48 + val = MOZ_FT_TRUNC(face->size->metrics.max_advance);
49 + mMaxAdvance = NSToIntRound(val * f);
52 PangoLayout *layout = pango_layout_new(mPangoContext);
54 mAveCharWidth = tmpWidth;
56 // mXHeight (height of an 'x' character)
57 - PRUnichar xUnichar('x');
59 - if (FcCharSetHasChar(xftFont->charset, xUnichar)) {
60 - XftTextExtents16(GDK_DISPLAY(), xftFont, &xUnichar, 1, &extents);
61 - mXHeight = extents.height;
62 + if (pango_fc_font_has_char(fcfont, 'x')) {
63 + PangoRectangle rect;
64 + PangoGlyph glyph = pango_fc_font_get_glyph (fcfont, 'x');
65 + pango_font_get_glyph_extents (PANGO_FONT (fcfont), glyph, &rect, NULL);
66 + mXHeight = NSToIntRound(rect.height * f / PANGO_SCALE);
69 // 56% of ascent, best guess for non-true type or asian fonts
70 - mXHeight = nscoord(((float)mMaxAscent) * 0.56);
71 + mXHeight = nscoord(((float)mMaxAscent) * 0.56 * f);
73 - mXHeight = nscoord(mXHeight * f);
75 // mUnderlineOffset (offset for underlines)
76 val = CONVERT_DESIGN_UNITS_TO_PIXELS(face->underline_position,
81 - -NSToIntRound(PR_MAX(1, floor(0.1 * xftFont->height + 0.5)) * f);
82 + -NSToIntRound(PR_MAX(1, floor(0.1 *
83 + MOZ_FT_TRUNC(face->size->metrics.height) + 0.5)) * f);
86 // mUnderlineSize (thickness of an underline)
91 - NSToIntRound(PR_MAX(1, floor(0.05 * xftFont->height + 0.5)) * f);
92 + NSToIntRound(PR_MAX(1,
93 + floor(0.05 * MOZ_FT_TRUNC(face->size->metrics.height) + 0.5)) * f);
99 mStrikeoutSize = mUnderlineSize;
101 - XftUnlockFace(xftFont);
102 + pango_fc_font_unlock_face(fcfont);
105 printf("%i\n", mXHeight);
109 if (!mRTLPangoContext) {
110 - mRTLPangoContext = pango_xft_get_context(GDK_DISPLAY(), 0);
111 + mRTLPangoContext = gdk_pango_context_get();
112 pango_context_set_base_dir(mRTLPangoContext, PANGO_DIRECTION_RTL);
114 gdk_pango_context_set_colormap(mRTLPangoContext, gdk_rgb_get_cmap());
115 @@ -1163,7 +1175,7 @@
116 NS_ConvertUCS2toUTF8 name(aName);
118 nsresult rv = NS_ERROR_FAILURE;
119 - PangoContext *context = pango_xft_get_context(GDK_DISPLAY(), 0);
120 + PangoContext *context = gdk_pango_context_get();
121 PangoFontFamily **familyList;
124 @@ -1262,7 +1274,7 @@
126 // Now that we have the font description set up, create the
128 - mLTRPangoContext = pango_xft_get_context(GDK_DISPLAY(), 0);
129 + mLTRPangoContext = gdk_pango_context_get();
130 mPangoContext = mLTRPangoContext;
132 // Make sure to set the base direction to LTR - if layout needs to