thunderbird/firefox-1.0-pango-cairo.patch
Kristian Høgsberg f3381bf1af - Update firefox-1.0-pango-cairo.patch to also fix xft usage in
mozilla/gfx/src/gtk/mozilla-decoder.cpp
2005-08-19 03:10:55 +00:00

153 lines
5.1 KiB
Diff

--- mozilla/gfx/src/gtk/nsFontMetricsPango.cpp.foo2 2005-06-20 13:12:24.000000000 -0400
+++ mozilla/gfx/src/gtk/nsFontMetricsPango.cpp 2005-06-20 10:16:59.000000000 -0400
@@ -53,7 +53,6 @@
#include "nsUnicharUtils.h"
#include "nsQuickSort.h"
-#include <pango/pangoxft.h>
#include <fontconfig/fontconfig.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
@@ -301,12 +300,11 @@
// Get our font face
FT_Face face;
+ face = pango_fc_font_lock_face(fcfont);
+ if (!face)
+ return NS_ERROR_NOT_AVAILABLE;
+
TT_OS2 *os2;
- XftFont *xftFont = pango_xft_font_get_font(PANGO_FONT(fcfont));
- if (!xftFont)
- return NS_ERROR_NOT_AVAILABLE;
-
- face = XftLockFace(xftFont);
os2 = (TT_OS2 *) FT_Get_Sfnt_Table(face, ft_sfnt_os2);
// mEmHeight (size in pixels of EM height)
@@ -318,10 +316,12 @@
mEmHeight = PR_MAX(1, nscoord(size * f));
// mMaxAscent
- mMaxAscent = nscoord(xftFont->ascent * f);
+ val = MOZ_FT_TRUNC(face->size->metrics.ascender);
+ mMaxAscent = NSToIntRound(val * f);
// mMaxDescent
- mMaxDescent = nscoord(xftFont->descent * f);
+ val = -MOZ_FT_TRUNC(face->size->metrics.descender);
+ mMaxDescent = NSToIntRound(val * f);
nscoord lineHeight = mMaxAscent + mMaxDescent;
@@ -341,7 +341,8 @@
mEmDescent = mEmHeight - mEmAscent;
// mMaxAdvance
- mMaxAdvance = nscoord(xftFont->max_advance_width * f);
+ val = MOZ_FT_TRUNC(face->size->metrics.max_advance);
+ mMaxAdvance = NSToIntRound(val * f);
// mPangoSpaceWidth
PangoLayout *layout = pango_layout_new(mPangoContext);
@@ -364,17 +365,16 @@
mAveCharWidth = tmpWidth;
// mXHeight (height of an 'x' character)
- PRUnichar xUnichar('x');
- XGlyphInfo extents;
- if (FcCharSetHasChar(xftFont->charset, xUnichar)) {
- XftTextExtents16(GDK_DISPLAY(), xftFont, &xUnichar, 1, &extents);
- mXHeight = extents.height;
+ if (pango_fc_font_has_char(fcfont, 'x')) {
+ PangoRectangle rect;
+ PangoGlyph glyph = pango_fc_font_get_glyph (fcfont, 'x');
+ pango_font_get_glyph_extents (PANGO_FONT (fcfont), glyph, &rect, NULL);
+ mXHeight = NSToIntRound(rect.height * f / PANGO_SCALE);
}
else {
// 56% of ascent, best guess for non-true type or asian fonts
- mXHeight = nscoord(((float)mMaxAscent) * 0.56);
+ mXHeight = nscoord(((float)mMaxAscent) * 0.56 * f);
}
- mXHeight = nscoord(mXHeight * f);
// mUnderlineOffset (offset for underlines)
val = CONVERT_DESIGN_UNITS_TO_PIXELS(face->underline_position,
@@ -384,7 +394,8 @@
}
else {
mUnderlineOffset =
- -NSToIntRound(PR_MAX(1, floor(0.1 * xftFont->height + 0.5)) * f);
+ -NSToIntRound(PR_MAX(1, floor(0.1 *
+ MOZ_FT_TRUNC(face->size->metrics.height) + 0.5)) * f);
}
// mUnderlineSize (thickness of an underline)
@@ -395,7 +406,8 @@
}
else {
mUnderlineSize =
- NSToIntRound(PR_MAX(1, floor(0.05 * xftFont->height + 0.5)) * f);
+ NSToIntRound(PR_MAX(1,
+ floor(0.05 * MOZ_FT_TRUNC(face->size->metrics.height) + 0.5)) * f);
}
// mSuperscriptOffset
@@ -426,7 +438,7 @@
// mStrikeoutSize
mStrikeoutSize = mUnderlineSize;
- XftUnlockFace(xftFont);
+ pango_fc_font_unlock_face(fcfont);
/*
printf("%i\n", mXHeight);
@@ -893,7 +905,7 @@
{
if (aIsRTL) {
if (!mRTLPangoContext) {
- mRTLPangoContext = pango_xft_get_context(GDK_DISPLAY(), 0);
+ mRTLPangoContext = gdk_pango_context_get();
pango_context_set_base_dir(mRTLPangoContext, PANGO_DIRECTION_RTL);
gdk_pango_context_set_colormap(mRTLPangoContext, gdk_rgb_get_cmap());
@@ -1163,7 +1175,7 @@
NS_ConvertUCS2toUTF8 name(aName);
nsresult rv = NS_ERROR_FAILURE;
- PangoContext *context = pango_xft_get_context(GDK_DISPLAY(), 0);
+ PangoContext *context = gdk_pango_context_get();
PangoFontFamily **familyList;
int n;
@@ -1262,7 +1274,7 @@
// Now that we have the font description set up, create the
// context.
- mLTRPangoContext = pango_xft_get_context(GDK_DISPLAY(), 0);
+ mLTRPangoContext = gdk_pango_context_get();
mPangoContext = mLTRPangoContext;
// Make sure to set the base direction to LTR - if layout needs to
--- mozilla/gfx/src/gtk/mozilla-decoder.cpp.noxft 2005-08-18 22:41:26.000000000 -0400
+++ mozilla/gfx/src/gtk/mozilla-decoder.cpp 2005-08-18 22:38:01.000000000 -0400
@@ -40,7 +40,7 @@
#define PANGO_ENABLE_ENGINE
#include "mozilla-decoder.h"
-#include <pango/pangoxft.h>
+#include <pango/pangocairo.h>
#include <pango/pangofc-fontmap.h>
#include <pango/pangofc-font.h>
#include <gdk/gdkx.h>
@@ -208,7 +208,7 @@
}
}
- pango_fc_font_map_add_decoder_find_func(PANGO_FC_FONT_MAP(pango_xft_get_font_map(GDK_DISPLAY(),gdk_x11_get_default_screen())),
+ pango_fc_font_map_add_decoder_find_func(PANGO_FC_FONT_MAP(pango_cairo_font_map_get_default()),
mozilla_find_decoder,
NULL,
NULL);