зеркало из https://github.com/mozilla/pjs.git
bug 362682. fix missing glyphs on linux. patch by myself and Behdad Esfahbod <mozilla@behdad.org>. r=vlad
This commit is contained in:
Родитель
0a621b7ab7
Коммит
8219812b75
|
@ -213,6 +213,7 @@ Gdiplus.h
|
|||
gdk/gdkevents.h
|
||||
gdk/gdk.h
|
||||
gdk/gdkkeysyms.h
|
||||
gdk/gdkpango.h
|
||||
gdk/gdkprivate.h
|
||||
gdk/gdkregion.h
|
||||
gdk/gdkwindow.h
|
||||
|
@ -505,6 +506,7 @@ PALM_CMN.H
|
|||
pango-engine.h
|
||||
pango-glyph.h
|
||||
pango-modules.h
|
||||
pango/pangocairo.h
|
||||
pango/pangofc-decoder.h
|
||||
pango/pangofc-font.h
|
||||
pango/pangofc-fontmap.h
|
||||
|
@ -513,6 +515,7 @@ pango/pango-fontmap.h
|
|||
pango/pango.h
|
||||
pango/pangoxft.h
|
||||
pango/pangox.h
|
||||
pango/pango-utils.h
|
||||
pango-types.h
|
||||
pascal.h
|
||||
Patches.h
|
||||
|
|
22
configure.in
22
configure.in
|
@ -116,7 +116,8 @@ PERL_VERSION=5.006
|
|||
LIBART_VERSION=2.3.4
|
||||
CAIRO_VERSION=1.4.2
|
||||
GLITZ_VERSION=0.4.0
|
||||
GTK2_VERSION=1.3.7
|
||||
PANGO_VERSION=1.10.0
|
||||
GTK2_VERSION=1.8.0
|
||||
MAKE_VERSION=3.78
|
||||
WINDRES_VERSION=2.14.90
|
||||
W32API_VERSION=3.8
|
||||
|
@ -4567,7 +4568,7 @@ fi
|
|||
if test "$COMPILE_ENVIRONMENT"; then
|
||||
if test "$MOZ_ENABLE_GTK2"
|
||||
then
|
||||
PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= 1.3.7 gdk-x11-2.0 glib-2.0 gobject-2.0)
|
||||
PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gdk-x11-2.0 glib-2.0 gobject-2.0)
|
||||
fi
|
||||
fi # COMPILE_ENVIRONMENT
|
||||
|
||||
|
@ -4806,7 +4807,7 @@ if test "$MOZ_ENABLE_XFT"
|
|||
then
|
||||
AC_DEFINE(MOZ_ENABLE_XFT)
|
||||
PKG_CHECK_MODULES(MOZ_XFT, xft)
|
||||
PKG_CHECK_MODULES(_PANGOCHK, pango >= 1.1.0)
|
||||
PKG_CHECK_MODULES(_PANGOCHK, pango >= $PANGO_VERSION)
|
||||
fi
|
||||
|
||||
AC_SUBST(MOZ_ENABLE_XFT)
|
||||
|
@ -4823,12 +4824,7 @@ MOZ_ARG_ENABLE_BOOL(pango,
|
|||
|
||||
if test "$MOZ_ENABLE_PANGO" && test -z "$MOZ_ENABLE_CAIRO_GFX"
|
||||
then
|
||||
AC_DEFINE(MOZ_ENABLE_PANGO)
|
||||
PKG_CHECK_MODULES(MOZ_PANGO, pangoxft >= 1.6.0)
|
||||
|
||||
AC_SUBST(MOZ_ENABLE_PANGO)
|
||||
AC_SUBST(MOZ_PANGO_CFLAGS)
|
||||
AC_SUBST(MOZ_PANGO_LIBS)
|
||||
AC_MSG_ERROR([Cairo gfx is required for Pango font rendering])
|
||||
fi
|
||||
|
||||
if test "$MOZ_ENABLE_GTK2" && test "$MOZ_ENABLE_CAIRO_GFX"
|
||||
|
@ -4844,13 +4840,7 @@ fi
|
|||
if test "$MOZ_ENABLE_PANGO" && test "$MOZ_ENABLE_CAIRO_GFX"
|
||||
then
|
||||
AC_DEFINE(MOZ_ENABLE_PANGO)
|
||||
dnl PKG_CHECK_MODULES(MOZ_PANGO, pango >= 1.10.0 pangocairo >= 1.10.0)
|
||||
if test "$MOZ_X11"; then
|
||||
PKG_CHECK_MODULES(MOZ_PANGO, pango >= 1.6.0 pangoft2 >= 1.6.0 pangoxft >= 1.6.0)
|
||||
else
|
||||
PKG_CHECK_MODULES(MOZ_PANGO, pango >= 1.6.0 pangoft2 >= 1.6.0)
|
||||
fi
|
||||
|
||||
PKG_CHECK_MODULES(MOZ_PANGO, pango >= $PANGO_VERSION pangocairo >= $PANGO_VERSION)
|
||||
AC_SUBST(MOZ_ENABLE_PANGO)
|
||||
AC_SUBST(MOZ_PANGO_CFLAGS)
|
||||
AC_SUBST(MOZ_PANGO_LIBS)
|
||||
|
|
|
@ -1097,7 +1097,9 @@ _render_glyph_bitmap (FT_Face face,
|
|||
* we avoid the FT_LOAD_NO_RECURSE flag.
|
||||
*/
|
||||
error = FT_Render_Glyph (glyphslot, FT_RENDER_MODE_NORMAL);
|
||||
if (error) {
|
||||
/* XXX ignoring all other errors for now. They are not fatal, typically
|
||||
* just a glyph-not-found. */
|
||||
if (error == FT_Err_Out_Of_Memory) {
|
||||
_cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
return CAIRO_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
@ -1891,8 +1893,9 @@ _cairo_ft_scaled_glyph_init (void *abstract_font,
|
|||
error = FT_Load_Glyph (scaled_font->unscaled->face,
|
||||
_cairo_scaled_glyph_index(scaled_glyph),
|
||||
load_flags);
|
||||
|
||||
if (error) {
|
||||
/* XXX ignoring all other errors for now. They are not fatal, typically
|
||||
* just a glyph-not-found. */
|
||||
if (error == FT_Err_Out_Of_Memory) {
|
||||
status = CAIRO_STATUS_NO_MEMORY;
|
||||
goto FAIL;
|
||||
}
|
||||
|
@ -2042,8 +2045,9 @@ _cairo_ft_scaled_glyph_init (void *abstract_font,
|
|||
error = FT_Load_Glyph (face,
|
||||
_cairo_scaled_glyph_index(scaled_glyph),
|
||||
load_flags | FT_LOAD_NO_BITMAP);
|
||||
|
||||
if (error) {
|
||||
/* XXX ignoring all other errors for now. They are not fatal, typically
|
||||
* just a glyph-not-found. */
|
||||
if (error == FT_Err_Out_Of_Memory) {
|
||||
_cairo_ft_unscaled_font_unlock_face (unscaled);
|
||||
_cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
return CAIRO_STATUS_NO_MEMORY;
|
||||
|
|
|
@ -44,14 +44,15 @@
|
|||
#include "gfxFont.h"
|
||||
|
||||
#include <pango/pango.h>
|
||||
#include <X11/Xft/Xft.h>
|
||||
|
||||
// Control when we use Xft directly, bypassing Pango
|
||||
// Enable this to use Xft to glyph-convert 8bit-only textruns, but use Pango
|
||||
// Control when we bypass Pango
|
||||
// Enable this to use FreeType to glyph-convert 8bit-only textruns, but use Pango
|
||||
// to shape any textruns with non-8bit characters
|
||||
#define ENABLE_XFT_FAST_PATH_8BIT
|
||||
// Enable this to use Xft to glyph-convert all textruns
|
||||
// #define ENABLE_XFT_FAST_PATH_ALWAYS
|
||||
// XXX
|
||||
#define ENABLE_FAST_PATH_8BIT
|
||||
// Enable this to bypass Pango shaping for all textruns. Don't expect
|
||||
// anything other than simple Latin work though!
|
||||
//#define ENABLE_FAST_PATH_ALWAYS
|
||||
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsClassHashtable.h"
|
||||
|
@ -70,17 +71,15 @@ public:
|
|||
|
||||
virtual const gfxFont::Metrics& GetMetrics();
|
||||
|
||||
PangoFontDescription *GetPangoFontDescription() { RealizeFont(); return mPangoFontDesc; }
|
||||
PangoContext *GetPangoContext() { RealizeFont(); return mPangoCtx; }
|
||||
PangoFontDescription *GetPangoFontDescription() { if (!mPangoFontDesc) RealizeFont(); return mPangoFontDesc; }
|
||||
PangoContext *GetPangoContext() { if (!mPangoFontDesc) RealizeFont(); return mPangoCtx; }
|
||||
|
||||
void GetMozLang(nsACString &aMozLang);
|
||||
void GetActualFontFamily(nsACString &aFamily);
|
||||
|
||||
XftFont *GetXftFont () { RealizeXftFont (); return mXftFont; }
|
||||
PangoFont *GetPangoFont() { RealizePangoFont(); return mPangoFont; }
|
||||
gfxFloat GetAdjustedSize() { RealizeFont(); return mAdjustedSize; }
|
||||
PangoFont *GetPangoFont() { if (!mPangoFont) RealizePangoFont(); return mPangoFont; }
|
||||
gfxFloat GetAdjustedSize() { if (!mPangoFontDesc) RealizeFont(); return mAdjustedSize; }
|
||||
|
||||
PRBool HasGlyph(const PRUint32 aChar);
|
||||
PRUint32 GetGlyph(const PRUint32 aChar);
|
||||
|
||||
virtual nsString GetUniqueName();
|
||||
|
@ -95,9 +94,7 @@ protected:
|
|||
PangoFontDescription *mPangoFontDesc;
|
||||
PangoContext *mPangoCtx;
|
||||
|
||||
XftFont *mXftFont;
|
||||
PangoFont *mPangoFont;
|
||||
PangoFont *mGlyphTestingFont;
|
||||
cairo_scaled_font_t *mCairoFont;
|
||||
|
||||
PRBool mHasMetrics;
|
||||
|
@ -106,7 +103,6 @@ protected:
|
|||
gfxFloat mAdjustedSize;
|
||||
|
||||
void RealizeFont(PRBool force = PR_FALSE);
|
||||
void RealizeXftFont(PRBool force = PR_FALSE);
|
||||
void RealizePangoFont(PRBool aForce = PR_FALSE);
|
||||
void GetCharSize(const char aChar, gfxSize& aInkSize, gfxSize& aLogSize,
|
||||
PRUint32 *aGlyphID = nsnull);
|
||||
|
@ -124,7 +120,7 @@ public:
|
|||
|
||||
virtual gfxFontGroup *Copy(const gfxFontStyle *aStyle);
|
||||
|
||||
// Create and initialize a textrun using Pango (or Xft)
|
||||
// Create and initialize a textrun using Pango
|
||||
virtual gfxTextRun *MakeTextRun(const PRUnichar *aString, PRUint32 aLength,
|
||||
const Parameters *aParams, PRUint32 aFlags);
|
||||
virtual gfxTextRun *MakeTextRun(const PRUint8 *aString, PRUint32 aLength,
|
||||
|
@ -146,8 +142,8 @@ protected:
|
|||
* but stored in UTF16 format)
|
||||
*/
|
||||
void InitTextRun(gfxTextRun *aTextRun, const gchar *aUTF8Text,
|
||||
PRUint32 aUTF8Length, PRUint32 aUTF8HeaderLength,
|
||||
PRBool aTake8BitPath);
|
||||
PRUint32 aUTF8Length, PRBool aTake8BitPath);
|
||||
|
||||
// Returns NS_ERROR_FAILURE if there's a missing glyph
|
||||
nsresult SetGlyphs(gfxTextRun *aTextRun, gfxPangoFont *aFont,
|
||||
const gchar *aUTF8, PRUint32 aUTF8Length,
|
||||
|
@ -158,11 +154,11 @@ protected:
|
|||
const gchar *aUTF8, PRUint32 aUTF8Length,
|
||||
PRUint32 *aUTF16Offset);
|
||||
void CreateGlyphRunsItemizing(gfxTextRun *aTextRun,
|
||||
const gchar *aUTF8, PRUint32 aUTF8Length,
|
||||
PRUint32 aUTF8HeaderLength);
|
||||
#if defined(ENABLE_XFT_FAST_PATH_8BIT) || defined(ENABLE_XFT_FAST_PATH_ALWAYS)
|
||||
void CreateGlyphRunsXft(gfxTextRun *aTextRun,
|
||||
const gchar *aUTF8, PRUint32 aUTF8Length);
|
||||
const gchar *aUTF8, PRUint32 aUTF8Length);
|
||||
#if defined(ENABLE_FAST_PATH_8BIT) || defined(ENABLE_FAST_PATH_ALWAYS)
|
||||
PRBool CanTakeFastPath(PRUint32 aFlags);
|
||||
void CreateGlyphRunsFast(gfxTextRun *aTextRun,
|
||||
const gchar *aUTF8, PRUint32 aUTF8Length);
|
||||
#endif
|
||||
|
||||
static PRBool FontCallback (const nsAString& fontName,
|
||||
|
@ -212,30 +208,4 @@ private:
|
|||
nsClassHashtable<nsUint32HashKey, gfxPangoFontWrapper> mPangoFonts;
|
||||
};
|
||||
|
||||
// XXX we should remove this class, because this class is used only in |HasGlyph| of gfxPangoFont.
|
||||
// But it can use fontconfig directly after bug 366664.
|
||||
class gfxPangoFontNameMap
|
||||
{
|
||||
public:
|
||||
gfxPangoFontNameMap();
|
||||
~gfxPangoFontNameMap();
|
||||
|
||||
static gfxPangoFontNameMap* GetPangoFontNameMap() {
|
||||
if (!sPangoFontNameMap)
|
||||
sPangoFontNameMap = new gfxPangoFontNameMap();
|
||||
return sPangoFontNameMap;
|
||||
}
|
||||
static void Shutdown() {
|
||||
if (sPangoFontNameMap)
|
||||
delete sPangoFontNameMap;
|
||||
sPangoFontNameMap = nsnull;
|
||||
}
|
||||
|
||||
void Put(const nsACString &aName, PangoFont *aPangoFont);
|
||||
PangoFont* Get(const nsACString &aName);
|
||||
|
||||
private:
|
||||
static gfxPangoFontNameMap *sPangoFontNameMap;
|
||||
nsClassHashtable<nsCStringHashKey, gfxPangoFontWrapper> mPangoFonts;
|
||||
};
|
||||
#endif /* GFX_PANGOFONTS_H */
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
if (sDPI == -1) {
|
||||
InitDPI();
|
||||
}
|
||||
NS_ASSERTION(sDPI != 0, "Something is wrong");
|
||||
NS_ASSERTION(sDPI > 0, "Something is wrong");
|
||||
return sDPI;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "cairo-xlib.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#if HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#elif HAVE_INTTYPES_H
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -60,12 +60,6 @@
|
|||
|
||||
#include <fontconfig/fontconfig.h>
|
||||
|
||||
#ifndef THEBES_USE_PANGO_CAIRO
|
||||
#include <pango/pangoxft.h>
|
||||
#endif // THEBES_USE_PANGO_CAIRO
|
||||
|
||||
#include <pango/pango-font.h>
|
||||
|
||||
#include "nsMathUtils.h"
|
||||
|
||||
#include "lcms.h"
|
||||
|
@ -89,6 +83,8 @@ gfxPlatformGtk::gfxPlatformGtk()
|
|||
#endif
|
||||
if (!sFontconfigUtils)
|
||||
sFontconfigUtils = gfxFontconfigUtils::GetFontconfigUtils();
|
||||
|
||||
InitDPI();
|
||||
}
|
||||
|
||||
gfxPlatformGtk::~gfxPlatformGtk()
|
||||
|
@ -98,10 +94,6 @@ gfxPlatformGtk::~gfxPlatformGtk()
|
|||
|
||||
gfxPangoFont::Shutdown();
|
||||
|
||||
#ifndef THEBES_USE_PANGO_CAIRO
|
||||
pango_xft_shutdown_display(GDK_DISPLAY(), 0);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// It would be nice to do this (although it might need to be after
|
||||
// the cairo shutdown that happens in ~gfxPlatform). It even looks
|
||||
|
@ -278,93 +270,17 @@ gfxPlatformGtk::CreateFontGroup(const nsAString &aFamilies,
|
|||
return new gfxPangoFontGroup(aFamilies, aStyle);
|
||||
}
|
||||
|
||||
static PRInt32
|
||||
GetXftDPI()
|
||||
{
|
||||
char *val = XGetDefault(GDK_DISPLAY(), "Xft", "dpi");
|
||||
if (val) {
|
||||
char *e;
|
||||
double d = strtod(val, &e);
|
||||
|
||||
if (e != val)
|
||||
return NS_lround(d);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static PRInt32
|
||||
GetDPIFromPangoFont()
|
||||
{
|
||||
#ifndef THEBES_USE_PANGO_CAIRO
|
||||
PangoContext* ctx = pango_xft_get_context(GDK_DISPLAY(), 0);
|
||||
gdk_pango_context_set_colormap(ctx, gdk_rgb_get_cmap());
|
||||
#else
|
||||
PangoContext* ctx =
|
||||
pango_cairo_font_map_create_context(
|
||||
PANGO_CAIRO_FONT_MAP(pango_cairo_font_map_get_default()));
|
||||
#endif
|
||||
|
||||
if (!ctx) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
double dblDPI = 0.0f;
|
||||
GList *items = nsnull;
|
||||
PangoItem *item = nsnull;
|
||||
PangoFcFont *fcfont = nsnull;
|
||||
|
||||
PangoAttrList *al = pango_attr_list_new();
|
||||
|
||||
if (!al) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Just using the string "a" because we need _some_ text.
|
||||
items = pango_itemize(ctx, "a", 0, 1, al, NULL);
|
||||
|
||||
if (!items) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
item = (PangoItem*)items->data;
|
||||
|
||||
if (!item) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
fcfont = PANGO_FC_FONT(item->analysis.font);
|
||||
|
||||
if (!fcfont) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
FcPatternGetDouble(fcfont->font_pattern, FC_DPI, 0, &dblDPI);
|
||||
|
||||
cleanup:
|
||||
if (al)
|
||||
pango_attr_list_unref(al);
|
||||
if (item)
|
||||
pango_item_free(item);
|
||||
if (items)
|
||||
g_list_free(items);
|
||||
if (ctx)
|
||||
g_object_unref(ctx);
|
||||
|
||||
return NS_lround(dblDPI);
|
||||
}
|
||||
|
||||
/* static */
|
||||
void
|
||||
gfxPlatformGtk::InitDPI()
|
||||
{
|
||||
sDPI = GetXftDPI();
|
||||
PangoContext *context = gdk_pango_context_get ();
|
||||
sDPI = pango_cairo_context_get_resolution (context);
|
||||
g_object_unref (context);
|
||||
|
||||
if (sDPI <= 0) {
|
||||
sDPI = GetDPIFromPangoFont();
|
||||
if (sDPI <= 0) {
|
||||
// Fall back to something sane
|
||||
sDPI = 96;
|
||||
}
|
||||
// Fall back to something sane
|
||||
sDPI = 96;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче