View | Details | Raw Unified | Return to bug 6151
Collapse All | Expand All

(-)configure.in (+4 lines)
Lines 3419-3432 dnl ==================================== Link Here
3419
dnl = Xft
3419
dnl = Xft
3420
dnl ========================================================
3420
dnl ========================================================
3421
MOZ_ARG_ENABLE_BOOL(xft,
3421
MOZ_ARG_ENABLE_BOOL(xft,
3422
[  --enable-xft            Enable Xft support ],
3422
[  --enable-xft            Enable Xft support ],
3423
    MOZ_ENABLE_XFT=1,
3423
    MOZ_ENABLE_XFT=1,
3424
    MOZ_ENABLE_XFT= )
3424
    MOZ_ENABLE_XFT= )
3425
3425
3426
if test "$MOZ_ENABLE_XFT" && test "$MOZ_ENABLE_FREETYPE2"; then
3427
    AC_MSG_ERROR([Cannot enable XFT and FREETYPE2 at the same time.])
3428
fi
3429
3426
if test "$MOZ_ENABLE_XFT"
3430
if test "$MOZ_ENABLE_XFT"
3427
then
3431
then
3428
    AC_DEFINE(MOZ_ENABLE_XFT)
3432
    AC_DEFINE(MOZ_ENABLE_XFT)
3429
    PKG_CHECK_MODULES(MOZ_XFT, xft)
3433
    PKG_CHECK_MODULES(MOZ_XFT, xft)
3430
    if test "$MOZ_ENABLE_GTK2"; then
3434
    if test "$MOZ_ENABLE_GTK2"; then
3431
        PKG_CHECK_MODULES(_PANGOCHK, pango >= 1.1.0)
3435
        PKG_CHECK_MODULES(_PANGOCHK, pango >= 1.1.0)
3432
    fi
3436
    fi
(-)gfx/idl/Makefile.in (-2 / +7 lines)
Lines 35-56 XPIDLSRCS = \ Link Here
35
		nsIFontList.idl \
35
		nsIFontList.idl \
36
		nsIScriptableRegion.idl \
36
		nsIScriptableRegion.idl \
37
		nsIScreen.idl \
37
		nsIScreen.idl \
38
		nsIScreenManager.idl \
38
		nsIScreenManager.idl \
39
		nsIPrintOptions.idl \
39
		nsIPrintOptions.idl \
40
		nsIPrintSettings.idl \
40
		nsIPrintSettings.idl \
41
		nsIPrintSettingsService.idl \
41
		nsIPrintSettingsService.idl \
42
		nsIFontCatalogService.idl \
43
		nsIFreeType2.idl \
44
		nsIPrintSession.idl \
42
		nsIPrintSession.idl \
45
		gfxIFormats.idl \
43
		gfxIFormats.idl \
46
		gfxIImageFrame.idl \
44
		gfxIImageFrame.idl \
47
		gfxtypes.idl \
45
		gfxtypes.idl \
48
		$(NULL)
46
		$(NULL)
49
47
48
ifdef MOZ_ENABLE_FREETYPE2
49
XPIDLSRCS	+= \
50
		nsIFontCatalogService.idl \
51
		nsIFreeType2.idl \
52
		$(NULL)
53
endif
54
50
ifneq (,$(filter mac cocoa,$(MOZ_GFX_TOOLKIT)))
55
ifneq (,$(filter mac cocoa,$(MOZ_GFX_TOOLKIT)))
51
XPIDLSRCS += nsIPrintSettingsX.idl \
56
XPIDLSRCS += nsIPrintSettingsX.idl \
52
		nsIPrintSessionX.idl \
57
		nsIPrintSessionX.idl \
53
		$(NULL)
58
		$(NULL)
54
endif
59
endif
55
60
56
ifeq ($(MOZ_GFX_TOOLKIT),windows)
61
ifeq ($(MOZ_GFX_TOOLKIT),windows)
(-)gfx/src/gtk/Makefile.in (-4 / +9 lines)
Lines 62-82 endif Link Here
62
NATIVE_THEME_SUPPORT = 1
62
NATIVE_THEME_SUPPORT = 1
63
63
64
CSRCS		= nsPrintdGTK.c
64
CSRCS		= nsPrintdGTK.c
65
65
66
# Code shared between GTK+, Xlib and Xprint gfx modules
66
# Code shared between GTK+, Xlib and Xprint gfx modules
67
X11SHARED_LCPPSRCS = \
67
X11SHARED_LCPPSRCS = \
68
		nsAntiAliasedGlyph.cpp \
68
		nsAntiAliasedGlyph.cpp \
69
		nsFontFreeType.cpp \
70
		nsFT2FontNode.cpp \
71
		nsFT2FontCatalog.cpp \
72
		nsX11AlphaBlend.cpp \
69
		nsX11AlphaBlend.cpp \
73
		nsXFontAAScaledBitmap.cpp \
70
		nsXFontAAScaledBitmap.cpp \
74
		nsXFontNormal.cpp \
71
		nsXFontNormal.cpp \
75
		$(NULL)
72
		$(NULL)
73
74
ifdef MOZ_ENABLE_FREETYPE2
75
X11SHARED_LCPPSRCS += \
76
		nsFontFreeType.cpp \
77
		nsFT2FontNode.cpp \
78
		nsFT2FontCatalog.cpp \
79
		$(NULL)
80
endif
76
                
81
                
77
CPPSRCS		= \
82
CPPSRCS		= \
78
		nsDeviceContextGTK.cpp \
83
		nsDeviceContextGTK.cpp \
79
		nsDeviceContextSpecFactoryG.cpp \
84
		nsDeviceContextSpecFactoryG.cpp \
80
		nsDeviceContextSpecG.cpp \
85
		nsDeviceContextSpecG.cpp \
81
		nsDrawingSurfaceGTK.cpp \
86
		nsDrawingSurfaceGTK.cpp \
82
		nsGfxFactoryGTK.cpp \
87
		nsGfxFactoryGTK.cpp \
Lines 204-224 EXTRA_DSO_LDOPTS += \ Link Here
204
endif
209
endif
205
210
206
LOCAL_INCLUDES	= \
211
LOCAL_INCLUDES	= \
207
		-I../.. \
212
		-I../.. \
208
		-I$(srcdir)/. \
213
		-I$(srcdir)/. \
209
		-I$(srcdir)/.. \
214
		-I$(srcdir)/.. \
210
		-I$(srcdir)/../shared \
215
		-I$(srcdir)/../shared \
211
		-I$(srcdir)/../freetype \
212
		-I$(srcdir)/../x11shared \
216
		-I$(srcdir)/../x11shared \
213
		$(MOZ_XFT_CFLAGS) \
217
		$(MOZ_XFT_CFLAGS) \
214
		$(NULL)
218
		$(NULL)
215
219
216
ifdef MOZ_ENABLE_FREETYPE2
220
ifdef MOZ_ENABLE_FREETYPE2
217
INCLUDES        += $(FT2_CFLAGS)
221
INCLUDES        += $(FT2_CFLAGS)
222
LOCAL_INCLUDES        += -I$(srcdir)/../freetype
218
endif
223
endif
219
224
220
ifdef MOZ_ENABLE_XPRINT
225
ifdef MOZ_ENABLE_XPRINT
221
export:: $(addprefix $(srcdir)/../xprint/,$(XPU_LCSRCS)) $(addprefix $(srcdir)/../x11shared/,$(X11SHARED_LCPPSRCS))
226
export:: $(addprefix $(srcdir)/../xprint/,$(XPU_LCSRCS)) $(addprefix $(srcdir)/../x11shared/,$(X11SHARED_LCPPSRCS))
222
	$(INSTALL) $^ .
227
	$(INSTALL) $^ .
223
else
228
else
224
export:: $(addprefix $(srcdir)/../x11shared/,$(X11SHARED_LCPPSRCS))
229
export:: $(addprefix $(srcdir)/../x11shared/,$(X11SHARED_LCPPSRCS))
(-)gfx/src/gtk/nsFontMetricsGTK.cpp (-3 / +176 lines)
Lines 58-73 Link Here
58
#include "nsPrintfCString.h"
58
#include "nsPrintfCString.h"
59
#include "nspr.h"
59
#include "nspr.h"
60
#include "nsHashtable.h"
60
#include "nsHashtable.h"
61
#include "nsReadableUtils.h"
61
#include "nsReadableUtils.h"
62
#include "nsAString.h"
62
#include "nsAString.h"
63
#include "nsXPIDLString.h"
63
#include "nsXPIDLString.h"
64
#include "nsFontDebug.h"
64
#include "nsFontDebug.h"
65
#ifdef MOZ_ENABLE_FREETYPE2
65
#include "nsFT2FontNode.h"
66
#include "nsFT2FontNode.h"
66
#include "nsFontFreeType.h"
67
#include "nsFontFreeType.h"
68
#endif
67
#include "nsXFontNormal.h"
69
#include "nsXFontNormal.h"
68
#include "nsX11AlphaBlend.h"
70
#include "nsX11AlphaBlend.h"
69
#include "nsXFontAAScaledBitmap.h"
71
#include "nsXFontAAScaledBitmap.h"
70
#include "nsUnicharUtils.h"
72
#include "nsUnicharUtils.h"
71
#ifdef ENABLE_X_FONT_BANNING
73
#ifdef ENABLE_X_FONT_BANNING
72
#include <regex.h>
74
#include <regex.h>
73
#endif /* ENABLE_X_FONT_BANNING */
75
#endif /* ENABLE_X_FONT_BANNING */
Lines 98-125 static PRLogModuleInfo * FontMetricsGTKL Link Here
98
// this factor larger than the height of the display, it's clamped to
100
// this factor larger than the height of the display, it's clamped to
99
// that value instead of the requested size.
101
// that value instead of the requested size.
100
#define FONT_MAX_FONT_SCALE 2
102
#define FONT_MAX_FONT_SCALE 2
101
103
102
#undef NOISY_FONTS
104
#undef NOISY_FONTS
103
#undef REALLY_NOISY_FONTS
105
#undef REALLY_NOISY_FONTS
104
106
107
#ifndef MOZ_ENABLE_FREETYPE2
108
static PRUint32 gFontDebug = 0 | NS_FONT_DEBUG_FONT_SCAN;
109
#endif
110
105
struct nsFontCharSetMap;
111
struct nsFontCharSetMap;
106
struct nsFontFamilyName;
112
struct nsFontFamilyName;
107
struct nsFontPropertyName;
113
struct nsFontPropertyName;
108
struct nsFontStyle;
114
struct nsFontStyle;
109
struct nsFontWeight;
115
struct nsFontWeight;
110
struct nsFontLangGroup;
116
struct nsFontLangGroup;
111
117
112
struct nsFontCharSetInfo
118
struct nsFontCharSetInfo
113
{
119
{
114
  const char*            mCharSet;
120
  const char*            mCharSet;
115
  nsFontCharSetConverter Convert;
121
  nsFontCharSetConverter Convert;
116
  PRUint8                mSpecialUnderline;
122
  PRUint8                mSpecialUnderline;
123
#ifdef MOZ_ENABLE_FREETYPE2
117
  PRInt32                mCodeRange1Bits;
124
  PRInt32                mCodeRange1Bits;
118
  PRInt32                mCodeRange2Bits;
125
  PRInt32                mCodeRange2Bits;
126
#endif
119
  PRUint16*              mCCMap;
127
  PRUint16*              mCCMap;
120
  nsIUnicodeEncoder*     mConverter;
128
  nsIUnicodeEncoder*     mConverter;
121
  nsIAtom*               mLangGroup;
129
  nsIAtom*               mLangGroup;
122
  PRBool                 mInitedSizeInfo;
130
  PRBool                 mInitedSizeInfo;
123
  PRInt32                mOutlineScaleMin;
131
  PRInt32                mOutlineScaleMin;
124
  PRInt32                mAABitmapScaleMin;
132
  PRInt32                mAABitmapScaleMin;
125
  double                 mAABitmapOversize;
133
  double                 mAABitmapOversize;
Lines 216-229 static gint DoubleByteConvert(nsFontChar Link Here
216
  const PRUnichar* aSrcBuf, PRInt32 aSrcLen, char* aDestBuf, PRInt32 aDestLen);
224
  const PRUnichar* aSrcBuf, PRInt32 aSrcLen, char* aDestBuf, PRInt32 aDestLen);
217
static gint ISO10646Convert(nsFontCharSetInfo* aSelf, XFontStruct* aFont,
225
static gint ISO10646Convert(nsFontCharSetInfo* aSelf, XFontStruct* aFont,
218
  const PRUnichar* aSrcBuf, PRInt32 aSrcLen, char* aDestBuf, PRInt32 aDestLen);
226
  const PRUnichar* aSrcBuf, PRInt32 aSrcLen, char* aDestBuf, PRInt32 aDestLen);
219
227
220
static nsFontCharSetInfo Unknown = { nsnull };
228
static nsFontCharSetInfo Unknown = { nsnull };
221
static nsFontCharSetInfo Special = { nsnull };
229
static nsFontCharSetInfo Special = { nsnull };
222
230
231
#ifdef MOZ_ENABLE_FREETYPE2
223
static nsFontCharSetInfo USASCII =
232
static nsFontCharSetInfo USASCII =
224
  { "us-ascii", SingleByteConvert, 0,
233
  { "us-ascii", SingleByteConvert, 0,
225
    TT_OS2_CPR1_LATIN1 | TT_OS2_CPR1_MAC_ROMAN,
234
    TT_OS2_CPR1_LATIN1 | TT_OS2_CPR1_MAC_ROMAN,
226
    TT_OS2_CPR2_CA_FRENCH |  TT_OS2_CPR2_PORTUGESE
235
    TT_OS2_CPR2_CA_FRENCH |  TT_OS2_CPR2_PORTUGESE
227
    | TT_OS2_CPR2_WE_LATIN1 |  TT_OS2_CPR2_US };
236
    | TT_OS2_CPR2_WE_LATIN1 |  TT_OS2_CPR2_US };
228
static nsFontCharSetInfo ISO88591 =
237
static nsFontCharSetInfo ISO88591 =
229
  { "ISO-8859-1", SingleByteConvert, 0,
238
  { "ISO-8859-1", SingleByteConvert, 0,
Lines 421-435 static nsFontCharSetInfo Mathematica2 = Link Here
421
   { "x-mathematica2", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
430
   { "x-mathematica2", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
422
static nsFontCharSetInfo Mathematica3 =
431
static nsFontCharSetInfo Mathematica3 =
423
   { "x-mathematica3", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
432
   { "x-mathematica3", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
424
static nsFontCharSetInfo Mathematica4 =
433
static nsFontCharSetInfo Mathematica4 =
425
   { "x-mathematica4", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
434
   { "x-mathematica4", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
426
static nsFontCharSetInfo Mathematica5 =
435
static nsFontCharSetInfo Mathematica5 =
427
   { "x-mathematica5", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
436
   { "x-mathematica5", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
428
#endif
437
#endif /* MATHML */
438
439
#else
440
441
static nsFontCharSetInfo USASCII =
442
  { "us-ascii", SingleByteConvert, 0 };
443
static nsFontCharSetInfo ISO88591 =
444
  { "ISO-8859-1", SingleByteConvert, 0 };
445
static nsFontCharSetInfo ISO88592 =
446
  { "ISO-8859-2", SingleByteConvert, 0 };
447
static nsFontCharSetInfo ISO88593 =
448
  { "ISO-8859-3", SingleByteConvert, 0 };
449
static nsFontCharSetInfo ISO88594 =
450
  { "ISO-8859-4", SingleByteConvert, 0 };
451
static nsFontCharSetInfo ISO88595 =
452
  { "ISO-8859-5", SingleByteConvert, 0 };
453
static nsFontCharSetInfo ISO88596 =
454
  { "ISO-8859-6", SingleByteConvert, 0 };
455
static nsFontCharSetInfo ISO885968x =
456
  { "x-iso-8859-6-8-x", SingleByteConvert, 0 };
457
static nsFontCharSetInfo ISO8859616 =
458
  { "x-iso-8859-6-16", SingleByteConvert, 0 };
459
static nsFontCharSetInfo IBM1046 =
460
  { "x-IBM1046", SingleByteConvert, 0 };
461
static nsFontCharSetInfo ISO88597 =
462
  { "ISO-8859-7", SingleByteConvert, 0 };
463
static nsFontCharSetInfo ISO88598 =
464
  { "ISO-8859-8", SingleByteConvert, 0 };
465
// change from  
466
// { "ISO-8859-8", SingleByteConvertReverse, 0, 0, 0 };
467
// untill we fix the layout and ensure we only call this with pure RTL text
468
static nsFontCharSetInfo ISO88599 =
469
  { "ISO-8859-9", SingleByteConvert, 0 };
470
// no support for iso-8859-10 (Nordic/Icelandic) currently
471
// static nsFontCharSetInfo ISO885910 =
472
// { "ISO-8859-10", SingleByteConvert, 0,
473
//   0, TT_OS2_CPR2_NORDIC | TT_OS2_CPR2_ICELANDIC };
474
// no support for iso-8859-12 (Vietnamese) currently
475
// static nsFontCharSetInfo ISO885912 =
476
// { "ISO-8859-12", SingleByteConvert, 0,
477
//   TT_OS2_CPR1_VIETNAMESE, 0 };
478
static nsFontCharSetInfo ISO885913 =
479
  { "ISO-8859-13", SingleByteConvert, 0 };
480
static nsFontCharSetInfo ISO885915 =
481
  { "ISO-8859-15", SingleByteConvert, 0 };
482
static nsFontCharSetInfo JISX0201 =
483
  { "jis_0201", SingleByteConvert, 1 };
484
static nsFontCharSetInfo KOI8R =
485
  { "KOI8-R", SingleByteConvert, 0 };
486
static nsFontCharSetInfo KOI8U =
487
  { "KOI8-U", SingleByteConvert, 0 };
488
static nsFontCharSetInfo TIS6202 =
489
/* Added to support thai context sensitive shaping if
490
 * CTL extension is is in force */
491
#ifdef SUNCTL
492
  { "tis620-2", SingleByteConvert, 0 };
493
#else
494
  { "windows-874", SingleByteConvert, 0 };
495
#endif /* SUNCTL */
496
static nsFontCharSetInfo TIS620 =
497
  { "TIS-620", SingleByteConvert, 0 };
498
static nsFontCharSetInfo ISO885911 =
499
  { "ISO-8859-11", SingleByteConvert, 0 };
500
static nsFontCharSetInfo Big5 =
501
  { "x-x-big5", DoubleByteConvert, 1 };
502
// a kludge to distinguish zh-TW only fonts in Big5 (such as hpbig5-)
503
// from zh-TW/zh-HK common fonts in Big5 (such as big5-1)
504
static nsFontCharSetInfo Big5TWHK =
505
  { "x-x-big5", DoubleByteConvert, 1 };
506
static nsFontCharSetInfo CNS116431 =
507
  { "x-cns-11643-1", DoubleByteConvert, 1 };
508
static nsFontCharSetInfo CNS116432 =
509
  { "x-cns-11643-2", DoubleByteConvert, 1 };
510
static nsFontCharSetInfo CNS116433 =
511
  { "x-cns-11643-3", DoubleByteConvert, 1 };
512
static nsFontCharSetInfo CNS116434 =
513
  { "x-cns-11643-4", DoubleByteConvert, 1 };
514
static nsFontCharSetInfo CNS116435 =
515
  { "x-cns-11643-5", DoubleByteConvert, 1 };
516
static nsFontCharSetInfo CNS116436 =
517
  { "x-cns-11643-6", DoubleByteConvert, 1 };
518
static nsFontCharSetInfo CNS116437 =
519
  { "x-cns-11643-7", DoubleByteConvert, 1 };
520
static nsFontCharSetInfo GB2312 =
521
  { "gb_2312-80", DoubleByteConvert, 1 };
522
static nsFontCharSetInfo GB18030_0 =
523
  { "gb18030.2000-0", DoubleByteConvert, 1 };
524
static nsFontCharSetInfo GB18030_1 =
525
  { "gb18030.2000-1", DoubleByteConvert, 1 };
526
static nsFontCharSetInfo GBK =
527
  { "x-gbk-noascii", DoubleByteConvert, 1 };
528
static nsFontCharSetInfo HKSCS =
529
  { "hkscs-1", DoubleByteConvert, 1 };
530
static nsFontCharSetInfo JISX0208 =
531
  { "jis_0208-1983", DoubleByteConvert, 1 };
532
static nsFontCharSetInfo JISX0212 =
533
  { "jis_0212-1990", DoubleByteConvert, 1 };
534
static nsFontCharSetInfo KSC5601 =
535
  { "ks_c_5601-1987", DoubleByteConvert, 1 };
536
static nsFontCharSetInfo X11Johab =
537
  { "x-x11johab", DoubleByteConvert, 1 };
538
static nsFontCharSetInfo JohabNoAscii =
539
  { "x-johab-noascii", DoubleByteConvert, 1 };
540
static nsFontCharSetInfo JamoTTF =
541
  { "x-koreanjamo-0", DoubleByteConvert, 1 };
542
static nsFontCharSetInfo TamilTTF =
543
  { "x-tamilttf-0", DoubleByteConvert, 0 };
544
static nsFontCharSetInfo CP1250 =
545
  { "windows-1250", SingleByteConvert, 0 };
546
static nsFontCharSetInfo CP1251 =
547
  { "windows-1251", SingleByteConvert, 0 };
548
static nsFontCharSetInfo CP1252 =
549
  { "windows-1252", SingleByteConvert, 0 };
550
static nsFontCharSetInfo CP1253 =
551
  { "windows-1253", SingleByteConvert, 0 };
552
static nsFontCharSetInfo CP1257 =
553
  { "windows-1257", SingleByteConvert, 0 };
554
555
#ifdef SUNCTL
556
/* Hindi range currently unsupported in FT2 range. Change TT* once we 
557
   arrive at a way to identify hindi */
558
static nsFontCharSetInfo SunIndic =
559
  { "x-sun-unicode-india-0", DoubleByteConvert, 0 };
560
#endif /* SUNCTL */
561
562
static nsFontCharSetInfo ISO106461 =
563
  { nsnull, ISO10646Convert, 1};
564
565
static nsFontCharSetInfo AdobeSymbol =
566
   { "Adobe-Symbol-Encoding", SingleByteConvert, 0 };
567
static nsFontCharSetInfo AdobeEuro =
568
  { "x-adobe-euro", SingleByteConvert, 0 };
569
         
570
#ifdef MOZ_MATHML
571
static nsFontCharSetInfo CMCMEX =
572
   { "x-t1-cmex", SingleByteConvert, 0};
573
static nsFontCharSetInfo CMCMSY =
574
   { "x-t1-cmsy", SingleByteConvert, 0};
575
static nsFontCharSetInfo CMCMR =
576
   { "x-t1-cmr", SingleByteConvert, 0};
577
static nsFontCharSetInfo CMCMMI =
578
   { "x-t1-cmmi", SingleByteConvert, 0};
579
static nsFontCharSetInfo Mathematica1 =
580
   { "x-mathematica1", SingleByteConvert, 0};
581
static nsFontCharSetInfo Mathematica2 =
582
   { "x-mathematica2", SingleByteConvert, 0}; 
583
static nsFontCharSetInfo Mathematica3 =
584
   { "x-mathematica3", SingleByteConvert, 0};
585
static nsFontCharSetInfo Mathematica4 =
586
   { "x-mathematica4", SingleByteConvert, 0}; 
587
static nsFontCharSetInfo Mathematica5 =
588
   { "x-mathematica5", SingleByteConvert, 0};
589
#endif /* MATHML */
590
#endif /* FREETYPE2 */
429
591
430
static nsFontLangGroup FLG_WESTERN = { "x-western",     nsnull };
592
static nsFontLangGroup FLG_WESTERN = { "x-western",     nsnull };
431
static nsFontLangGroup FLG_RUSSIAN = { "x-cyrillic",    nsnull };
593
static nsFontLangGroup FLG_RUSSIAN = { "x-cyrillic",    nsnull };
432
static nsFontLangGroup FLG_BALTIC  = { "x-baltic",      nsnull };
594
static nsFontLangGroup FLG_BALTIC  = { "x-baltic",      nsnull };
433
static nsFontLangGroup FLG_CE      = { "x-central-euro",nsnull };
595
static nsFontLangGroup FLG_CE      = { "x-central-euro",nsnull };
434
static nsFontLangGroup FLG_GREEK   = { "el",            nsnull };
596
static nsFontLangGroup FLG_GREEK   = { "el",            nsnull };
435
static nsFontLangGroup FLG_TURKISH = { "tr",            nsnull };
597
static nsFontLangGroup FLG_TURKISH = { "tr",            nsnull };
Lines 817-831 FreeNodeArray(nsHashKey* aKey, void* aDa Link Here
817
static void
979
static void
818
FreeGlobals(void)
980
FreeGlobals(void)
819
{
981
{
820
  // XXX complete this
982
  // XXX complete this
821
983
822
  gInitialized = 0;
984
  gInitialized = 0;
823
985
986
#ifdef MOZ_ENABLE_FREETYPE2
824
  nsFT2FontNode::FreeGlobals();
987
  nsFT2FontNode::FreeGlobals();
988
#endif
825
989
826
#ifdef ENABLE_X_FONT_BANNING
990
#ifdef ENABLE_X_FONT_BANNING
827
  if (gFontRejectRegEx) {
991
  if (gFontRejectRegEx) {
828
    regfree(gFontRejectRegEx);
992
    regfree(gFontRejectRegEx);
829
    delete gFontRejectRegEx;
993
    delete gFontRejectRegEx;
830
    gFontRejectRegEx = nsnull;
994
    gFontRejectRegEx = nsnull;
831
  }
995
  }
Lines 1217-1235 InitGlobals(nsIDeviceContext *aDevice) Link Here
1217
      
1381
      
1218
      FreeGlobals();
1382
      FreeGlobals();
1219
      return NS_ERROR_INVALID_ARG;
1383
      return NS_ERROR_INVALID_ARG;
1220
    }    
1384
    }    
1221
  }
1385
  }
1222
#endif /* ENABLE_X_FONT_BANNING */
1386
#endif /* ENABLE_X_FONT_BANNING */
1223
1387
1388
#ifdef MOZ_ENABLE_FREETYPE2
1224
  rv = nsFT2FontNode::InitGlobals();
1389
  rv = nsFT2FontNode::InitGlobals();
1225
  if (NS_FAILED(rv)) {
1390
  if (NS_FAILED(rv)) {
1226
    FreeGlobals();
1391
    FreeGlobals();
1227
    return NS_ERROR_OUT_OF_MEMORY;
1392
    return NS_ERROR_OUT_OF_MEMORY;
1228
  }
1393
  }
1394
#endif
1229
1395
1230
  gInitialized = 1;
1396
  gInitialized = 1;
1231
1397
1232
  return NS_OK;
1398
  return NS_OK;
1233
}
1399
}
1234
1400
1235
// do the 8 to 16 bit conversion on the stack
1401
// do the 8 to 16 bit conversion on the stack
Lines 1553-1575 NS_IMETHODIMP nsFontMetricsGTK::Destroy Link Here
1553
}
1719
}
1554
1720
1555
void nsFontMetricsGTK::RealizeFont()
1721
void nsFontMetricsGTK::RealizeFont()
1556
{
1722
{
1557
  float f;
1723
  float f;
1558
  f = mDeviceContext->DevUnitsToAppUnits();
1724
  f = mDeviceContext->DevUnitsToAppUnits();
1559
1725
1726
#ifdef MOZ_ENABLE_FREETYPE2
1560
  if (mWesternFont->IsFreeTypeFont()) {
1727
  if (mWesternFont->IsFreeTypeFont()) {
1561
    nsFreeTypeFont *ft = (nsFreeTypeFont *)mWesternFont;
1728
    nsFreeTypeFont *ft = (nsFreeTypeFont *)mWesternFont;
1562
    if (!ft)
1729
    if (!ft)
1563
      return;
1730
      return;
1564
    // now that there are multiple font types (eg: core X fonts
1731
    // now that there are multiple font types (eg: core X fonts
1565
    // and TrueType fonts) there should be a common set of methods 
1732
    // and TrueType fonts) there should be a common set of methods 
1566
    // to get the metrics info from the font object. These methods
1733
    // to get the metrics info from the font object. These methods
1567
    // probably should be virtual functions defined in nsFontGTK.
1734
    // probably should be virtual functions defined in nsFontGTK.
1568
#if (defined(MOZ_ENABLE_FREETYPE2))
1569
    int lineSpacing = ft->ascent() + ft->descent();
1735
    int lineSpacing = ft->ascent() + ft->descent();
1570
    if (lineSpacing > mWesternFont->mSize) {
1736
    if (lineSpacing > mWesternFont->mSize) {
1571
      mLeading = nscoord((lineSpacing - mWesternFont->mSize) * f);
1737
      mLeading = nscoord((lineSpacing - mWesternFont->mSize) * f);
1572
    }
1738
    }
1573
    else {
1739
    else {
1574
      mLeading = 0;
1740
      mLeading = 0;
1575
    }
1741
    }
Lines 1633-1648 void nsFontMetricsGTK::RealizeFont() Link Here
1633
    }
1799
    }
1634
1800
1635
    /* need better way to calculate this */
1801
    /* need better way to calculate this */
1636
    mStrikeoutOffset = NSToCoordRound(mXHeight / 2.0);
1802
    mStrikeoutOffset = NSToCoordRound(mXHeight / 2.0);
1637
    mStrikeoutSize = mUnderlineSize;
1803
    mStrikeoutSize = mUnderlineSize;
1638
1804
1639
    return;
1805
    return;
1640
#endif /* (defined(MOZ_ENABLE_FREETYPE2)) */
1641
  }
1806
  }
1807
#endif
1642
  nsXFont *xFont = mWesternFont->GetXFont();
1808
  nsXFont *xFont = mWesternFont->GetXFont();
1643
  XFontStruct *fontInfo = xFont->GetXFontStruct();
1809
  XFontStruct *fontInfo = xFont->GetXFontStruct();
1644
  f = mDeviceContext->DevUnitsToAppUnits();
1810
  f = mDeviceContext->DevUnitsToAppUnits();
1645
1811
1646
  nscoord lineSpacing = nscoord((fontInfo->ascent + fontInfo->descent) * f);
1812
  nscoord lineSpacing = nscoord((fontInfo->ascent + fontInfo->descent) * f);
1647
  mEmHeight = PR_MAX(1, nscoord(mWesternFont->mSize * f));
1813
  mEmHeight = PR_MAX(1, nscoord(mWesternFont->mSize * f));
1648
  if (lineSpacing > mEmHeight) {
1814
  if (lineSpacing > mEmHeight) {
Lines 3251-3264 nsFontMetricsGTK::GetAASBBaseFont(nsFont Link Here
3251
  return base_aafont;
3417
  return base_aafont;
3252
}
3418
}
3253
3419
3254
nsFontGTK*
3420
nsFontGTK*
3255
nsFontMetricsGTK::PickASizeAndLoad(nsFontStretch* aStretch,
3421
nsFontMetricsGTK::PickASizeAndLoad(nsFontStretch* aStretch,
3256
  nsFontCharSetInfo* aCharSet, PRUint32 aChar, const char *aName)
3422
  nsFontCharSetInfo* aCharSet, PRUint32 aChar, const char *aName)
3257
{
3423
{
3424
3425
#ifdef MOZ_ENABLE_FREETYPE2
3258
  if (aStretch->mFreeTypeFaceID) {
3426
  if (aStretch->mFreeTypeFaceID) {
3259
    //FREETYPE_FONT_PRINTF(("mFreeTypeFaceID = 0x%p", aStretch->mFreeTypeFaceID));
3427
    //FREETYPE_FONT_PRINTF(("mFreeTypeFaceID = 0x%p", aStretch->mFreeTypeFaceID));
3260
    nsFreeTypeFont *ftfont = nsFreeTypeFont::NewFont(aStretch->mFreeTypeFaceID,
3428
    nsFreeTypeFont *ftfont = nsFreeTypeFont::NewFont(aStretch->mFreeTypeFaceID,
3261
                                                     mPixelSize,
3429
                                                     mPixelSize,
3262
                                                     aName);
3430
                                                     aName);
3263
    if (!ftfont) {
3431
    if (!ftfont) {
3264
      FREETYPE_FONT_PRINTF(("failed to create font"));
3432
      FREETYPE_FONT_PRINTF(("failed to create font"));
Lines 3283-3296 nsFontMetricsGTK::PickASizeAndLoad(nsFon Link Here
3283
    return AddToLoadedFontsList(ftfont);
3451
    return AddToLoadedFontsList(ftfont);
3284
  }
3452
  }
3285
3453
3286
  if (IS_SURROGATE(aChar)) {
3454
  if (IS_SURROGATE(aChar)) {
3287
    // SURROGATE is only supported by FreeType
3455
    // SURROGATE is only supported by FreeType
3288
    return nsnull;
3456
    return nsnull;
3289
  }
3457
  }
3458
#endif
3290
3459
3291
  PRBool use_scaled_font = PR_FALSE;
3460
  PRBool use_scaled_font = PR_FALSE;
3292
  PRBool have_nearly_rightsized_bitmap = PR_FALSE;
3461
  PRBool have_nearly_rightsized_bitmap = PR_FALSE;
3293
  nsFontGTK* base_aafont = nsnull;
3462
  nsFontGTK* base_aafont = nsnull;
3294
3463
3295
  PRInt32 bitmap_size = NOT_FOUND_FONT_SIZE;
3464
  PRInt32 bitmap_size = NOT_FOUND_FONT_SIZE;
3296
  PRInt32 scale_size = mPixelSize;
3465
  PRInt32 scale_size = mPixelSize;
Lines 5191-5206 GetFontNames(const char* aPattern, PRBoo Link Here
5191
{
5360
{
5192
#ifdef NS_FONT_DEBUG_CALL_TRACE
5361
#ifdef NS_FONT_DEBUG_CALL_TRACE
5193
  if (gFontDebug & NS_FONT_DEBUG_CALL_TRACE) {
5362
  if (gFontDebug & NS_FONT_DEBUG_CALL_TRACE) {
5194
    printf("GetFontNames %s\n", aPattern);
5363
    printf("GetFontNames %s\n", aPattern);
5195
  }
5364
  }
5196
#endif
5365
#endif
5197
5366
5367
#ifdef MOZ_ENABLE_FREETYPE2
5198
  // get FreeType fonts
5368
  // get FreeType fonts
5199
  nsFT2FontNode::GetFontNames(aPattern, aNodes);
5369
  nsFT2FontNode::GetFontNames(aPattern, aNodes);
5370
#endif
5200
5371
5201
  nsCAutoString previousNodeName;
5372
  nsCAutoString previousNodeName;
5202
  nsHashtable* node_hash;
5373
  nsHashtable* node_hash;
5203
  if (aAnyFoundry) {
5374
  if (aAnyFoundry) {
5204
    NS_ASSERTION(aPattern[1] == '*', "invalid 'anyFoundry' pattern");
5375
    NS_ASSERTION(aPattern[1] == '*', "invalid 'anyFoundry' pattern");
5205
    node_hash = gAFRENodes;
5376
    node_hash = gAFRENodes;
5206
  }
5377
  }
Lines 6565-6582 GetCharSetMap(const char *aCharSetName) Link Here
6565
    nsFontCharSetMap* charSetMap =
6736
    nsFontCharSetMap* charSetMap =
6566
      (nsFontCharSetMap*) gCharSetMaps->Get(&charSetKey);
6737
      (nsFontCharSetMap*) gCharSetMaps->Get(&charSetKey);
6567
    if (!charSetMap)
6738
    if (!charSetMap)
6568
      charSetMap = gNoneCharSetMap;
6739
      charSetMap = gNoneCharSetMap;
6569
  return charSetMap;
6740
  return charSetMap;
6570
}
6741
}
6571
6742
6743
#ifdef MOZ_ENABLE_FREETYPE2
6572
void
6744
void
6573
CharSetNameToCodeRangeBits(const char *aCharset,
6745
CharSetNameToCodeRangeBits(const char *aCharset,
6574
                           PRUint32 *aCodeRange1, PRUint32 *aCodeRange2)
6746
                           PRUint32 *aCodeRange1, PRUint32 *aCodeRange2)
6575
{
6747
{
6576
  nsFontCharSetMap *charSetMap = GetCharSetMap(aCharset);
6748
  nsFontCharSetMap *charSetMap = GetCharSetMap(aCharset);
6577
  nsFontCharSetInfo* charSetInfo = charSetMap->mInfo;
6749
  nsFontCharSetInfo* charSetInfo = charSetMap->mInfo;
6578
6750
6579
  *aCodeRange1 = charSetInfo->mCodeRange1Bits;
6751
  *aCodeRange1 = charSetInfo->mCodeRange1Bits;
6580
  *aCodeRange2 = charSetInfo->mCodeRange2Bits;
6752
  *aCodeRange2 = charSetInfo->mCodeRange2Bits;
6581
}
6753
}
6754
#endif
6582
6755
(-)gfx/src/gtk/nsFontMetricsGTK.h (+6 lines)
Lines 48-62 Link Here
48
#include "nsIDeviceContext.h"
48
#include "nsIDeviceContext.h"
49
#include "nsCRT.h"
49
#include "nsCRT.h"
50
#include "nsCOMPtr.h"
50
#include "nsCOMPtr.h"
51
#include "nsRenderingContextGTK.h"
51
#include "nsRenderingContextGTK.h"
52
#include "nsICharRepresentable.h"
52
#include "nsICharRepresentable.h"
53
#include "nsCompressedCharMap.h"
53
#include "nsCompressedCharMap.h"
54
#include "nsIFontMetricsGTK.h"
54
#include "nsIFontMetricsGTK.h"
55
#ifdef MOZ_ENABLE_FREETYPE2
55
#include "nsIFontCatalogService.h"
56
#include "nsIFontCatalogService.h"
57
#endif
56
58
57
#include <gdk/gdk.h>
59
#include <gdk/gdk.h>
58
#include <gdk/gdkx.h>
60
#include <gdk/gdkx.h>
59
61
60
#undef FONT_HAS_GLYPH
62
#undef FONT_HAS_GLYPH
61
#define FONT_HAS_GLYPH(map, char) IS_REPRESENTABLE(map, char)
63
#define FONT_HAS_GLYPH(map, char) IS_REPRESENTABLE(map, char)
62
#define WEIGHT_INDEX(weight) (((weight) / 100) - 1)
64
#define WEIGHT_INDEX(weight) (((weight) / 100) - 1)
Lines 88-102 struct nsFontStretch Link Here
88
  nsFontGTK**        mSizes;
90
  nsFontGTK**        mSizes;
89
  PRUint16           mSizesAlloc;
91
  PRUint16           mSizesAlloc;
90
  PRUint16           mSizesCount;
92
  PRUint16           mSizesCount;
91
93
92
  char*              mScalable;
94
  char*              mScalable;
93
  PRBool             mOutlineScaled;
95
  PRBool             mOutlineScaled;
94
  nsVoidArray        mScaledFonts;
96
  nsVoidArray        mScaledFonts;
97
#ifdef MOZ_ENABLE_FREETYPE2
95
  nsITrueTypeFontCatalogEntry*   mFreeTypeFaceID;
98
  nsITrueTypeFontCatalogEntry*   mFreeTypeFaceID;
99
#endif
96
};
100
};
97
101
98
struct nsFontStyle
102
struct nsFontStyle
99
{
103
{
100
  NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
104
  NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
101
105
102
  void FillWeightHoles(void);
106
  void FillWeightHoles(void);
Lines 407-420 public: Link Here
407
  NS_DECL_ISUPPORTS
411
  NS_DECL_ISUPPORTS
408
  NS_DECL_NSIFONTENUMERATOR
412
  NS_DECL_NSIFONTENUMERATOR
409
};
413
};
410
414
411
class nsHashKey;
415
class nsHashKey;
412
PRBool FreeNode(nsHashKey* aKey, void* aData, void* aClosure);
416
PRBool FreeNode(nsHashKey* aKey, void* aData, void* aClosure);
413
nsFontCharSetInfo *GetCharSetInfo(const char *aCharSetName);
417
nsFontCharSetInfo *GetCharSetInfo(const char *aCharSetName);
418
#ifdef MOZ_ENABLE_FREETYPE2
414
void CharSetNameToCodeRangeBits(const char*, PRUint32*, PRUint32*);
419
void CharSetNameToCodeRangeBits(const char*, PRUint32*, PRUint32*);
420
#endif
415
nsFontCharSetMap *GetCharSetMap(const char *aCharSetName);
421
nsFontCharSetMap *GetCharSetMap(const char *aCharSetName);
416
422
417
423
418
424
419
425
420
#endif
426
#endif
(-)gfx/src/gtk/nsFontMetricsXft.cpp (-217 / +14 lines)
Lines 60-73 Link Here
60
#include "nsICharsetConverterManager.h"
60
#include "nsICharsetConverterManager.h"
61
#include "nsICharRepresentable.h"
61
#include "nsICharRepresentable.h"
62
#include "nsIPersistentProperties2.h"
62
#include "nsIPersistentProperties2.h"
63
#include "nsCompressedCharMap.h"
63
#include "nsCompressedCharMap.h"
64
#include "nsNetUtil.h"
64
#include "nsNetUtil.h"
65
#include "nsClassHashtable.h"
65
#include "nsClassHashtable.h"
66
#include "nsAutoBuffer.h"
66
#include "nsAutoBuffer.h"
67
#include "nsFontConfigUtils.h"
67
68
68
#include <gdk/gdkx.h>
69
#include <gdk/gdkx.h>
69
#include <freetype/tttables.h>
70
#include <freetype/tttables.h>
70
#include <freetype/freetype.h>
71
#include <freetype/freetype.h>
71
72
72
#define FORCE_PR_LOG
73
#define FORCE_PR_LOG
73
#include "prlog.h"
74
#include "prlog.h"
Lines 190-223 class nsFontXftInfo { Link Here
190
    // Unicode, Custom, CustomWide
191
    // Unicode, Custom, CustomWide
191
    nsXftFontType               mFontType;
192
    nsXftFontType               mFontType;
192
    // Truetype cmap to use for direct retrieval of GIDs with FT_Get_Char_Index
193
    // Truetype cmap to use for direct retrieval of GIDs with FT_Get_Char_Index
193
    // for 'narrow' custom fonts.
194
    // for 'narrow' custom fonts.
194
    FT_Encoding                 mFT_Encoding;
195
    FT_Encoding                 mFT_Encoding;
195
};
196
};
196
197
197
struct MozXftLangGroup {
198
    const char    *mozLangGroup;
199
    FcChar32       character;
200
    const FcChar8 *XftLang;
201
};
202
203
static const MozXftLangGroup MozXftLangGroups[] = {
204
    { "x-western",      0x0041, (const FcChar8 *)"en" },
205
    { "x-central-euro", 0x0100, (const FcChar8 *)"pl" },
206
    { "x-cyrillic",     0x0411, (const FcChar8 *)"ru" },
207
    { "x-baltic",       0x0104, (const FcChar8 *)"lv" },
208
    { "x-devanagari",   0x0905, (const FcChar8 *)"hi" },
209
    { "x-tamil",        0x0B85, (const FcChar8 *)"ta" },
210
    { "x-unicode",      0x0000,                  0    },
211
    { "x-user-def",     0x0000,                  0    },
212
};
213
214
#define NUM_XFT_LANG_GROUPS (sizeof (MozXftLangGroups) / \
215
                             sizeof (MozXftLangGroups[0]))
216
217
struct DrawStringData {
198
struct DrawStringData {
218
    nscoord                x;
199
    nscoord                x;
219
    nscoord                y;
200
    nscoord                y;
220
    const nscoord         *spacing;
201
    const nscoord         *spacing;
221
    nscoord                xOffset;
202
    nscoord                xOffset;
222
    nsRenderingContextGTK *context;
203
    nsRenderingContextGTK *context;
223
    XftDraw               *draw;
204
    XftDraw               *draw;
Lines 232-260 struct BoundingMetricsData { Link Here
232
    PRBool firstTime;
213
    PRBool firstTime;
233
};
214
};
234
#endif /* MOZ_MATHML */
215
#endif /* MOZ_MATHML */
235
216
236
#define AUTO_BUFFER_SIZE 3000
217
#define AUTO_BUFFER_SIZE 3000
237
typedef nsAutoBuffer<FcChar32, AUTO_BUFFER_SIZE> nsAutoFcChar32Buffer;
218
typedef nsAutoBuffer<FcChar32, AUTO_BUFFER_SIZE> nsAutoFcChar32Buffer;
238
219
239
static int      CalculateSlant   (PRUint8  aStyle);
240
static int      CalculateWeight  (PRUint16 aWeight);
241
static void     AddLangGroup     (FcPattern *aPattern, nsIAtom *aLangGroup);
242
static void     AddFFRE          (FcPattern *aPattern, nsCString *aFamily,
243
                                  PRBool aWeak);
244
static void     FFREToFamily     (nsACString &aFFREName, nsACString &oFamily);
245
static int      FFRECountHyphens (nsACString &aFFREName);
246
static int      CompareFontNames (const void* aArg1, const void* aArg2,
220
static int      CompareFontNames (const void* aArg1, const void* aArg2,
247
                                  void* aClosure);
221
                                  void* aClosure);
248
static PRBool   IsASCIIFontName  (const nsString& aName);
249
static nsresult EnumFontsXft     (nsIAtom* aLangGroup, const char* aGeneric,
222
static nsresult EnumFontsXft     (nsIAtom* aLangGroup, const char* aGeneric,
250
                                  PRUint32* aCount, PRUnichar*** aResult);
223
                                  PRUint32* aCount, PRUnichar*** aResult);
251
224
252
static const MozXftLangGroup* FindFCLangGroup (nsACString &aLangGroup);
253
254
static        void ConvertCharToUCS4    (const char *aString,
225
static        void ConvertCharToUCS4    (const char *aString,
255
                                         PRUint32 aLength,
226
                                         PRUint32 aLength,
256
                                         nsAutoFcChar32Buffer &aOutBuffer,
227
                                         nsAutoFcChar32Buffer &aOutBuffer,
257
                                         PRUint32 *aOutLen);
228
                                         PRUint32 *aOutLen);
258
static        void ConvertUnicharToUCS4 (const PRUnichar *aString,
229
static        void ConvertUnicharToUCS4 (const PRUnichar *aString,
259
                                         PRUint32 aLength,
230
                                         PRUint32 aLength,
260
                                         nsAutoFcChar32Buffer &aOutBuffer,
231
                                         nsAutoFcChar32Buffer &aOutBuffer,
Lines 1018-1038 nsFontMetricsXft::SetupFCPattern(void) Link Here
1018
    for (int i=0; i < mFontList.Count(); ++i) {
989
    for (int i=0; i < mFontList.Count(); ++i) {
1019
        // if this was a generic name, break out of the loop since we
990
        // if this was a generic name, break out of the loop since we
1020
        // don't want to add it to the pattern yet
991
        // don't want to add it to the pattern yet
1021
        if (mFontIsGeneric[i])
992
        if (mFontIsGeneric[i])
1022
            break;;
993
            break;;
1023
994
1024
        nsCString *familyName = mFontList.CStringAt(i);
995
        nsCString *familyName = mFontList.CStringAt(i);
1025
        AddFFRE(mPattern, familyName, PR_FALSE);
996
        NS_AddFFRE(mPattern, familyName, PR_FALSE);
1026
    }
997
    }
1027
998
1028
    // Add the language group.  Note that we do this before adding any
999
    // Add the language group.  Note that we do this before adding any
1029
    // generics.  That's because the language is more important than
1000
    // generics.  That's because the language is more important than
1030
    // any generic font.
1001
    // any generic font.
1031
    AddLangGroup (mPattern, mLangGroup);
1002
    NS_AddLangGroup (mPattern, mLangGroup);
1032
1003
1033
    // If there's a generic add a pref for the generic if there's one
1004
    // If there's a generic add a pref for the generic if there's one
1034
    // set.
1005
    // set.
1035
    if (mGenericFont && !mFont->systemFont) {
1006
    if (mGenericFont && !mFont->systemFont) {
1036
        nsCString name;
1007
        nsCString name;
1037
        name += "font.name.";
1008
        name += "font.name.";
1038
        name += mGenericFont->get();
1009
        name += mGenericFont->get();
Lines 1048-1078 nsFontMetricsXft::SetupFCPattern(void) Link Here
1048
        if (pref) {
1019
        if (pref) {
1049
            nsresult rv;
1020
            nsresult rv;
1050
            nsXPIDLCString value;
1021
            nsXPIDLCString value;
1051
            rv = pref->GetCharPref(name.get(), getter_Copies(value));
1022
            rv = pref->GetCharPref(name.get(), getter_Copies(value));
1052
1023
1053
            // we ignore prefs that have three hypens since they are X
1024
            // we ignore prefs that have three hypens since they are X
1054
            // style prefs.
1025
            // style prefs.
1055
            if (FFRECountHyphens(value) < 3) {
1026
            if (NS_FFRECountHyphens(value) < 3) {
1056
                nsCString tmpstr;
1027
                nsCString tmpstr;
1057
                tmpstr.Append(value);
1028
                tmpstr.Append(value);
1058
1029
1059
                if (PR_LOG_TEST(gXftFontLoad, PR_LOG_DEBUG)) {
1030
                if (PR_LOG_TEST(gXftFontLoad, PR_LOG_DEBUG)) {
1060
                    printf("\tadding generic font from preferences: %s\n",
1031
                    printf("\tadding generic font from preferences: %s\n",
1061
                           tmpstr.get());
1032
                           tmpstr.get());
1062
                }
1033
                }
1063
1034
1064
                AddFFRE(mPattern, &tmpstr, PR_FALSE);
1035
                NS_AddFFRE(mPattern, &tmpstr, PR_FALSE);
1065
            }
1036
            }
1066
        }
1037
        }
1067
    }
1038
    }
1068
1039
1069
    // Add the generic if there is one.
1040
    // Add the generic if there is one.
1070
    if (mGenericFont && !mFont->systemFont)
1041
    if (mGenericFont && !mFont->systemFont)
1071
        AddFFRE(mPattern, mGenericFont, PR_FALSE);
1042
        NS_AddFFRE(mPattern, mGenericFont, PR_FALSE);
1072
1043
1073
    if (PR_LOG_TEST(gXftFontLoad, PR_LOG_DEBUG)) {
1044
    if (PR_LOG_TEST(gXftFontLoad, PR_LOG_DEBUG)) {
1074
        // generic font
1045
        // generic font
1075
        if (mGenericFont && !mFont->systemFont) {
1046
        if (mGenericFont && !mFont->systemFont) {
1076
            printf("\tadding generic family: %s\n", mGenericFont->get());
1047
            printf("\tadding generic family: %s\n", mGenericFont->get());
1077
        }
1048
        }
1078
1049
Lines 1091-1121 nsFontMetricsXft::SetupFCPattern(void) Link Here
1091
        default:
1062
        default:
1092
            printf("roman\n");
1063
            printf("roman\n");
1093
            break;
1064
            break;
1094
        }
1065
        }
1095
1066
1096
        // weight
1067
        // weight
1097
        printf("\tweight: (orig,calc) %d,%d\n",
1068
        printf("\tweight: (orig,calc) %d,%d\n",
1098
               mFont->weight, CalculateWeight(mFont->weight));
1069
               mFont->weight, NS_CalculateWeight(mFont->weight));
1099
1070
1100
    }        
1071
    }        
1101
1072
1102
    // add the point size
1073
    // add the point size
1103
    // We've done some round-tripping of floating point numbers so they
1074
    // We've done some round-tripping of floating point numbers so they
1104
    // might not be quite right.  Since Xft rounds down, add a little,
1075
    // might not be quite right.  Since Xft rounds down, add a little,
1105
    // so we don't go from 9.00000 to 8.99999 to 8.
1076
    // so we don't go from 9.00000 to 8.99999 to 8.
1106
    FcPatternAddDouble(mPattern, FC_PIXEL_SIZE, mPixelSize + 0.000001);
1077
    FcPatternAddDouble(mPattern, FC_PIXEL_SIZE, mPixelSize + 0.000001);
1107
1078
1108
    // Add the slant type
1079
    // Add the slant type
1109
    FcPatternAddInteger(mPattern, FC_SLANT,
1080
    FcPatternAddInteger(mPattern, FC_SLANT,
1110
                        CalculateSlant(mFont->style));
1081
                        NS_CalculateSlant(mFont->style));
1111
1082
1112
    // Add the weight
1083
    // Add the weight
1113
    FcPatternAddInteger(mPattern, FC_WEIGHT,
1084
    FcPatternAddInteger(mPattern, FC_WEIGHT,
1114
                        CalculateWeight(mFont->weight));
1085
                        NS_CalculateWeight(mFont->weight));
1115
1086
1116
    // Set up the default substitutions for this font
1087
    // Set up the default substitutions for this font
1117
    FcConfigSubstitute(0, mPattern, FcMatchPattern);
1088
    FcConfigSubstitute(0, mPattern, FcMatchPattern);
1118
    XftDefaultSubstitute(GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()),
1089
    XftDefaultSubstitute(GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()),
1119
                         mPattern);
1090
                         mPattern);
1120
}
1091
}
1121
1092
Lines 1270-1284 nsFontMetricsXft::SetupMiniFont(void) Link Here
1270
        XftPatternAddBool(mPattern, XFT_RENDER, False);
1241
        XftPatternAddBool(mPattern, XFT_RENDER, False);
1271
1242
1272
    FcPatternAddString(pattern, FC_FAMILY, (FcChar8 *)"monospace");
1243
    FcPatternAddString(pattern, FC_FAMILY, (FcChar8 *)"monospace");
1273
1244
1274
    FcPatternAddInteger(pattern, FC_PIXEL_SIZE, int(0.5 * mPixelSize));
1245
    FcPatternAddInteger(pattern, FC_PIXEL_SIZE, int(0.5 * mPixelSize));
1275
1246
1276
    FcPatternAddInteger(pattern, FC_WEIGHT,
1247
    FcPatternAddInteger(pattern, FC_WEIGHT,
1277
                        CalculateWeight(mFont->weight));
1248
                        NS_CalculateWeight(mFont->weight));
1278
1249
1279
    FcConfigSubstitute(0, pattern, FcMatchPattern);
1250
    FcConfigSubstitute(0, pattern, FcMatchPattern);
1280
    XftDefaultSubstitute(GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()),
1251
    XftDefaultSubstitute(GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY()),
1281
                         pattern);
1252
                         pattern);
1282
1253
1283
    FcResult res;
1254
    FcResult res;
1284
    
1255
    
Lines 1686-1700 nsFontMetricsXft::BoundingMetricsCallbac Link Here
1686
#endif /* MOZ_MATHML */
1657
#endif /* MOZ_MATHML */
1687
1658
1688
/* static */
1659
/* static */
1689
nsresult
1660
nsresult
1690
nsFontMetricsXft::FamilyExists(nsIDeviceContext *aDevice,
1661
nsFontMetricsXft::FamilyExists(nsIDeviceContext *aDevice,
1691
                               const nsString &aName)
1662
                               const nsString &aName)
1692
{
1663
{
1693
    if (!IsASCIIFontName(aName))
1664
    if (!NS_IsASCIIFontName(aName))
1694
        return NS_ERROR_FAILURE;
1665
        return NS_ERROR_FAILURE;
1695
1666
1696
    NS_ConvertUCS2toUTF8 name(aName);
1667
    NS_ConvertUCS2toUTF8 name(aName);
1697
1668
1698
    FcFontSet *set = nsnull;
1669
    FcFontSet *set = nsnull;
1699
    FcObjectSet *os = nsnull;
1670
    FcObjectSet *os = nsnull;
1700
1671
Lines 1744-1758 nsFontMetricsXft::FamilyExists(nsIDevice Link Here
1744
/* static */
1715
/* static */
1745
PRBool
1716
PRBool
1746
nsFontMetricsXft::EnumFontCallback(const nsString &aFamily, PRBool aIsGeneric,
1717
nsFontMetricsXft::EnumFontCallback(const nsString &aFamily, PRBool aIsGeneric,
1747
                                   void *aData)
1718
                                   void *aData)
1748
{
1719
{
1749
    // make sure it's an ascii name, if not then return and continue
1720
    // make sure it's an ascii name, if not then return and continue
1750
    // enumerating
1721
    // enumerating
1751
    if (!IsASCIIFontName(aFamily))
1722
    if (!NS_IsASCIIFontName(aFamily))
1752
        return PR_TRUE;
1723
        return PR_TRUE;
1753
1724
1754
    nsCAutoString name;
1725
    nsCAutoString name;
1755
    name.AssignWithConversion(aFamily.get());
1726
    name.AssignWithConversion(aFamily.get());
1756
    ToLowerCase(name);
1727
    ToLowerCase(name);
1757
    nsFontMetricsXft *metrics = (nsFontMetricsXft *)aData;
1728
    nsFontMetricsXft *metrics = (nsFontMetricsXft *)aData;
1758
    metrics->mFontList.AppendCString(name);
1729
    metrics->mFontList.AppendCString(name);
Lines 1842-1856 nsFontEnumeratorXft::GetDefaultFont(cons Link Here
1842
    match_pattern = FcPatternCreate();
1813
    match_pattern = FcPatternCreate();
1843
1814
1844
  if (!match_pattern)
1815
  if (!match_pattern)
1845
    return NS_OK; // not fatal, just return an empty default name
1816
    return NS_OK; // not fatal, just return an empty default name
1846
1817
1847
  if (aLangGroup && *aLangGroup) {
1818
  if (aLangGroup && *aLangGroup) {
1848
    nsCOMPtr<nsIAtom> langGroup = do_GetAtom(aLangGroup);
1819
    nsCOMPtr<nsIAtom> langGroup = do_GetAtom(aLangGroup);
1849
    AddLangGroup(match_pattern, langGroup);
1820
    NS_AddLangGroup(match_pattern, langGroup);
1850
  }
1821
  }
1851
1822
1852
  FcConfigSubstitute(0, match_pattern, FcMatchPattern); 
1823
  FcConfigSubstitute(0, match_pattern, FcMatchPattern); 
1853
  FcDefaultSubstitute(match_pattern);
1824
  FcDefaultSubstitute(match_pattern);
1854
  FcPattern* result_pattern = FcFontMatch(0, match_pattern, &res);
1825
  FcPattern* result_pattern = FcFontMatch(0, match_pattern, &res);
1855
  if (result_pattern) {
1826
  if (result_pattern) {
1856
    char *family;
1827
    char *family;
Lines 2227-2408 nsAutoDrawSpecBuffer::Flush() Link Here
2227
    }
2198
    }
2228
}
2199
}
2229
2200
2230
// Static functions
2201
// Static functions
2231
2202
2232
/* static */
2203
/* static */
2233
int
2204
int
2234
CalculateSlant(PRUint8 aStyle)
2235
{
2236
    int fcSlant;
2237
2238
    switch(aStyle) {
2239
    case NS_FONT_STYLE_ITALIC:
2240
        fcSlant = FC_SLANT_ITALIC;
2241
        break;
2242
    case NS_FONT_STYLE_OBLIQUE:
2243
        fcSlant = FC_SLANT_OBLIQUE;
2244
        break;
2245
    default:
2246
        fcSlant = FC_SLANT_ROMAN;
2247
        break;
2248
    }
2249
2250
    return fcSlant;
2251
}
2252
2253
/* static */
2254
int
2255
CalculateWeight (PRUint16 aWeight)
2256
{
2257
    /*
2258
     * weights come in two parts crammed into one
2259
     * integer -- the "base" weight is weight / 100,
2260
     * the rest of the value is the "offset" from that
2261
     * weight -- the number of steps to move to adjust
2262
     * the weight in the list of supported font weights,
2263
     * this value can be negative or positive.
2264
     */
2265
    PRInt32 baseWeight = (aWeight + 50) / 100;
2266
    PRInt32 offset = aWeight - baseWeight * 100;
2267
2268
    /* clip weights to range 0 to 9 */
2269
    if (baseWeight < 0)
2270
        baseWeight = 0;
2271
    if (baseWeight > 9)
2272
        baseWeight = 9;
2273
2274
    /* Map from weight value to fcWeights index */
2275
    static int fcWeightLookup[10] = {
2276
        0, 0, 0, 0, 1, 1, 2, 3, 3, 4,
2277
    };
2278
2279
    PRInt32 fcWeight = fcWeightLookup[baseWeight];
2280
2281
    /*
2282
     * adjust by the offset value, make sure we stay inside the 
2283
     * fcWeights table
2284
     */
2285
    fcWeight += offset;
2286
2287
    if (fcWeight < 0)
2288
        fcWeight = 0;
2289
    if (fcWeight > 4)
2290
        fcWeight = 4;
2291
2292
    /* Map to final FC_WEIGHT value */
2293
    static int fcWeights[5] = {
2294
        FC_WEIGHT_LIGHT,      /* 0 */
2295
        FC_WEIGHT_MEDIUM,     /* 1 */
2296
        FC_WEIGHT_DEMIBOLD,   /* 2 */
2297
        FC_WEIGHT_BOLD,       /* 3 */
2298
        FC_WEIGHT_BLACK,      /* 4 */
2299
    };
2300
2301
    return fcWeights[fcWeight];
2302
2303
}
2304
2305
/* static */
2306
void
2307
AddLangGroup(FcPattern *aPattern, nsIAtom *aLangGroup)
2308
{
2309
    // Find the FC lang group for this lang group
2310
    nsCAutoString cname;
2311
    aLangGroup->ToUTF8String(cname);
2312
2313
    // see if the lang group needs to be translated from mozilla's
2314
    // internal mapping into fontconfig's
2315
    const struct MozXftLangGroup *langGroup;
2316
    langGroup = FindFCLangGroup(cname);
2317
2318
    // if there's no lang group, just use the lang group as it was
2319
    // passed to us
2320
    //
2321
    // we're casting away the const here for the strings - should be
2322
    // safe.
2323
    if (!langGroup)
2324
        FcPatternAddString(aPattern, FC_LANG, (FcChar8 *)cname.get());
2325
    else if (langGroup->XftLang) 
2326
        FcPatternAddString(aPattern, FC_LANG, (FcChar8 *)langGroup->XftLang);
2327
}
2328
2329
/* static */
2330
void
2331
AddFFRE(FcPattern *aPattern, nsCString *aFamily, PRBool aWeak)
2332
{
2333
    nsCAutoString family;
2334
    FFREToFamily(*aFamily, family);
2335
2336
    FcValue v;
2337
    v.type = FcTypeString;
2338
    // casting away the const here, should be safe
2339
    v.u.s = (FcChar8 *)family.get();
2340
2341
    if (aWeak)
2342
        FcPatternAddWeak(aPattern, FC_FAMILY, v, FcTrue);
2343
    else
2344
        FcPatternAdd(aPattern, FC_FAMILY, v, FcTrue);
2345
}
2346
2347
/* static */
2348
void
2349
FFREToFamily(nsACString &aFFREName, nsACString &oFamily)
2350
{
2351
  if (FFRECountHyphens(aFFREName) == 3) {
2352
      PRInt32 familyHyphen = aFFREName.FindChar('-') + 1;
2353
      PRInt32 registryHyphen = aFFREName.FindChar('-',familyHyphen);
2354
      oFamily.Append(Substring(aFFREName, familyHyphen,
2355
                               registryHyphen-familyHyphen));
2356
  }
2357
  else {
2358
      oFamily.Append(aFFREName);
2359
  }
2360
}
2361
2362
/* static */
2363
int
2364
FFRECountHyphens (nsACString &aFFREName)
2365
{
2366
    int h = 0;
2367
    PRInt32 hyphen = 0;
2368
    while ((hyphen = aFFREName.FindChar('-', hyphen)) >= 0) {
2369
        ++h;
2370
        ++hyphen;
2371
    }
2372
    return h;
2373
}
2374
2375
/* static */
2376
int
2377
CompareFontNames (const void* aArg1, const void* aArg2, void* aClosure)
2205
CompareFontNames (const void* aArg1, const void* aArg2, void* aClosure)
2378
{
2206
{
2379
    const PRUnichar* str1 = *((const PRUnichar**) aArg1);
2207
    const PRUnichar* str1 = *((const PRUnichar**) aArg1);
2380
    const PRUnichar* str2 = *((const PRUnichar**) aArg2);
2208
    const PRUnichar* str2 = *((const PRUnichar**) aArg2);
2381
2209
2382
    return nsCRT::strcmp(str1, str2);
2210
    return nsCRT::strcmp(str1, str2);
2383
}
2211
}
2384
2212
2385
PRBool
2386
IsASCIIFontName(const nsString& aName)
2387
{
2388
    PRUint32 len = aName.Length();
2389
    const PRUnichar* str = aName.get();
2390
    for (PRUint32 i = 0; i < len; i++) {
2391
        /*
2392
         * X font names are printable ASCII, ignore others (for now)
2393
         */
2394
        if ((str[i] < 0x20) || (str[i] > 0x7E)) {
2395
            return PR_FALSE;
2396
        }
2397
    }
2398
  
2399
    return PR_TRUE;
2400
}
2401
2402
/* static */
2213
/* static */
2403
nsresult
2214
nsresult
2404
EnumFontsXft(nsIAtom* aLangGroup, const char* aGeneric,
2215
EnumFontsXft(nsIAtom* aLangGroup, const char* aGeneric,
2405
             PRUint32* aCount, PRUnichar*** aResult)
2216
             PRUint32* aCount, PRUnichar*** aResult)
2406
{
2217
{
2407
    FcPattern   *pat = NULL;
2218
    FcPattern   *pat = NULL;
2408
    FcObjectSet *os  = NULL;
2219
    FcObjectSet *os  = NULL;
Lines 2422-2436 EnumFontsXft(nsIAtom* aLangGroup, const Link Here
2422
2233
2423
    os = FcObjectSetBuild(FC_FAMILY, FC_FOUNDRY, 0);
2234
    os = FcObjectSetBuild(FC_FAMILY, FC_FOUNDRY, 0);
2424
    if (!os)
2235
    if (!os)
2425
        goto end;
2236
        goto end;
2426
2237
2427
    // take the pattern and add the lang group to it
2238
    // take the pattern and add the lang group to it
2428
    if (aLangGroup)
2239
    if (aLangGroup)
2429
        AddLangGroup(pat, aLangGroup);
2240
        NS_AddLangGroup(pat, aLangGroup);
2430
2241
2431
    // get the font list
2242
    // get the font list
2432
    fs = FcFontList(0, pat, os);
2243
    fs = FcFontList(0, pat, os);
2433
2244
2434
    if (!fs)
2245
    if (!fs)
2435
        goto end;
2246
        goto end;
2436
2247
Lines 2530-2557 EnumFontsXft(nsIAtom* aLangGroup, const Link Here
2530
    if (fs)
2341
    if (fs)
2531
        FcFontSetDestroy(fs);
2342
        FcFontSetDestroy(fs);
2532
2343
2533
    return rv;
2344
    return rv;
2534
}
2345
}
2535
2346
2536
/* static */
2347
/* static */
2537
const MozXftLangGroup*
2538
FindFCLangGroup (nsACString &aLangGroup)
2539
{
2540
    for (unsigned int i=0; i < NUM_XFT_LANG_GROUPS; ++i) {
2541
        if (aLangGroup.Equals(MozXftLangGroups[i].mozLangGroup,
2542
                              nsCaseInsensitiveCStringComparator())) {
2543
            return &MozXftLangGroups[i];
2544
        }
2545
    }
2546
2547
    return nsnull;
2548
}
2549
2550
/* static */
2551
void
2348
void
2552
ConvertCharToUCS4(const char *aString, PRUint32 aLength, 
2349
ConvertCharToUCS4(const char *aString, PRUint32 aLength, 
2553
                  nsAutoFcChar32Buffer &aOutBuffer, PRUint32 *aOutLen)
2350
                  nsAutoFcChar32Buffer &aOutBuffer, PRUint32 *aOutLen)
2554
{
2351
{
2555
    *aOutLen = 0;
2352
    *aOutLen = 0;
2556
    FcChar32 *outBuffer;
2353
    FcChar32 *outBuffer;
2557
2354
(-)gfx/src/gtk/nsGfxFactoryGTK.cpp (-2 / +4 lines)
Lines 67-82 Link Here
67
#endif
67
#endif
68
#ifdef MOZ_ENABLE_COREXFONTS
68
#ifdef MOZ_ENABLE_COREXFONTS
69
#include "nsFontMetricsGTK.h"
69
#include "nsFontMetricsGTK.h"
70
#endif
70
#endif
71
#include "nsFontMetricsUtils.h"
71
#include "nsFontMetricsUtils.h"
72
#include "nsPrintSession.h"
72
#include "nsPrintSession.h"
73
#include "gfxImageFrame.h"
73
#include "gfxImageFrame.h"
74
#ifdef MOZ_ENABLE_FREETYPE2
74
#include "nsFT2FontCatalog.h"
75
#include "nsFT2FontCatalog.h"
75
#include "nsFreeType.h"
76
#include "nsFreeType.h"
77
#endif
76
78
77
// objects that just require generic constructors
79
// objects that just require generic constructors
78
80
79
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextGTK)
81
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextGTK)
80
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextGTK)
82
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextGTK)
81
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageGTK)
83
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageGTK)
82
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
84
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
Lines 88-103 NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenM Link Here
88
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsGTK)
90
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsGTK)
89
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorGTK)
91
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorGTK)
90
#ifdef NATIVE_THEME_SUPPORT
92
#ifdef NATIVE_THEME_SUPPORT
91
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeGTK)
93
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeGTK)
92
#endif
94
#endif
93
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
95
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
94
NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
96
NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
95
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFT2FontCatalog)
96
#ifdef MOZ_ENABLE_FREETYPE2
97
#ifdef MOZ_ENABLE_FREETYPE2
98
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFT2FontCatalog)
97
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsFreeType2, Init)
99
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsFreeType2, Init)
98
#endif
100
#endif
99
101
100
// our custom constructors
102
// our custom constructors
101
103
102
static nsresult
104
static nsresult
103
nsFontMetricsConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
105
nsFontMetricsConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
Lines 287-305 static const nsModuleComponentInfo compo Link Here
287
    GFX_IMAGEFRAME_CID,
289
    GFX_IMAGEFRAME_CID,
288
    "@mozilla.org/gfx/image/frame;2",
290
    "@mozilla.org/gfx/image/frame;2",
289
    gfxImageFrameConstructor, },
291
    gfxImageFrameConstructor, },
290
  { "Print Session",
292
  { "Print Session",
291
    NS_PRINTSESSION_CID,
293
    NS_PRINTSESSION_CID,
292
    "@mozilla.org/gfx/printsession;1",
294
    "@mozilla.org/gfx/printsession;1",
293
    nsPrintSessionConstructor },
295
    nsPrintSessionConstructor },
296
#ifdef MOZ_ENABLE_FREETYPE2
294
  { "TrueType Font Catalog Service",
297
  { "TrueType Font Catalog Service",
295
    NS_FONTCATALOGSERVICE_CID,
298
    NS_FONTCATALOGSERVICE_CID,
296
    "@mozilla.org/gfx/xfontcatalogservice;1",
299
    "@mozilla.org/gfx/xfontcatalogservice;1",
297
    nsFT2FontCatalogConstructor },
300
    nsFT2FontCatalogConstructor },
298
#ifdef MOZ_ENABLE_FREETYPE2
299
  { "FreeType2 routines",
301
  { "FreeType2 routines",
300
    NS_FREETYPE2_CID,
302
    NS_FREETYPE2_CID,
301
    NS_FREETYPE2_CONTRACTID,
303
    NS_FREETYPE2_CONTRACTID,
302
    nsFreeType2Constructor },
304
    nsFreeType2Constructor },
303
#endif
305
#endif
304
#ifdef NATIVE_THEME_SUPPORT
306
#ifdef NATIVE_THEME_SUPPORT
305
   { "Native Theme Renderer",
307
   { "Native Theme Renderer",
(-)gfx/src/ps/Makefile.in (-5 / +16 lines)
Lines 73-107 EXTRA_DSO_LDOPTS = \ Link Here
73
		-L$(DIST)/lib \
73
		-L$(DIST)/lib \
74
		-lgfxshared_s \
74
		-lgfxshared_s \
75
		$(EXTRA_DSO_LIBS) \
75
		$(EXTRA_DSO_LIBS) \
76
		$(MOZ_COMPONENT_LIBS) \
76
		$(MOZ_COMPONENT_LIBS) \
77
		$(MOZ_UNICHARUTIL_LIBS) \
77
		$(MOZ_UNICHARUTIL_LIBS) \
78
		$(NULL)
78
		$(NULL)
79
79
80
ifdef MOZ_ENABLE_FREETYPE2
80
ifdef MOZ_ENABLE_XFT
81
EXTRA_DSO_LDOPTS += \
82
		$(MOZ_XFT_LIBS) \
83
		$(NULL)
84
endif
85
86
ifneq (,$(MOZ_ENABLE_FREETYPE2)$(MOZ_ENABLE_XFT))
81
CPPSRCS		+= \
87
CPPSRCS		+= \
82
		nsCidMap.cpp \
88
		nsCidMap.cpp \
83
		nsType1.cpp \
89
		nsType1.cpp \
84
		nsType8.cpp \
90
		nsType8.cpp \
85
		$(NULL)
91
		$(NULL)
86
endif
92
endif
87
93
88
include $(topsrcdir)/config/rules.mk
94
include $(topsrcdir)/config/rules.mk
89
95
90
ifdef MOZ_ENABLE_FREETYPE2
91
INCLUDES        += $(FT2_CFLAGS)
92
endif
93
94
CFLAGS		+= $(TK_CFLAGS)
96
CFLAGS		+= $(TK_CFLAGS)
95
CXXFLAGS	+= $(TK_CFLAGS)
97
CXXFLAGS	+= $(TK_CFLAGS)
96
98
97
LOCAL_INCLUDES = \
99
LOCAL_INCLUDES = \
98
		-I../.. \
100
		-I../.. \
99
		-I$(srcdir)/.. \
101
		-I$(srcdir)/.. \
100
                 $(NULL)
102
                 $(NULL)
101
103
104
ifdef MOZ_ENABLE_XFT
105
INCLUDES		+= $(MOZ_XFT_CFLAGS)
106
LOCAL_INCLUDES	+= -I$(srcdir)/../shared
107
else
108
ifdef MOZ_ENABLE_FREETYPE2
109
INCLUDES	+= $(FT2_CFLAGS)
110
endif
111
endif
112
102
libs::
113
libs::
103
	$(INSTALL) $(EXPORT_RESOURCE) $(DIST)/bin/res
114
	$(INSTALL) $(EXPORT_RESOURCE) $(DIST)/bin/res
104
115
105
install::
116
install::
106
	$(SYSINSTALL) $(IFLAGS1) $(EXPORT_RESOURCE) $(DESTDIR)$(mozappdir)/res
117
	$(SYSINSTALL) $(IFLAGS1) $(EXPORT_RESOURCE) $(DESTDIR)$(mozappdir)/res
107
118
(-)gfx/src/ps/nsDeviceContextPS.cpp (-1 / +12 lines)
Lines 209-232 nsDeviceContextPS::InitDeviceContextPS(n Link Here
209
  mParentDeviceContext = aParentContext;
209
  mParentDeviceContext = aParentContext;
210
210
211
  mPSFontGeneratorList = new nsHashtable();
211
  mPSFontGeneratorList = new nsHashtable();
212
  NS_ENSURE_TRUE(mPSFontGeneratorList, NS_ERROR_OUT_OF_MEMORY);
212
  NS_ENSURE_TRUE(mPSFontGeneratorList, NS_ERROR_OUT_OF_MEMORY);
213
 
213
 
214
  nsresult rv;
214
  nsresult rv;
215
  nsCOMPtr<nsIPref> pref(do_GetService(NS_PREF_CONTRACTID, &rv));
215
  nsCOMPtr<nsIPref> pref(do_GetService(NS_PREF_CONTRACTID, &rv));
216
#ifdef MOZ_ENABLE_XFT
217
  if (NS_SUCCEEDED(rv)) {
218
      rv = pref->GetBoolPref("font.FreeType2.printing", &mFTPEnable);
219
      if (NS_FAILED(rv))
220
        mFTPEnable = PR_FALSE;
221
  }
222
#else 
223
  mFTPEnable = PR_FALSE;
224
#ifdef MOZ_ENABLE_FREETYPE2
216
  if (NS_SUCCEEDED(rv)) {
225
  if (NS_SUCCEEDED(rv)) {
217
    rv = pref->GetBoolPref("font.FreeType2.enable", &mFTPEnable);
226
    rv = pref->GetBoolPref("font.FreeType2.enable", &mFTPEnable);
218
    if (NS_FAILED(rv))
227
    if (NS_FAILED(rv))
219
      mFTPEnable = PR_FALSE;
228
      mFTPEnable = PR_FALSE;
220
    if (mFTPEnable) {
229
    if (mFTPEnable) {
221
      rv = pref->GetBoolPref("font.FreeType2.printing", &mFTPEnable);
230
      rv = pref->GetBoolPref("font.FreeType2.printing", &mFTPEnable);
222
      if (NS_FAILED(rv))
231
      if (NS_FAILED(rv))
223
        mFTPEnable = PR_FALSE;
232
        mFTPEnable = PR_FALSE;
224
    }
233
    }
225
  }
234
  }
235
#endif
236
#endif
226
  
237
  
227
  // the user's locale
238
  // the user's locale
228
  nsCOMPtr<nsILanguageAtomService> langService;
239
  nsCOMPtr<nsILanguageAtomService> langService;
229
  langService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
240
  langService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
230
  if (langService) {
241
  if (langService) {
231
    langService->GetLocaleLanguageGroup(&gUsersLocale);
242
    langService->GetLocaleLanguageGroup(&gUsersLocale);
232
  }
243
  }
Lines 431-445 GeneratePSFontCallback(nsHashKey *aKey, Link Here
431
 */
442
 */
432
NS_IMETHODIMP nsDeviceContextPS::EndDocument(void)
443
NS_IMETHODIMP nsDeviceContextPS::EndDocument(void)
433
{
444
{
434
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::EndDocument()\n"));
445
  PR_LOG(nsDeviceContextPSLM, PR_LOG_DEBUG, ("nsDeviceContextPS::EndDocument()\n"));
435
446
436
  NS_ENSURE_TRUE(mPSObj != nsnull, NS_ERROR_NULL_POINTER);
447
  NS_ENSURE_TRUE(mPSObj != nsnull, NS_ERROR_NULL_POINTER);
437
  
448
  
438
#ifdef MOZ_ENABLE_FREETYPE2
449
#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
439
  // Before output Type8 font, check whether printer support CID font
450
  // Before output Type8 font, check whether printer support CID font
440
  if (mFTPEnable && mPSFontGeneratorList)
451
  if (mFTPEnable && mPSFontGeneratorList)
441
    if (mPSFontGeneratorList->Count() > 0)
452
    if (mPSFontGeneratorList->Count() > 0)
442
      mPSObj->add_cid_check();
453
      mPSObj->add_cid_check();
443
#endif
454
#endif
444
 
455
 
445
  /* Core of TrueType printing:
456
  /* Core of TrueType printing:
(-)gfx/src/ps/nsFontMetricsPS.cpp (-92 / +952 lines)
Lines 17-30 Link Here
17
 * The Initial Developer of the Original Code is 
17
 * The Initial Developer of the Original Code is 
18
 * Netscape Communications Corporation.
18
 * Netscape Communications Corporation.
19
 * Portions created by the Initial Developer are Copyright (C) 1998
19
 * Portions created by the Initial Developer are Copyright (C) 1998
20
 * the Initial Developer. All Rights Reserved.
20
 * the Initial Developer. All Rights Reserved.
21
 *
21
 *
22
 * Contributor(s):
22
 * Contributor(s):
23
 *   Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
23
 *   Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
24
 *   Ervin Yan <Ervin.Yan@sun.com>
25
 *   Christopher Blizzard <blizzard@mozilla.org>
26
 *   Jungshik Shin <jshin@i18nl10n.com>
24
 *
27
 *
25
 *
28
 *
26
 * Alternatively, the contents of this file may be used under the terms of
29
 * Alternatively, the contents of this file may be used under the terms of
27
 * either the GNU General Public License Version 2 or later (the "GPL"), or
30
 * either the GNU General Public License Version 2 or later (the "GPL"), or
28
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
 * in which case the provisions of the GPL or the LGPL are applicable instead
32
 * in which case the provisions of the GPL or the LGPL are applicable instead
30
 * of those above. If you wish to allow use of your version of this file only
33
 * of those above. If you wish to allow use of your version of this file only
Lines 43-72 Link Here
43
#include "nsRenderingContextPS.h"
46
#include "nsRenderingContextPS.h"
44
#include "nsIServiceManager.h"
47
#include "nsIServiceManager.h"
45
#include "nsGfxCIID.h"
48
#include "nsGfxCIID.h"
46
49
47
#include "nsIPref.h"
50
#include "nsIPref.h"
48
#include "nsVoidArray.h"
51
#include "nsVoidArray.h"
49
#include "nsReadableUtils.h"
52
#include "nsReadableUtils.h"
50
#ifdef MOZ_ENABLE_FREETYPE2
53
#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
51
#include "nsType8.h"
54
#include "nsType8.h"
52
#endif
55
#endif
53
#include "prlog.h"
56
#include "prlog.h"
54
57
55
#include "nsArray.h"
58
#include "nsArray.h"
56
59
57
extern nsIAtom *gUsersLocale;
60
extern nsIAtom *gUsersLocale;
58
#define NS_IS_BOLD(weight) ((weight) > 400 ? 1 : 0)
61
#define NS_IS_BOLD(weight) ((weight) > 400 ? 1 : 0)
59
62
63
#ifdef MOZ_ENABLE_XFT
64
65
#include "nsFontConfigUtils.h"
66
67
static nsFontPS* CreateFontPS(nsXftEntry*, const nsFont&,
68
                              nsFontMetricsPS*);
69
70
#else
60
#ifdef MOZ_ENABLE_FREETYPE2
71
#ifdef MOZ_ENABLE_FREETYPE2
61
static nsFontPS* CreateFontPS(nsITrueTypeFontCatalogEntry*, const nsFont&,
72
static nsFontPS* CreateFontPS(nsITrueTypeFontCatalogEntry*, const nsFont&,
62
                              nsFontMetricsPS*);
73
                              nsFontMetricsPS*);
63
74
64
static NS_DEFINE_CID(kFCSCID, NS_FONTCATALOGSERVICE_CID);
75
static NS_DEFINE_CID(kFCSCID, NS_FONTCATALOGSERVICE_CID);
65
#endif
76
#endif
77
#endif
66
78
67
#ifdef PR_LOGGING
79
#ifdef PR_LOGGING
68
static PRLogModuleInfo *gFontMetricsPSM = PR_NewLogModule("FontMetricsPS");
80
static PRLogModuleInfo *gFontMetricsPSM = PR_NewLogModule("FontMetricsPS");
69
#endif
81
#endif
70
82
71
/** ---------------------------------------------------
83
/** ---------------------------------------------------
72
 *  See documentation in nsFontMetricsPS.h
84
 *  See documentation in nsFontMetricsPS.h
Lines 89-107 nsFontMetricsPS :: ~nsFontMetricsPS() Link Here
89
  
101
  
90
  if (mFontsPS) {
102
  if (mFontsPS) {
91
    int i;
103
    int i;
92
    for (i=0; i<mFontsPS->Count(); i++) {
104
    for (i=0; i<mFontsPS->Count(); i++) {
93
      fontps *fontPS = (fontps *)mFontsPS->ElementAt(i);
105
      fontps *fontPS = (fontps *)mFontsPS->ElementAt(i);
94
      if (!fontPS)
106
      if (!fontPS)
95
        continue;
107
        continue;
96
      NS_IF_RELEASE(fontPS->entry);
97
      if (fontPS->fontps)
108
      if (fontPS->fontps)
98
        delete fontPS->fontps;
109
        delete fontPS->fontps;
110
#ifdef MOZ_ENABLE_XFT
111
      if (fontPS->entry)
112
        delete fontPS->entry;
113
      if (fontPS->charset)
114
        FcCharSetDestroy(fontPS->charset);
115
#else
116
#ifdef MOZ_ENABLE_FREETYPE2
117
      NS_IF_RELEASE(fontPS->entry);
99
      if (fontPS->ccmap)
118
      if (fontPS->ccmap)
100
        FreeCCMap(fontPS->ccmap);
119
        FreeCCMap(fontPS->ccmap);
120
#endif
121
#endif
101
      delete fontPS;
122
      delete fontPS;
102
    }
123
    }
103
    delete mFontsPS;
124
    delete mFontsPS;
104
  }
125
  }
105
126
106
  if (mFontsAlreadyLoaded) {
127
  if (mFontsAlreadyLoaded) {
107
    delete mFontsAlreadyLoaded;
128
    delete mFontsAlreadyLoaded;
Lines 123-136 NS_IMPL_ISUPPORTS1(nsFontMetricsPS, nsIF Link Here
123
NS_IMETHODIMP
144
NS_IMETHODIMP
124
nsFontMetricsPS :: Init(const nsFont& aFont, nsIAtom* aLangGroup,
145
nsFontMetricsPS :: Init(const nsFont& aFont, nsIAtom* aLangGroup,
125
  nsIDeviceContext *aContext)
146
  nsIDeviceContext *aContext)
126
{
147
{
127
  mLangGroup = aLangGroup;
148
  mLangGroup = aLangGroup;
128
149
129
  mFont = new nsFont(aFont);
150
  mFont = new nsFont(aFont);
151
130
  //don't addref this to avoid circular refs
152
  //don't addref this to avoid circular refs
131
  mDeviceContext = (nsDeviceContextPS *)aContext;
153
  mDeviceContext = (nsDeviceContextPS *)aContext;
132
154
133
  mFontsPS = new nsVoidArray();
155
  mFontsPS = new nsVoidArray();
134
  NS_ENSURE_TRUE(mFontsPS, NS_ERROR_OUT_OF_MEMORY);
156
  NS_ENSURE_TRUE(mFontsPS, NS_ERROR_OUT_OF_MEMORY);
135
  mFontsAlreadyLoaded = new nsHashtable();
157
  mFontsAlreadyLoaded = new nsHashtable();
136
  NS_ENSURE_TRUE(mFontsAlreadyLoaded, NS_ERROR_OUT_OF_MEMORY);
158
  NS_ENSURE_TRUE(mFontsAlreadyLoaded, NS_ERROR_OUT_OF_MEMORY);
Lines 158-172 nsFontMetricsPS :: Destroy() Link Here
158
void
180
void
159
nsFontMetricsPS::RealizeFont()
181
nsFontMetricsPS::RealizeFont()
160
{
182
{
161
  if (mFont && mDeviceContext) {
183
  if (mFont && mDeviceContext) {
162
    float dev2app;
184
    float dev2app;
163
    dev2app = mDeviceContext->DevUnitsToAppUnits();
185
    dev2app = mDeviceContext->DevUnitsToAppUnits();
164
    fontps *font = (fontps*)mFontsPS->ElementAt(0);
186
    fontps *font = (fontps*)mFontsPS->ElementAt(0);
165
#ifdef MOZ_ENABLE_FREETYPE2
187
#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
166
    NS_ASSERTION(font && font->entry, "no font available");
188
    NS_ASSERTION(font && font->entry, "no font available");
167
    if (font && !font->fontps && font->entry)
189
    if (font && !font->fontps && font->entry)
168
      font->fontps = CreateFontPS(font->entry, *mFont, this);
190
      font->fontps = CreateFontPS(font->entry, *mFont, this);
169
#endif
191
#endif
170
    NS_ASSERTION(font && font->fontps, "no font available");
192
    NS_ASSERTION(font && font->fontps, "no font available");
171
    if (font && font->fontps)
193
    if (font && font->fontps)
172
      font->fontps->RealizeFont(this, dev2app);
194
      font->fontps->RealizeFont(this, dev2app);
Lines 464-482 nsFontPS::FindFont(char aChar, const nsF Link Here
464
// nsFontPS
486
// nsFontPS
465
nsFontPS*
487
nsFontPS*
466
nsFontPS::FindFont(PRUnichar aChar, const nsFont& aFont, 
488
nsFontPS::FindFont(PRUnichar aChar, const nsFont& aFont, 
467
                   nsFontMetricsPS* aFontMetrics)
489
                   nsFontMetricsPS* aFontMetrics)
468
{
490
{
469
  nsFontPS* fontPS;
491
  nsFontPS* fontPS;
470
492
471
#ifdef MOZ_ENABLE_FREETYPE2
493
#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
472
  nsDeviceContextPS* dc = aFontMetrics->GetDeviceContext();
494
  nsDeviceContextPS* dc = aFontMetrics->GetDeviceContext();
473
  NS_ENSURE_TRUE(dc, nsnull);
495
  NS_ENSURE_TRUE(dc, nsnull);
474
  if (dc->mFTPEnable) {
496
  if (dc->mFTPEnable) {
497
#ifdef MOZ_ENABLE_XFT
498
    fontPS = nsFontPSXft::FindFont(aChar, aFont, aFontMetrics);
499
#else
475
    fontPS = nsFontPSFreeType::FindFont(aChar, aFont, aFontMetrics);
500
    fontPS = nsFontPSFreeType::FindFont(aChar, aFont, aFontMetrics);
501
#endif
476
    if (fontPS)
502
    if (fontPS)
477
      return fontPS;
503
      return fontPS;
478
  }
504
  }
479
#endif
505
#endif
480
506
481
  /* Find in afm font */
507
  /* Find in afm font */
482
  if (aFontMetrics->GetFontsPS()->Count() > 0) {
508
  if (aFontMetrics->GetFontsPS()->Count() > 0) {
Lines 484-500 nsFontPS::FindFont(PRUnichar aChar, cons Link Here
484
    NS_ENSURE_TRUE(fps, nsnull);
510
    NS_ENSURE_TRUE(fps, nsnull);
485
    fontPS = fps->fontps;
511
    fontPS = fps->fontps;
486
  }
512
  }
487
  else {
513
  else {
488
    fontPS = nsFontPSAFM::FindFont(aFont, aFontMetrics);
514
    fontPS = nsFontPSAFM::FindFont(aFont, aFontMetrics);
489
    fontps *fps = new fontps;
515
    fontps *fps = new fontps;
490
    NS_ENSURE_TRUE(fps, nsnull);
516
    NS_ENSURE_TRUE(fps, nsnull);
491
    fps->entry  = nsnull;
492
    fps->fontps = fontPS;
517
    fps->fontps = fontPS;
518
#if defined(MOZ_ENABLE_XFT) || defined(MOZ_ENABLE_FREETYPE2) 
519
    fps->entry  = nsnull;
520
#ifdef MOZ_ENABLE_XFT
521
    fps->charset = nsnull;
522
#else
493
    fps->ccmap  = nsnull;
523
    fps->ccmap  = nsnull;
524
#endif
525
#endif
494
    aFontMetrics->GetFontsPS()->AppendElement(fps);
526
    aFontMetrics->GetFontsPS()->AppendElement(fps);
495
  }
527
  }
496
  return fontPS;
528
  return fontPS;
497
}
529
}
498
530
499
nsFontPS::nsFontPS(const nsFont& aFont, nsFontMetricsPS* aFontMetrics)
531
nsFontPS::nsFontPS(const nsFont& aFont, nsFontMetricsPS* aFontMetrics)
500
{
532
{
Lines 544-705 nsFontPSAFM::FindFont(const nsFont& aFon Link Here
544
}
576
}
545
577
546
nsFontPSAFM::nsFontPSAFM(const nsFont& aFont, nsAFMObject* aAFMInfo,
578
nsFontPSAFM::nsFontPSAFM(const nsFont& aFont, nsAFMObject* aAFMInfo,
547
                         PRInt16 fontIndex, nsFontMetricsPS* aFontMetrics) :
579
                         PRInt16 fontIndex, nsFontMetricsPS* aFontMetrics) :
548
nsFontPS(aFont, aFontMetrics), mAFMInfo(aAFMInfo), mFontIndex(fontIndex)
580
nsFontPS(aFont, aFontMetrics), mAFMInfo(aAFMInfo), mFontIndex(fontIndex)
549
{
581
{
550
  if (!(mFont && mAFMInfo)) return;
582
  if (!(mFont && mAFMInfo)) return;
551
  mFamilyName.AssignWithConversion((char*)mAFMInfo->mPSFontInfo->mFamilyName);
583
  AppendASCIItoUTF16(mAFMInfo->mPSFontInfo->mFamilyName, mFamilyName);
552
}
584
}
553
585
554
nsFontPSAFM::~nsFontPSAFM()
586
nsFontPSAFM::~nsFontPSAFM()
555
{
587
{
556
  if (mAFMInfo) {
588
  if (mAFMInfo) {
557
    delete mAFMInfo;
589
    delete mAFMInfo;
558
    mAFMInfo = nsnull;
590
    mAFMInfo = nsnull;
559
  }
591
  }
560
}
592
}
561
593
562
nscoord
594
nscoord
563
nsFontPSAFM::GetWidth(const char* aString, PRUint32 aLength)
595
nsFontPSAFM::GetWidth(const char* aString, PRUint32 aLength)
564
{
596
{
565
  nscoord width = 0;
597
  nscoord width = 0;
566
  if (mAFMInfo) {
598
  if (mAFMInfo) {
567
    mAFMInfo->GetStringWidth(aString, width, aLength);
599
    mAFMInfo->GetStringWidth(aString, width, aLength);
568
  }
600
  }
569
  return width;
601
  return width;
602
}
603
604
nscoord
605
nsFontPSAFM::GetWidth(const PRUnichar* aString, PRUint32 aLength)
606
{
607
  nscoord width = 0;
608
  if (mAFMInfo) {
609
    mAFMInfo->GetStringWidth(aString, width, aLength);
610
  }
611
  return width;
612
}
613
614
nscoord
615
nsFontPSAFM::DrawString(nsRenderingContextPS* aContext,
616
                        nscoord aX, nscoord aY,
617
                        const char* aString, PRUint32 aLength)
618
{
619
  NS_ENSURE_TRUE(aContext, 0);
620
  nsPostScriptObj* psObj = aContext->GetPostScriptObj();
621
  NS_ENSURE_TRUE(psObj, 0);
622
623
  psObj->moveto(aX, aY);
624
  psObj->show(aString, aLength, "");
625
  return GetWidth(aString, aLength);
626
}
627
628
nscoord
629
nsFontPSAFM::DrawString(nsRenderingContextPS* aContext,
630
                        nscoord aX, nscoord aY,
631
                        const PRUnichar* aString, PRUint32 aLength)
632
{
633
  NS_ENSURE_TRUE(aContext, 0);
634
  nsPostScriptObj* psObj = aContext->GetPostScriptObj();
635
  NS_ENSURE_TRUE(psObj, 0);
636
637
  psObj->moveto(aX, aY);
638
  psObj->show(aString, aLength, "", 0);
639
  return GetWidth(aString, aLength);
640
}
641
642
nsresult
643
nsFontPSAFM::RealizeFont(nsFontMetricsPS* aFontMetrics, float dev2app)
644
{
645
  NS_ENSURE_ARG_POINTER(aFontMetrics);
646
647
  float fontSize;
648
  float offset;
649
650
  nscoord onePixel = NSToCoordRound(1 * dev2app);
651
652
  // convert the font size which is in twips to points
653
  fontSize = mFont->size / TWIPS_PER_POINT_FLOAT;
654
655
  offset = NSFloatPointsToTwips(fontSize * mAFMInfo->mPSFontInfo->mXHeight) / 1000.0f;
656
  nscoord xHeight = NSToCoordRound(offset);
657
  aFontMetrics->SetXHeight(xHeight);
658
  aFontMetrics->SetSuperscriptOffset(xHeight);
659
  aFontMetrics->SetSubscriptOffset(xHeight);
660
  aFontMetrics->SetStrikeout((nscoord)(xHeight / 2), onePixel);
661
662
  offset = NSFloatPointsToTwips(fontSize * mAFMInfo->mPSFontInfo->mUnderlinePosition) / 1000.0f;
663
  aFontMetrics->SetUnderline(NSToCoordRound(offset), onePixel);
664
665
  nscoord size = NSToCoordRound(fontSize * dev2app);
666
  aFontMetrics->SetHeight(size);
667
  aFontMetrics->SetEmHeight(size);
668
  aFontMetrics->SetMaxAdvance(size);
669
  aFontMetrics->SetMaxHeight(size);
670
671
  offset = NSFloatPointsToTwips(fontSize * mAFMInfo->mPSFontInfo->mAscender) / 1000.0f;
672
  nscoord ascent = NSToCoordRound(offset);
673
  aFontMetrics->SetAscent(ascent);
674
  aFontMetrics->SetEmAscent(ascent);
675
  aFontMetrics->SetMaxAscent(ascent);
676
677
  offset = NSFloatPointsToTwips(fontSize * mAFMInfo->mPSFontInfo->mDescender) / 1000.0f;
678
  nscoord descent = -(NSToCoordRound(offset));
679
  aFontMetrics->SetDescent(descent);
680
  aFontMetrics->SetEmDescent(descent);
681
  aFontMetrics->SetMaxDescent(descent);
682
683
  aFontMetrics->SetLeading(0);
684
685
  nscoord spaceWidth = GetWidth(" ", 1);
686
  aFontMetrics->SetSpaceWidth(spaceWidth);
687
688
  nscoord aveCharWidth = GetWidth("x", 1);
689
  aFontMetrics->SetAveCharWidth(aveCharWidth);
690
691
  return NS_OK;
692
}
693
694
nsresult
695
nsFontPSAFM::SetupFont(nsRenderingContextPS* aContext)
696
{
697
  NS_ENSURE_TRUE(aContext && mFontMetrics, 0);
698
  nsPostScriptObj* psObj = aContext->GetPostScriptObj();
699
  NS_ENSURE_TRUE(psObj, 0);
700
701
  nscoord fontHeight = 0;
702
  mFontMetrics->GetHeight(fontHeight);
703
704
  psObj->setscriptfont(mFontIndex, mFamilyName,
705
                       fontHeight, mFont->style, mFont->variant,
706
                       mFont->weight, mFont->decorations);
707
  return NS_OK;
708
}
709
710
#ifdef MOZ_MATHML
711
nsresult
712
nsFontPSAFM::GetBoundingMetrics(const char*        aString,
713
                                PRUint32           aLength,
714
                                nsBoundingMetrics& aBoundingMetrics)
715
{
716
  return NS_ERROR_NOT_IMPLEMENTED;
717
}
718
719
nsresult
720
nsFontPSAFM::GetBoundingMetrics(const PRUnichar*   aString,
721
                                PRUint32           aLength,
722
                                nsBoundingMetrics& aBoundingMetrics)
723
{
724
  return NS_ERROR_NOT_IMPLEMENTED;
725
}
726
#endif
727
728
#if defined(MOZ_ENABLE_FREETYPE2) || defined(MOZ_ENABLE_XFT)
729
730
#define WIDEN_8_TO_16_BUF_SIZE 1024
731
732
#ifdef MOZ_ENABLE_XFT
733
734
nsXftEntry::nsXftEntry(FcPattern *aFontPattern)
735
{
736
  mFace = nsnull;
737
  mFaceIndex = 0;
738
739
  char *fcResult;
740
741
  if (FcPatternGetString(aFontPattern, FC_FILE, 0, (FcChar8 **) &fcResult)
742
      == FcResultMatch)     
743
    mFontFileName = fcResult;
744
745
  if (FcPatternGetString(aFontPattern, FC_FAMILY, 0, (FcChar8 **) &fcResult)
746
      == FcResultMatch)     
747
    mFamilyName = fcResult;
748
749
  if (FcPatternGetString(aFontPattern, FC_STYLE, 0, (FcChar8 **) &fcResult)
750
      == FcResultMatch)
751
    mStyleName = fcResult;
752
}
753
754
755
static nsFontPS*
756
CreateFontPS(nsXftEntry *aEntry, const nsFont& aFont,
757
             nsFontMetricsPS* aFontMetrics)
758
{
759
  nsresult rv;
760
  nsDeviceContextPS* dc = aFontMetrics->GetDeviceContext();
761
  NS_ENSURE_TRUE(dc, nsnull);
762
763
  nsCAutoString fileName(aEntry->mFontFileName);
764
  nsCAutoString familyName(aEntry->mFamilyName);
765
  nsCAutoString styleName(aEntry->mStyleName);
766
  ToLowerCase(familyName);
767
  ToLowerCase(styleName);
768
  
769
  nsCAutoString fontName;
770
  fontName.Append(familyName);
771
  fontName.Append("-");
772
  fontName.Append(styleName);
773
  nsCStringKey key(fontName);
774
775
  nsHashtable *psFGList = dc->GetPSFontGeneratorList();
776
  NS_ENSURE_TRUE(psFGList, nsnull);
777
  
778
  nsPSFontGenerator* psFontGen = (nsPSFontGenerator*) psFGList->Get(&key);
779
  if (!psFontGen) {
780
    psFontGen = new nsXftType8Generator;
781
    NS_ENSURE_TRUE(psFontGen, nsnull);
782
    rv = ((nsXftType8Generator*)psFontGen)->Init(aEntry);
783
    if (NS_FAILED(rv)) {
784
      delete psFontGen;
785
      return nsnull;
786
    }
787
    psFGList->Put(&key, (void *) psFontGen);
788
  }
789
  nsFontPSXft* font = new nsFontPSXft(aFont, aFontMetrics);
790
  NS_ENSURE_TRUE(font, nsnull);
791
  rv = font->Init(aEntry, psFontGen);
792
  if (NS_FAILED(rv)) {
793
    delete font;
794
    return nsnull;
795
  }
796
  return font;
797
}
798
799
/* static */
800
PRBool
801
nsFontPSXft::CSSFontEnumCallback(const nsString& aFamily, PRBool aIsGeneric,
802
                                      void* aFpi)
803
{
804
    fontPSInfo *fpi = (fontPSInfo *)aFpi;
805
806
    // make sure it's an ascii name, if not then return and continue
807
    // enumerating
808
    if (!NS_IsASCIIFontName(aFamily))
809
        return PR_TRUE;
810
811
    NS_LossyConvertUTF16toASCII name(aFamily);
812
    ToLowerCase(name);
813
    fpi->mFontList.AppendCString(name);
814
    fpi->mFontIsGeneric.AppendElement((void *)aIsGeneric);
815
    if (aIsGeneric) {
816
        fpi->mGenericFont =
817
            fpi->mFontList.CStringAt(fpi->mFontList.Count() - 1);
818
        return PR_FALSE; // stop processing
819
    }
820
821
    return PR_TRUE; // keep processing
822
}
823
824
nsFontPS*
825
nsFontPSXft::FindFont(PRUnichar aChar, const nsFont& aFont, 
826
                           nsFontMetricsPS* aFontMetrics)
827
{
828
  PRBool inited = PR_FALSE;
829
  nsCOMPtr<nsIAtom> langGroup;
830
  fontPSInfo fpi;
831
  fpi.fontps = aFontMetrics->GetFontsPS();
832
  int i = 0;
833
834
  while (1) {
835
    //
836
    // see if it is already in the list of fonts
837
    //
838
    for (; i<fpi.fontps->Count(); i++) {
839
      fontps *fi = (fontps *)fpi.fontps->ElementAt(i);
840
      if (!fi->entry || !fi->charset) {
841
        NS_ASSERTION(fi->entry, "invalid entry");
842
        NS_ASSERTION(fi->charset, "invalid charset");
843
        continue;
844
      }
845
      if (FcCharSetHasChar(fi->charset, aChar)) {
846
        if (!fi->fontps) {
847
#ifdef PR_LOGGING
848
          if (PR_LOG_TEST(gFontMetricsPSM, PR_LOG_DEBUG)) {
849
            PR_LogPrint("CreateFontPS %s/%s\n",
850
                fi->entry->mFamilyName.get(), fi->entry->mStyleName.get());
851
          }
852
#endif
853
          fi->fontps = CreateFontPS(fi->entry, aFont, aFontMetrics);
854
        }
855
        if (fi->fontps)
856
          return fi->fontps;
857
      }
858
    }
859
860
    // if already get all matched fonts and not found suitable
861
    // then return nsnull
862
    if (fpi.fontps->Count() > 0)
863
      return nsnull;
864
865
    //
866
    // it is not already in the list of fonts
867
    // so add more fonts to the list
868
    //
869
    if (inited)
870
      return nsnull;
871
 
872
    inited = PR_TRUE;
873
874
    fpi.nsfont = &aFont;
875
    fpi.alreadyLoaded = aFontMetrics->GetFontsAlreadyLoadedList();
876
    fpi.mGenericFont = nsnull;
877
878
    aFontMetrics->GetLangGroup(getter_AddRefs(langGroup));
879
    if (!langGroup)
880
      langGroup = NS_NewAtom("x-western");
881
882
    // enumerate over the font names passed in
883
    aFont.EnumerateFamilies(nsFontPSXft::CSSFontEnumCallback, &fpi);
884
885
    nsCOMPtr<nsIPref> prefService;
886
    prefService = do_GetService(NS_PREF_CONTRACTID);
887
    if (!prefService)
888
      return nsnull;
889
890
    nsXPIDLCString value;
891
    nsCAutoString  aDefaultFont;
892
893
    // Set up the default font name if it's not set
894
    if (!fpi.mGenericFont) {
895
      prefService->CopyCharPref("font.default", getter_Copies(value));
896
897
      if (value.get())
898
        aDefaultFont = value.get();
899
      else
900
        aDefaultFont = "serif";
901
902
      fpi.mGenericFont = &aDefaultFont;
903
    }
904
905
    // If pattern is null, set up the base bits of it so we can
906
    // match.  If we need to match later we don't have to set it up
907
    // again.
908
    FcPattern *pattern = nsnull;
909
910
    pattern = FcPatternCreate();
911
    if (!pattern)
912
      return nsnull;
913
914
    // XXX need to add user defined family
915
916
    // Add CSS names - walk the list of fonts, adding the generic as
917
    // the last font
918
    for (int i=0; i < fpi.mFontList.Count(); ++i) {
919
      // if this was a generic name, break out of the loop since we
920
      // don't want to add it to the pattern yet
921
      if (fpi.mFontIsGeneric[i])
922
        break;;
923
924
      nsCString *familyName = fpi.mFontList.CStringAt(i);
925
      NS_AddFFRE(pattern, familyName, PR_FALSE);
926
    }
927
928
    // Add the language group.  Note that we do this before adding any
929
    // generics.  That's because the language is more important than
930
    // any generic font.
931
    NS_AddLangGroup(pattern, langGroup);
932
933
    // If there's a generic add a pref for the generic if there's one
934
    // set.
935
    if (fpi.mGenericFont && !aFont.systemFont) {
936
      nsCAutoString name("font.name.");
937
      name += fpi.mGenericFont->get();
938
      name += ".";
939
940
      nsAutoString langGroupStr;
941
      langGroup->ToString(langGroupStr);
942
943
      LossyAppendUTF16toASCII(langGroupStr, name);
944
945
      nsCOMPtr<nsIPref> pref;
946
      pref = do_GetService(NS_PREF_CONTRACTID);
947
      if (pref) {
948
        nsresult rv;
949
        nsXPIDLCString value;
950
        rv = pref->GetCharPref(name.get(), getter_Copies(value));
951
952
        // we ignore prefs that have three hypens since they are X
953
        // style prefs.
954
        if (NS_FFRECountHyphens(value) < 3) {
955
          nsCAutoString tmpstr(value);
956
957
          if (PR_LOG_TEST(gFontMetricsPSM, PR_LOG_DEBUG)) {
958
              printf("\tadding generic font from preferences: %s\n",
959
                     tmpstr.get());
960
          }
961
962
          NS_AddFFRE(pattern, &tmpstr, PR_FALSE);
963
        }
964
      }
965
    }
966
967
    // Add the generic if there is one.
968
    if (fpi.mGenericFont && !aFont.systemFont)
969
      NS_AddFFRE(pattern, fpi.mGenericFont, PR_FALSE);
970
971
    // Add the slant type
972
    FcPatternAddInteger(pattern, FC_SLANT, NS_CalculateSlant(aFont.style));
973
974
    // Add the weight
975
    FcPatternAddInteger(pattern, FC_WEIGHT, NS_CalculateWeight(aFont.weight));
976
977
    // Set up the default substitutions for this font
978
    FcConfigSubstitute(0, pattern, FcMatchPattern);
979
    FcDefaultSubstitute(pattern);
980
981
    FcResult   result;
982
    FcFontSet *set = FcFontSort(0, pattern, FcTrue, 0, &result);
983
    if (!set) {
984
       return nsnull;
985
    }
986
987
    // Create a list of new font objects based on the fonts returned
988
    // as part of the query
989
    for (int i=0; i < set->nfont; ++i) {
990
        FcBool fc_outline;
991
        FcChar8 *fc_family;
992
        FcChar8 *fc_style;
993
        FcCharSet *fc_charset;
994
995
        // skip if the fonts is not outline font files.
996
        result = FcPatternGetBool (set->fonts[i], FC_OUTLINE, 0, &fc_outline);
997
        if (!fc_outline)
998
          continue;
999
1000
        result = FcPatternGetString (set->fonts[i], FC_FAMILY, 0, &fc_family);
1001
        if (result != FcResultMatch || fc_family == nsnull)
1002
          continue;
1003
1004
        result = FcPatternGetString (set->fonts[i], FC_STYLE, 0, &fc_style);
1005
        if (result != FcResultMatch || fc_style == nsnull)
1006
          continue;
1007
1008
        result = FcPatternGetCharSet(set->fonts[i], FC_CHARSET, 0, &fc_charset);
1009
        if (result != FcResultMatch || fc_charset == nsnull)
1010
          continue;
1011
1012
        nsXftEntry *xftEntry = new nsXftEntry(set->fonts[i]);
1013
        if (!xftEntry)
1014
          continue;
1015
1016
        fontps *fps = new fontps;
1017
        fps->entry = xftEntry;
1018
        fps->charset = fc_charset;
1019
        fps->fontps = nsnull;
1020
        fpi.fontps->AppendElement(fps);
1021
    }
1022
1023
    // we're done with the set now
1024
    FcFontSetDestroy(set);
1025
1026
    FcPatternDestroy(pattern);
1027
  }
1028
1029
  return nsnull;
1030
}
1031
1032
/*FT_CALLBACK_DEF*/
1033
FT_Error
1034
nsXftFaceRequester(FTC_FaceID face_id, FT_Library lib,
1035
                  FT_Pointer request_data, FT_Face* aFace)
1036
{
1037
  nsXftEntry *faceID = (nsXftEntry *)face_id;
1038
1039
  FT_Error fterror = FT_New_Face(lib, faceID->mFontFileName.get(),
1040
                                 faceID->mFaceIndex, aFace);
1041
  if (fterror) 
1042
    *aFace = nsnull;
1043
  return 0;
1044
}
1045
1046
nsFontPSXft::nsFontPSXft(const nsFont& aFont,
1047
                                   nsFontMetricsPS* aFontMetrics)
1048
  :nsFontPS(aFont, aFontMetrics)
1049
{
1050
}
1051
1052
nsresult
1053
nsFontPSXft::Init(nsXftEntry* aEntry,
1054
                       nsPSFontGenerator* aPSFontGen)
1055
{
1056
  NS_ENSURE_TRUE(aEntry && aPSFontGen, NS_ERROR_FAILURE);
1057
  mEntry = aEntry;
1058
  mPSFontGenerator = aPSFontGen;
1059
1060
  float app2dev;
1061
  nsIDeviceContext* dc = mFontMetrics->GetDeviceContext();
1062
  NS_ENSURE_TRUE(dc, NS_ERROR_NULL_POINTER);
1063
  app2dev = dc->AppUnitsToDevUnits();
1064
  
1065
  mPixelSize = NSToIntRound(app2dev * mFont->size);
1066
1067
  mImageDesc.font.face_id    = (void*)mEntry;
1068
  mImageDesc.font.pix_width  = mPixelSize;
1069
  mImageDesc.font.pix_height = mPixelSize;
1070
  mImageDesc.image_type = 0;
1071
1072
  FT_Error fterror; 
1073
  fterror = FT_Init_FreeType(&mFreeTypeLibrary);
1074
  if (fterror) {
1075
    NS_ASSERTION(!fterror, "failed to initialize FreeType library");
1076
    mFreeTypeLibrary = nsnull;
1077
    return NS_ERROR_FAILURE;
1078
  }
1079
  fterror = FTC_Manager_New(mFreeTypeLibrary, 0, 0, 0, nsXftFaceRequester,
1080
                  NULL, &mFTCacheManager);
1081
  NS_ASSERTION(!fterror, "failed to create FreeType Cache manager");
1082
  if (fterror)
1083
    return NS_ERROR_FAILURE;
1084
1085
  fterror = FTC_Image_Cache_New(mFTCacheManager, &mImageCache);
1086
  NS_ASSERTION(!fterror, "failed to create FreeType image cache");
1087
  if (fterror)
1088
    return NS_ERROR_FAILURE;
1089
1090
  return NS_OK;
1091
}
1092
1093
nsFontPSXft::~nsFontPSXft()
1094
{
1095
  FTC_Manager_Done(mFTCacheManager);
1096
1097
  if (FT_Done_FreeType(mFreeTypeLibrary))
1098
    return;
1099
1100
  mEntry = nsnull;
1101
}
1102
1103
FT_Face
1104
nsFontPSXft::getFTFace()
1105
{
1106
  FT_Error error;
1107
  FT_Face face = mEntry->mFace;
1108
1109
  if (face)
1110
    return (face);
1111
1112
  error = FTC_Manager_Lookup_Size(mFTCacheManager, &mImageDesc.font,
1113
                                  &face, nsnull);
1114
  NS_ASSERTION(error == 0, "failed to get face/size");
1115
  if (error)
1116
    return nsnull;
1117
1118
  mEntry->mFace = face;
1119
  return face;
1120
}
1121
1122
nscoord
1123
nsFontPSXft::GetWidth(const char* aString, PRUint32 aLength)
1124
{
1125
  PRUnichar unichars[WIDEN_8_TO_16_BUF_SIZE];
1126
  PRUint32 len, width = 0;
1127
  while ( aLength > 0 ) {
1128
    len = PR_MIN(aLength, WIDEN_8_TO_16_BUF_SIZE);
1129
    for (PRUint32 i=0; i < len; i++) {
1130
      unichars[i] = PRUnichar(PRUint8(aString[i]));
1131
    }
1132
    width += GetWidth(unichars, len);
1133
    aString += len;
1134
    aLength -= len;
1135
  }
1136
  return width;
1137
}
1138
1139
1140
nscoord
1141
nsFontPSXft::GetWidth(const PRUnichar* aString, PRUint32 aLength)
1142
{
1143
  FT_UInt glyph_index;
1144
  FT_Glyph glyph;
1145
  double origin_x = 0;
1146
1147
  // get the face/size from the FreeType cache
1148
  FT_Face face = getFTFace();
1149
  NS_ASSERTION(face, "failed to get face/size");
1150
  if (!face)
1151
    return 0;
1152
1153
  for (PRUint32 i=0; i<aLength; i++) {
1154
    glyph_index = FT_Get_Char_Index((FT_Face)face, aString[i]);
1155
    FT_Error error = FTC_Image_Cache_Lookup(mImageCache, &mImageDesc,
1156
                                            glyph_index, &glyph);
1157
    if (error) {
1158
      origin_x += FT_REG_TO_16_16(face->size->metrics.x_ppem/2 + 2);
1159
      continue;
1160
    }
1161
    origin_x += glyph->advance.x;
1162
  }
1163
1164
  NS_ENSURE_TRUE(mFontMetrics, 0);
1165
1166
  nsDeviceContextPS* dc = mFontMetrics->GetDeviceContext();
1167
  NS_ENSURE_TRUE(dc, 0);
1168
1169
  float dev2app;
1170
  dev2app = dc->DevUnitsToAppUnits();
1171
  origin_x *= dev2app;
1172
  origin_x /= FT_REG_TO_16_16(1);
1173
1174
  return NSToCoordRound((nscoord)origin_x);
1175
}
1176
1177
nscoord
1178
nsFontPSXft::DrawString(nsRenderingContextPS* aContext,
1179
                             nscoord aX, nscoord aY,
1180
                             const char* aString, PRUint32 aLength)
1181
{
1182
  NS_ENSURE_TRUE(aContext, 0);
1183
  nsPostScriptObj* psObj = aContext->GetPostScriptObj();
1184
  NS_ENSURE_TRUE(psObj, 0);
1185
  nscoord width = 0;
1186
  
1187
  psObj->moveto(aX, aY);
1188
1189
  PRUnichar unichars[WIDEN_8_TO_16_BUF_SIZE];
1190
  PRUint32 len;
1191
  
1192
  while ( aLength > 0 ) {
1193
    len = PR_MIN(aLength, WIDEN_8_TO_16_BUF_SIZE);
1194
    for (PRUint32 i=0; i < len; i++) {
1195
      unichars[i] = PRUnichar(PRUint8(aString[i]));
1196
    }
1197
    psObj->show(unichars, len, "", 1);
1198
    mPSFontGenerator->AddToSubset(unichars, len);
1199
    width += GetWidth(unichars, len);
1200
    aString += len;
1201
    aLength -= len;
1202
  }
1203
  return width;
1204
}
1205
1206
nscoord
1207
nsFontPSXft::DrawString(nsRenderingContextPS* aContext,
1208
                             nscoord aX, nscoord aY,
1209
                             const PRUnichar* aString, PRUint32 aLength)
1210
{
1211
  NS_ENSURE_TRUE(aContext, 0);
1212
  nsPostScriptObj* psObj = aContext->GetPostScriptObj();
1213
  NS_ENSURE_TRUE(psObj, 0);
1214
1215
  psObj->moveto(aX, aY);
1216
  psObj->show(aString, aLength, "", 1);
1217
  
1218
  mPSFontGenerator->AddToSubset(aString, aLength);
1219
  return GetWidth(aString, aLength);
1220
}
1221
1222
int
1223
nsFontPSXft::ascent()
1224
{
1225
  FT_Face face = getFTFace();
1226
  NS_ASSERTION(face, "failed to get face/size");
1227
  NS_ENSURE_TRUE(face, 0);
1228
  return FT_DESIGN_UNITS_TO_PIXELS(face->ascender, face->size->metrics.y_scale);
1229
}
1230
1231
int
1232
nsFontPSXft::descent()
1233
{
1234
  FT_Face face = getFTFace();
1235
  NS_ASSERTION(face, "failed to get face/size");
1236
  NS_ENSURE_TRUE(face, 0);
1237
  return FT_DESIGN_UNITS_TO_PIXELS(-face->descender, face->size->metrics.y_scale);
1238
}
1239
1240
int
1241
nsFontPSXft::max_ascent()
1242
{
1243
  FT_Face face = getFTFace();
1244
  NS_ASSERTION(face, "failed to get face/size");
1245
  NS_ENSURE_TRUE(face, 0);
1246
  TT_OS2 *tt_os2 = (TT_OS2 *) FT_Get_Sfnt_Table(face, ft_sfnt_os2);
1247
  NS_ASSERTION(tt_os2, "unable to get OS2 table");
1248
  if (tt_os2)
1249
     return FT_DESIGN_UNITS_TO_PIXELS(tt_os2->sTypoAscender,
1250
                                      face->size->metrics.y_scale);
1251
  else
1252
     return FT_DESIGN_UNITS_TO_PIXELS(face->bbox.yMax,
1253
                                      face->size->metrics.y_scale);
1254
}
1255
1256
int
1257
nsFontPSXft::max_descent()
1258
{
1259
  FT_Face face = getFTFace();
1260
  NS_ASSERTION(face, "failed to get face/size");
1261
  NS_ENSURE_TRUE(face, 0);
1262
  TT_OS2 *tt_os2 = (TT_OS2 *) FT_Get_Sfnt_Table(face, ft_sfnt_os2);
1263
  NS_ASSERTION(tt_os2, "unable to get OS2 table");
1264
  if (tt_os2)
1265
     return FT_DESIGN_UNITS_TO_PIXELS(-tt_os2->sTypoDescender,
1266
                                      face->size->metrics.y_scale);
1267
  else
1268
     return FT_DESIGN_UNITS_TO_PIXELS(-face->bbox.yMin,
1269
                                      face->size->metrics.y_scale);
1270
}
1271
1272
int
1273
nsFontPSXft::max_width()
1274
{
1275
  FT_Face face = getFTFace();
1276
  NS_ASSERTION(face, "failed to get face/size");
1277
  NS_ENSURE_TRUE(face, 0);
1278
  return FT_DESIGN_UNITS_TO_PIXELS(face->max_advance_width,
1279
                                   face->size->metrics.x_scale);
1280
}
1281
1282
PRBool
1283
nsFontPSXft::getXHeight(unsigned long &aVal)
1284
{
1285
  FT_Face face = getFTFace();
1286
  NS_ASSERTION(face, "failed to get face/size");
1287
  if (!face || !aVal)
1288
    return PR_FALSE;
1289
  aVal = FT_DESIGN_UNITS_TO_PIXELS(face->height, face->size->metrics.y_scale);
1290
1291
  return PR_TRUE;
1292
}
1293
1294
PRBool
1295
nsFontPSXft::underlinePosition(long &aVal)
1296
{
1297
  FT_Face face = getFTFace();
1298
  NS_ASSERTION(face, "failed to get face/size");
1299
  if (!face)
1300
    return PR_FALSE;
1301
  aVal = FT_DESIGN_UNITS_TO_PIXELS(-face->underline_position,
1302
                                   face->size->metrics.y_scale);
1303
  return PR_TRUE;
570
}
1304
}
571
1305
572
nscoord
1306
PRBool
573
nsFontPSAFM::GetWidth(const PRUnichar* aString, PRUint32 aLength)
1307
nsFontPSXft::underline_thickness(unsigned long &aVal)
574
{
1308
{
575
  nscoord width = 0;
1309
  FT_Face face = getFTFace();
576
  if (mAFMInfo) {
1310
  NS_ASSERTION(face, "failed to get face/size");
577
    mAFMInfo->GetStringWidth(aString, width, aLength);
1311
  if (!face)
578
  }
1312
    return PR_FALSE;
579
  return width;
1313
  aVal = FT_DESIGN_UNITS_TO_PIXELS(face->underline_thickness,
1314
                                   face->size->metrics.x_scale);
1315
  return PR_TRUE;
580
}
1316
}
581
1317
582
nscoord
1318
PRBool
583
nsFontPSAFM::DrawString(nsRenderingContextPS* aContext,
1319
nsFontPSXft::superscript_y(long &aVal)
584
                        nscoord aX, nscoord aY,
585
                        const char* aString, PRUint32 aLength)
586
{
1320
{
587
  NS_ENSURE_TRUE(aContext, 0);
1321
  aVal = 0;
588
  nsPostScriptObj* psObj = aContext->GetPostScriptObj();
1322
  FT_Face face = getFTFace();
589
  NS_ENSURE_TRUE(psObj, 0);
1323
  NS_ASSERTION(face, "failed to get face/size");
1324
  if (!face)
1325
    return PR_FALSE;
590
1326
591
  psObj->moveto(aX, aY);
1327
  TT_OS2 *tt_os2 = (TT_OS2 *) FT_Get_Sfnt_Table(face, ft_sfnt_os2);
592
  psObj->show(aString, aLength, "");
1328
  NS_ASSERTION(tt_os2, "unable to get OS2 table");
593
  return GetWidth(aString, aLength);
1329
  if (!tt_os2)
1330
    return PR_FALSE;
1331
1332
  aVal = FT_DESIGN_UNITS_TO_PIXELS(tt_os2->ySuperscriptYOffset,
1333
                                  face->size->metrics.y_scale);
1334
  return PR_TRUE;
594
}
1335
}
595
1336
596
nscoord
1337
PRBool
597
nsFontPSAFM::DrawString(nsRenderingContextPS* aContext,
1338
nsFontPSXft::subscript_y(long &aVal)
598
                        nscoord aX, nscoord aY,
599
                        const PRUnichar* aString, PRUint32 aLength)
600
{
1339
{
601
  NS_ENSURE_TRUE(aContext, 0);
1340
  aVal = 0;
602
  nsPostScriptObj* psObj = aContext->GetPostScriptObj();
1341
  FT_Face face = getFTFace();
603
  NS_ENSURE_TRUE(psObj, 0);
1342
  NS_ASSERTION(face, "failed to get face/size");
1343
  if (!face)
1344
    return PR_FALSE;
604
1345
605
  psObj->moveto(aX, aY);
1346
  TT_OS2 *tt_os2 = (TT_OS2 *) FT_Get_Sfnt_Table(face, ft_sfnt_os2);
606
  psObj->show(aString, aLength, "", 0);
1347
  NS_ASSERTION(tt_os2, "unable to get OS2 table");
607
  return GetWidth(aString, aLength);
1348
  if (!tt_os2)
1349
    return PR_FALSE;
1350
1351
  aVal = FT_DESIGN_UNITS_TO_PIXELS(tt_os2->ySubscriptYOffset,
1352
                                  face->size->metrics.y_scale);
1353
1354
  // some fonts have the sign wrong. it should be always positive.
1355
  aVal = (aVal < 0) ? -aVal : aVal;
1356
  return PR_TRUE;
608
}
1357
}
609
1358
610
nsresult
1359
nsresult
611
nsFontPSAFM::RealizeFont(nsFontMetricsPS* aFontMetrics, float dev2app)
1360
nsFontPSXft::RealizeFont(nsFontMetricsPS* aFontMetrics, float dev2app)
612
{
1361
{
613
  NS_ENSURE_ARG_POINTER(aFontMetrics);
1362
 
614
1363
  nscoord leading, emHeight, emAscent, emDescent;
615
  float fontSize;
1364
  nscoord maxHeight, maxAscent, maxDescent, maxAdvance;
616
  float offset;
1365
  nscoord xHeight, spaceWidth, aveCharWidth;
1366
  nscoord underlineOffset, underlineSize, superscriptOffset, subscriptOffset;
1367
  nscoord strikeoutOffset, strikeoutSize;
617
1368
618
  nscoord onePixel = NSToCoordRound(1 * dev2app);
1369
  int lineSpacing = ascent() + descent();
1370
  if (lineSpacing > mPixelSize) {
1371
    leading = nscoord((lineSpacing - mPixelSize) * dev2app);
1372
  }
1373
  else {
1374
    leading = 0;
1375
  }
1376
  emHeight = PR_MAX(1, nscoord(mPixelSize * dev2app));
1377
  emAscent = nscoord(ascent() * mPixelSize * dev2app / lineSpacing);
1378
  emDescent = emHeight - emAscent;
619
1379
620
  // convert the font size which is in twips to points
1380
  maxHeight  = nscoord((max_ascent() + max_descent()) * dev2app);
621
  fontSize = mFont->size / TWIPS_PER_POINT_FLOAT;
1381
  maxAscent  = nscoord(max_ascent() * dev2app) ;
1382
  maxDescent = nscoord(max_descent() * dev2app);
1383
  maxAdvance = nscoord(max_width() * dev2app);
622
1384
623
  offset = NSFloatPointsToTwips(fontSize * mAFMInfo->mPSFontInfo->mXHeight) / 1000.0f;
1385
  // 56% of ascent, best guess for non-true type
624
  nscoord xHeight = NSToCoordRound(offset);
1386
  xHeight = NSToCoordRound((float)ascent()* dev2app * 0.56f);
625
  aFontMetrics->SetXHeight(xHeight);
626
  aFontMetrics->SetSuperscriptOffset(xHeight);
627
  aFontMetrics->SetSubscriptOffset(xHeight);
628
  aFontMetrics->SetStrikeout((nscoord)(xHeight / 2), onePixel);
629
1387
630
  offset = NSFloatPointsToTwips(fontSize * mAFMInfo->mPSFontInfo->mUnderlinePosition) / 1000.0f;
1388
  PRUnichar space = (PRUnichar)' ';
631
  aFontMetrics->SetUnderline(NSToCoordRound(offset), onePixel);
1389
  spaceWidth = NSToCoordRound(GetWidth(&space, 1));
1390
  PRUnichar averageX = (PRUnichar)'x';
1391
  aveCharWidth = NSToCoordRound(GetWidth(&averageX, 1));
1392
  
1393
  unsigned long pr = 0;
1394
  if (getXHeight(pr)) {
1395
    xHeight = (nscoord(pr * dev2app));
1396
  }
632
1397
633
  nscoord size = NSToCoordRound(fontSize * dev2app);
1398
  float height;
634
  aFontMetrics->SetHeight(size);
1399
  long val;
635
  aFontMetrics->SetEmHeight(size);
1400
  
636
  aFontMetrics->SetMaxAdvance(size);
1401
  height = ascent() + descent();
637
  aFontMetrics->SetMaxHeight(size);
1402
  underlineOffset = -NSToIntRound(
1403
                    PR_MAX (1, floor (0.1 * height + 0.5)) * dev2app);
638
1404
639
  offset = NSFloatPointsToTwips(fontSize * mAFMInfo->mPSFontInfo->mAscender) / 1000.0f;
1405
  if (underline_thickness(pr)) {
640
  nscoord ascent = NSToCoordRound(offset);
1406
    /* this will only be provided from adobe .afm fonts */
641
  aFontMetrics->SetAscent(ascent);
1407
    underlineSize = nscoord(PR_MAX(dev2app, NSToIntRound(pr * dev2app)));
642
  aFontMetrics->SetEmAscent(ascent);
1408
  }
643
  aFontMetrics->SetMaxAscent(ascent);
1409
  else {
1410
    height = ascent() + descent();
1411
    underlineSize = NSToIntRound(
1412
                    PR_MAX(1, floor (0.05 * height + 0.5)) * dev2app);
1413
  }
644
1414
645
  offset = NSFloatPointsToTwips(fontSize * mAFMInfo->mPSFontInfo->mDescender) / 1000.0f;
1415
  if (superscript_y(val)) {
646
  nscoord descent = -(NSToCoordRound(offset));
1416
    superscriptOffset = nscoord(PR_MAX(dev2app, NSToIntRound(val * dev2app)));
647
  aFontMetrics->SetDescent(descent);
1417
  }
648
  aFontMetrics->SetEmDescent(descent);
1418
  else {
649
  aFontMetrics->SetMaxDescent(descent);
1419
    superscriptOffset = xHeight;
1420
  }
650
1421
651
  aFontMetrics->SetLeading(0);
1422
  if (subscript_y(val)) {
1423
    subscriptOffset = nscoord(PR_MAX(dev2app, NSToIntRound(val * dev2app)));
1424
  }
1425
  else {
1426
   subscriptOffset = xHeight;
1427
  }
652
1428
653
  nscoord spaceWidth = GetWidth(" ", 1);
1429
  /* need better way to calculate this */
1430
  strikeoutOffset = NSToCoordRound(xHeight / 2.0);
1431
  strikeoutSize = underlineSize;
1432
  
1433
  // TODO: leading never used, does it equal to "Height"?
1434
  aFontMetrics->SetHeight(emHeight);
1435
  aFontMetrics->SetEmHeight(emHeight);
1436
  aFontMetrics->SetEmAscent(emAscent);
1437
  aFontMetrics->SetEmDescent(emDescent);
1438
  aFontMetrics->SetMaxHeight(maxHeight);
1439
  aFontMetrics->SetMaxAscent(maxAscent);
1440
  aFontMetrics->SetMaxDescent(maxDescent);
1441
  aFontMetrics->SetMaxAdvance(maxAdvance);
1442
  aFontMetrics->SetXHeight(xHeight);
654
  aFontMetrics->SetSpaceWidth(spaceWidth);
1443
  aFontMetrics->SetSpaceWidth(spaceWidth);
655
656
  nscoord aveCharWidth = GetWidth("x", 1);
657
  aFontMetrics->SetAveCharWidth(aveCharWidth);
1444
  aFontMetrics->SetAveCharWidth(aveCharWidth);
1445
  aFontMetrics->SetUnderline(underlineOffset, underlineSize);
1446
  aFontMetrics->SetSuperscriptOffset(superscriptOffset);
1447
  aFontMetrics->SetSubscriptOffset(subscriptOffset);
1448
  aFontMetrics->SetStrikeout(strikeoutOffset, strikeoutSize);
658
1449
659
  return NS_OK;
1450
  return NS_OK;
660
}
1451
}
661
1452
662
nsresult
1453
nsresult
663
nsFontPSAFM::SetupFont(nsRenderingContextPS* aContext)
1454
nsFontPSXft::SetupFont(nsRenderingContextPS* aContext)
664
{
1455
{
665
  NS_ENSURE_TRUE(aContext && mFontMetrics, 0);
1456
  NS_ENSURE_TRUE(aContext, NS_ERROR_FAILURE);
666
  nsPostScriptObj* psObj = aContext->GetPostScriptObj();
1457
  nsPostScriptObj* psObj = aContext->GetPostScriptObj();
667
  NS_ENSURE_TRUE(psObj, 0);
1458
  NS_ENSURE_TRUE(psObj, NS_ERROR_FAILURE);
668
1459
669
  nscoord fontHeight = 0;
1460
  nscoord fontHeight = 0;
670
  mFontMetrics->GetHeight(fontHeight);
1461
  mFontMetrics->GetHeight(fontHeight);
671
1462
672
  psObj->setscriptfont(mFontIndex, mFamilyName,
1463
  nsCString fontName;
673
                       fontHeight, mFont->style, mFont->variant,
1464
  int wmode = 0;
674
                       mFont->weight, mFont->decorations);
1465
  FT_Face face = getFTFace();
1466
  NS_ENSURE_TRUE(face, NS_ERROR_NULL_POINTER);
1467
  char *cidFontName = FT2ToType8CidFontName(face, wmode);
1468
  NS_ENSURE_TRUE(cidFontName, NS_ERROR_FAILURE);
1469
  fontName.Assign(cidFontName);
1470
  psObj->setfont(fontName, fontHeight);
1471
  PR_Free(cidFontName);
1472
  
675
  return NS_OK;
1473
  return NS_OK;
676
}
1474
}
677
1475
678
#ifdef MOZ_MATHML
1476
#ifdef MOZ_MATHML
679
nsresult
1477
nsresult
680
nsFontPSAFM::GetBoundingMetrics(const char*        aString,
1478
nsFontPSXft::GetBoundingMetrics(const char*        aString,
681
                                PRUint32           aLength,
1479
                                     PRUint32           aLength,
682
                                nsBoundingMetrics& aBoundingMetrics)
1480
                                     nsBoundingMetrics& aBoundingMetrics)
683
{
1481
{
684
  return NS_ERROR_NOT_IMPLEMENTED;
1482
  return NS_ERROR_NOT_IMPLEMENTED;
685
}
1483
}
686
1484
687
nsresult
1485
nsresult
688
nsFontPSAFM::GetBoundingMetrics(const PRUnichar*   aString,
1486
nsFontPSXft::GetBoundingMetrics(const PRUnichar*   aString,
689
                                PRUint32           aLength,
1487
                                     PRUint32           aLength,
690
                                nsBoundingMetrics& aBoundingMetrics)
1488
                                     nsBoundingMetrics& aBoundingMetrics)
691
{
1489
{
692
  return NS_ERROR_NOT_IMPLEMENTED;
1490
  return NS_ERROR_NOT_IMPLEMENTED;
693
}
1491
}
694
#endif
1492
#endif //MOZ_MATHML
695
696
#ifdef MOZ_ENABLE_FREETYPE2
697
1493
698
#define WIDEN_8_TO_16_BUF_SIZE 1024
1494
#else
699
1495
700
PRBool
1496
PRBool
701
nsFontPSFreeType::CSSFontEnumCallback(const nsString& aFamily, PRBool aGeneric,
1497
nsFontPSFreeType::CSSFontEnumCallback(const nsString& aFamily, PRBool aGeneric,
702
                                      void* aFpi)
1498
                                      void* aFpi)
703
{
1499
{
704
  fontPSInfo* fpi = (fontPSInfo*)aFpi;
1500
  fontPSInfo* fpi = (fontPSInfo*)aFpi;
705
  nsCAutoString familyname;
1501
  nsCAutoString familyname;
Lines 709-723 nsFontPSFreeType::CSSFontEnumCallback(co Link Here
709
      return PR_TRUE; // keep trying
1505
      return PR_TRUE; // keep trying
710
    }
1506
    }
711
    nsXPIDLCString value;
1507
    nsXPIDLCString value;
712
    nsresult rv;
1508
    nsresult rv;
713
    nsCOMPtr<nsIPref> pref(do_GetService(NS_PREF_CONTRACTID, &rv));
1509
    nsCOMPtr<nsIPref> pref(do_GetService(NS_PREF_CONTRACTID, &rv));
714
    NS_ENSURE_SUCCESS(rv, PR_TRUE); // keep trying
1510
    NS_ENSURE_SUCCESS(rv, PR_TRUE); // keep trying
715
    nsCAutoString name("font.name.");
1511
    nsCAutoString name("font.name.");
716
    name.AppendWithConversion(aFamily.get());
1512
    LossyAppendUTF16toASCII(aFamily, name);
717
    name.Append(char('.'));
1513
    name.Append(char('.'));
718
    name.Append(fpi->lang);
1514
    name.Append(fpi->lang);
719
    pref->CopyCharPref(name.get(), getter_Copies(value));
1515
    pref->CopyCharPref(name.get(), getter_Copies(value));
720
    if (!value.get())
1516
    if (!value.get())
721
      return PR_TRUE; // keep trying
1517
      return PR_TRUE; // keep trying
722
    // strip down to just the family name
1518
    // strip down to just the family name
723
    PRInt32 startFamily = value.FindChar('-') + 1;
1519
    PRInt32 startFamily = value.FindChar('-') + 1;
Lines 730-744 nsFontPSFreeType::CSSFontEnumCallback(co Link Here
730
      else  // FFRE 
1526
      else  // FFRE 
731
        familyname.Append(Substring(value, startFamily, endFamily - startFamily));
1527
        familyname.Append(Substring(value, startFamily, endFamily - startFamily));
732
    }
1528
    }
733
    PR_LOG(gFontMetricsPSM, PR_LOG_DEBUG,
1529
    PR_LOG(gFontMetricsPSM, PR_LOG_DEBUG,
734
        ("generic font \"%s\" -> \"%s\"\n", name.get(), familyname.get()));
1530
        ("generic font \"%s\" -> \"%s\"\n", name.get(), familyname.get()));
735
  }
1531
  }
736
  else
1532
  else
737
    familyname.AppendWithConversion(aFamily);
1533
    LossyAppendUTF16toASCII(aFamily, familyname);
738
1534
739
  AddFontEntries(familyname, fpi->lang, fpi->weight, 
1535
  AddFontEntries(familyname, fpi->lang, fpi->weight, 
740
                 nsIFontCatalogService::kFCWidthAny, fpi->slant,
1536
                 nsIFontCatalogService::kFCWidthAny, fpi->slant,
741
                 nsIFontCatalogService::kFCSpacingAny, fpi);
1537
                 nsIFontCatalogService::kFCSpacingAny, fpi);
742
1538
743
  return PR_TRUE;
1539
  return PR_TRUE;
744
}
1540
}
Lines 1556-1569 nsFontPSFreeType::GetBoundingMetrics(con Link Here
1556
                                     nsBoundingMetrics& aBoundingMetrics)
2352
                                     nsBoundingMetrics& aBoundingMetrics)
1557
{
2353
{
1558
  return NS_ERROR_NOT_IMPLEMENTED;
2354
  return NS_ERROR_NOT_IMPLEMENTED;
1559
}
2355
}
1560
#endif //MOZ_MATHML
2356
#endif //MOZ_MATHML
1561
2357
1562
#endif //MOZ_ENABLE_FREETYPE2
2358
#endif //MOZ_ENABLE_FREETYPE2
2359
#endif //MOZ_ENABLE_XFT
1563
2360
1564
// Implementation of nsPSFontGenerator
2361
// Implementation of nsPSFontGenerator
1565
nsPSFontGenerator::nsPSFontGenerator()
2362
nsPSFontGenerator::nsPSFontGenerator()
1566
{
2363
{
1567
}
2364
}
1568
2365
1569
nsPSFontGenerator::~nsPSFontGenerator()
2366
nsPSFontGenerator::~nsPSFontGenerator()
Lines 1589-1603 void nsPSFontGenerator::AddToSubset(cons Link Here
1589
  for (PRUint32 i=0; i < aLength; i++) {
2386
  for (PRUint32 i=0; i < aLength; i++) {
1590
    unichar = (PRUnichar)((unsigned char)aString[i]);
2387
    unichar = (PRUnichar)((unsigned char)aString[i]);
1591
    if (mSubset.FindChar(unichar) == -1 )
2388
    if (mSubset.FindChar(unichar) == -1 )
1592
      mSubset.Append(unichar);
2389
      mSubset.Append(unichar);
1593
  }
2390
  }
1594
}
2391
}
1595
2392
2393
#ifdef MOZ_ENABLE_XFT
2394
nsXftType8Generator::nsXftType8Generator()
2395
{
2396
}
2397
2398
nsresult
2399
nsXftType8Generator::Init(nsXftEntry* aEntry)
2400
{
2401
  NS_ENSURE_TRUE(aEntry, NS_ERROR_FAILURE);
2402
  mEntry = aEntry;
2403
2404
  FT_Error error = FT_Init_FreeType(&mFreeTypeLibrary);
2405
  NS_ASSERTION(!error, "failed to initialize FreeType library");
2406
  if (error) {
2407
    mFreeTypeLibrary = nsnull;
2408
    return NS_ERROR_FAILURE;
2409
  }
2410
  error = FTC_Manager_New(mFreeTypeLibrary, 0, 0, 0, nsXftFaceRequester,
2411
                          NULL, &mFTCacheManager);
2412
  NS_ASSERTION(!error, "failed to create FreeType Cache manager");
2413
  if (error)
2414
    return NS_ERROR_FAILURE;
2415
2416
  return NS_OK;
2417
}
2418
2419
nsXftType8Generator::~nsXftType8Generator()
2420
{
2421
  FTC_Manager_Done(mFTCacheManager);
2422
2423
  if (FT_Done_FreeType(mFreeTypeLibrary))
2424
    return;
2425
2426
  mEntry = nsnull;
2427
}
2428
2429
void nsXftType8Generator::GeneratePSFont(FILE* aFile)
2430
{
2431
  FT_Error error;
2432
  FT_Face face = mEntry->mFace;
2433
2434
  if (face == nsnull) {
2435
    mImageDesc.font.face_id    = (void*)mEntry;
2436
    mImageDesc.font.pix_width  = 16;
2437
    mImageDesc.font.pix_height = 16;
2438
    mImageDesc.image_type = 0;
2439
    error = FTC_Manager_Lookup_Size(mFTCacheManager, &mImageDesc.font,
2440
                                    &face, nsnull);
2441
    if (error)
2442
      return;
2443
  }
2444
2445
  if (face == nsnull)
2446
    return;
2447
 
2448
  int wmode = 0;
2449
  if (!mSubset.IsEmpty())
2450
    FT2SubsetToType8(face, mSubset.get(), mSubset.Length(), wmode, aFile);
2451
}
2452
2453
#else
1596
#ifdef MOZ_ENABLE_FREETYPE2
2454
#ifdef MOZ_ENABLE_FREETYPE2
2455
1597
nsFT2Type8Generator::nsFT2Type8Generator()
2456
nsFT2Type8Generator::nsFT2Type8Generator()
1598
{
2457
{
1599
}
2458
}
1600
2459
1601
nsresult
2460
nsresult
1602
nsFT2Type8Generator::Init(nsITrueTypeFontCatalogEntry* aEntry)
2461
nsFT2Type8Generator::Init(nsITrueTypeFontCatalogEntry* aEntry)
1603
{
2462
{
Lines 1635-1643 void nsFT2Type8Generator::GeneratePSFont Link Here
1635
  if (NS_FAILED(rv))
2494
  if (NS_FAILED(rv))
1636
    return;
2495
    return;
1637
 
2496
 
1638
  int wmode = 0;
2497
  int wmode = 0;
1639
  if (!mSubset.IsEmpty())
2498
  if (!mSubset.IsEmpty())
1640
    FT2SubsetToType8(face, mSubset.get(), mSubset.Length(), wmode, aFile);
2499
    FT2SubsetToType8(face, mSubset.get(), mSubset.Length(), wmode, aFile);
1641
}
2500
}
1642
#endif //MOZ_ENABLE_FREETYPE2
1643
2501
2502
#endif //MOZ_ENABLE_FREETYPE2
2503
#endif //MOZ_ENABLE_XFT
(-)gfx/src/ps/nsFontMetricsPS.h (-6 / +139 lines)
Lines 47-61 Link Here
47
#include "nsIAtom.h"
47
#include "nsIAtom.h"
48
#include "nsUnitConversion.h"
48
#include "nsUnitConversion.h"
49
#include "nsIDeviceContext.h"
49
#include "nsIDeviceContext.h"
50
#include "nsCOMPtr.h"
50
#include "nsCOMPtr.h"
51
#include "nsCRT.h"
51
#include "nsCRT.h"
52
#include "nsCompressedCharMap.h"
52
#include "nsCompressedCharMap.h"
53
#include "nsPostScriptObj.h"
53
#include "nsPostScriptObj.h"
54
#ifdef MOZ_ENABLE_XFT
55
#include <ft2build.h>
56
#include FT_FREETYPE_H
57
#include FT_GLYPH_H
58
#include FT_CACHE_H
59
#include FT_CACHE_IMAGE_H
60
#include FT_OUTLINE_H
61
#include FT_OUTLINE_H
62
#include FT_TRUETYPE_TABLES_H
63
#else
64
#ifdef MOZ_ENABLE_FREETYPE2
54
#include "nsIFontCatalogService.h"
65
#include "nsIFontCatalogService.h"
66
#endif
67
#endif
55
#include "nsVoidArray.h"
68
#include "nsVoidArray.h"
56
#include "nsHashtable.h"
69
#include "nsHashtable.h"
57
70
58
class nsPSFontGenerator;
71
class nsPSFontGenerator;
59
class nsDeviceContextPS;
72
class nsDeviceContextPS;
60
class nsRenderingContextPS;
73
class nsRenderingContextPS;
61
class nsFontPS;
74
class nsFontPS;
Lines 247-270 public: Link Here
247
#endif
260
#endif
248
261
249
  nsAFMObject* mAFMInfo;
262
  nsAFMObject* mAFMInfo;
250
  PRInt16      mFontIndex;
263
  PRInt16      mFontIndex;
251
  nsString     mFamilyName;
264
  nsString     mFamilyName;
252
};
265
};
253
266
267
268
#ifdef MOZ_ENABLE_XFT
269
270
#include <X11/Xft/Xft.h>
271
272
class nsXftEntry
273
{
274
public:
275
  nsXftEntry(FcPattern *aFontPattern);
276
  ~nsXftEntry() {}; 
277
278
  FT_Face       mFace;
279
  int           mFaceIndex;
280
  nsCString     mFontFileName;
281
  nsCString     mFamilyName;
282
  nsCString     mStyleName;
283
284
protected:
285
  nsXftEntry() {};
286
};
287
288
struct fontps {
289
  nsXftEntry *entry;
290
  nsFontPS   *fontps;
291
  FcCharSet  *charset;
292
};
293
294
struct fontPSInfo {
295
  nsVoidArray     *fontps;
296
  const nsFont*    nsfont;
297
  nsCAutoString    lang;
298
  nsHashtable     *alreadyLoaded;
299
  nsCStringArray   mFontList;
300
  nsAutoVoidArray  mFontIsGeneric;
301
  nsCString       *mGenericFont;
302
};
303
304
class nsFontPSXft : public nsFontPS
305
{
306
public:
307
  static nsFontPS* FindFont(PRUnichar aChar, const nsFont& aFont,
308
                            nsFontMetricsPS* aFontMetrics);
309
  nsresult         Init(nsXftEntry* aEntry,
310
                        nsPSFontGenerator* aPSFontGen);
311
  static PRBool CSSFontEnumCallback(const nsString& aFamily, PRBool aGeneric,
312
                                    void* aFpi);
313
314
  nsFontPSXft(const nsFont& aFont, nsFontMetricsPS* aFontMetrics);
315
  virtual ~nsFontPSXft();
316
  NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
317
318
  nscoord GetWidth(const char* aString, PRUint32 aLength);
319
  nscoord GetWidth(const PRUnichar* aString, PRUint32 aLength);
320
  nscoord DrawString(nsRenderingContextPS* aContext,
321
                     nscoord aX, nscoord aY,
322
                     const char* aString, PRUint32 aLength);
323
  nscoord DrawString(nsRenderingContextPS* aContext,
324
                     nscoord aX, nscoord aY,
325
                     const PRUnichar* aString, PRUint32 aLength);
326
  nsresult RealizeFont(nsFontMetricsPS* aFontMetrics, float dev2app);
327
  nsresult SetupFont(nsRenderingContextPS* aContext);
328
329
#ifdef MOZ_MATHML
330
  nsresult
331
  GetBoundingMetrics(const char*        aString,
332
                     PRUint32           aLength,
333
                     nsBoundingMetrics& aBoundingMetrics);
334
  nsresult
335
  GetBoundingMetrics(const PRUnichar*   aString,
336
                     PRUint32           aLength,
337
                     nsBoundingMetrics& aBoundingMetrics);
338
#endif
339
340
  nsXftEntry *mEntry;
341
  FT_Face getFTFace();
342
343
protected:
344
  PRUint16        mPixelSize;
345
  FTC_Image_Desc  mImageDesc;
346
  FT_Library      mFreeTypeLibrary;
347
  FTC_Manager     mFTCacheManager;
348
  FTC_Image_Cache mImageCache;
349
350
  int     ascent();
351
  int     descent();
352
  PRBool  getXHeight(unsigned long &aVal);
353
  int     max_ascent();
354
  int     max_descent();
355
  int     max_width();
356
  PRBool  superscript_y(long &aVal);
357
  PRBool  subscript_y(long &aVal);
358
  PRBool  underlinePosition(long &aVal);
359
  PRBool  underline_thickness(unsigned long &aVal);
360
  nsPSFontGenerator*  mPSFontGenerator;
361
};
362
363
#else
364
365
#ifdef MOZ_ENABLE_FREETYPE2
366
#include "nsIFreeType2.h"
367
254
typedef struct {
368
typedef struct {
255
  nsITrueTypeFontCatalogEntry *entry;
369
  nsITrueTypeFontCatalogEntry *entry;
256
  nsFontPS *fontps;
370
  nsFontPS *fontps;
257
  unsigned short *ccmap;
371
  unsigned short *ccmap;
258
} fontps;
372
} fontps;
259
373
260
#ifdef MOZ_ENABLE_FREETYPE2
261
262
#include "nsIFreeType2.h"
263
264
typedef struct {
374
typedef struct {
265
  nsVoidArray *fontps;
375
  nsVoidArray *fontps;
266
  const nsFont* nsfont;
376
  const nsFont* nsfont;
267
  nsCAutoString lang;
377
  nsCAutoString lang;
268
  nsHashtable *alreadyLoaded;
378
  nsHashtable *alreadyLoaded;
269
  PRUint16 slant;
379
  PRUint16 slant;
270
  PRUint16 weight;
380
  PRUint16 weight;
Lines 334-371 protected: Link Here
334
  PRBool  superscript_y(long &aVal);
444
  PRBool  superscript_y(long &aVal);
335
  PRBool  subscript_y(long &aVal);
445
  PRBool  subscript_y(long &aVal);
336
  PRBool  underlinePosition(long &aVal);
446
  PRBool  underlinePosition(long &aVal);
337
  PRBool  underline_thickness(unsigned long &aVal);
447
  PRBool  underline_thickness(unsigned long &aVal);
338
  nsPSFontGenerator*  mPSFontGenerator;
448
  nsPSFontGenerator*  mPSFontGenerator;
339
};
449
};
340
450
341
#endif
451
#else // !FREETYPE2 && !XFT
452
typedef struct {
453
  nsFontPS   *fontps;
454
} fontps;
455
#endif // MOZ_ENABLE_FREETYPE2
456
#endif   // MOZ_ENABLE_XFT
342
457
343
class nsPSFontGenerator {
458
class nsPSFontGenerator {
344
public:
459
public:
345
  nsPSFontGenerator();
460
  nsPSFontGenerator();
346
  virtual ~nsPSFontGenerator();
461
  virtual ~nsPSFontGenerator();
347
  virtual void  GeneratePSFont(FILE* aFile);
462
  virtual void  GeneratePSFont(FILE* aFile);
348
  void  AddToSubset(const PRUnichar* aString, PRUint32 aLength);
463
  void  AddToSubset(const PRUnichar* aString, PRUint32 aLength);
349
  void  AddToSubset(const char* aString, PRUint32 aLength);
464
  void  AddToSubset(const char* aString, PRUint32 aLength);
350
465
351
protected:
466
protected:
352
  nsString mSubset;
467
  nsString mSubset;
353
};
468
};
354
469
470
471
#ifdef MOZ_ENABLE_XFT
472
473
class nsXftType8Generator : public nsPSFontGenerator {
474
public:
475
  nsXftType8Generator();
476
  ~nsXftType8Generator();
477
  nsresult Init(nsXftEntry* aFce);
478
  void  GeneratePSFont(FILE* aFile);
479
480
protected:
481
  nsXftEntry *mEntry;
482
  FTC_Image_Desc  mImageDesc;
483
  FT_Library      mFreeTypeLibrary;
484
  FTC_Manager     mFTCacheManager;
485
};
486
#else
355
#ifdef MOZ_ENABLE_FREETYPE2
487
#ifdef MOZ_ENABLE_FREETYPE2
356
class nsFT2Type8Generator : public nsPSFontGenerator {
488
class nsFT2Type8Generator : public nsPSFontGenerator {
357
public:
489
public:
358
  nsFT2Type8Generator();
490
  nsFT2Type8Generator();
359
  ~nsFT2Type8Generator();
491
  ~nsFT2Type8Generator();
360
  nsresult Init(nsITrueTypeFontCatalogEntry* aFce);
492
  nsresult Init(nsITrueTypeFontCatalogEntry* aFce);
361
  void  GeneratePSFont(FILE* aFile);
493
  void  GeneratePSFont(FILE* aFile);
362
494
363
protected:
495
protected:
364
  nsCOMPtr<nsITrueTypeFontCatalogEntry> mEntry;
496
  nsCOMPtr<nsITrueTypeFontCatalogEntry> mEntry;
365
  nsCOMPtr<nsIFreeType2> mFt2;
497
  nsCOMPtr<nsIFreeType2> mFt2;
366
  FTC_Image_Desc  mImageDesc;
498
  FTC_Image_Desc  mImageDesc;
367
};
499
};
368
#endif
500
#endif   // MOZ_ENABLE_FREETYPE2
501
#endif   // MOZ_ENABLE_XFT
369
502
370
#endif
503
#endif
371
504
(-)gfx/src/ps/nsType1.cpp (-5 / +35 lines)
Lines 67-81 Link Here
67
67
68
#include "nsType1.h"
68
#include "nsType1.h"
69
69
70
static const PRUint16 type1_encryption_c1 = TYPE1_ENCRYPTION_C1;
70
static const PRUint16 type1_encryption_c1 = TYPE1_ENCRYPTION_C1;
71
static const PRUint16 type1_encryption_c2 = TYPE1_ENCRYPTION_C2;
71
static const PRUint16 type1_encryption_c2 = TYPE1_ENCRYPTION_C2;
72
72
73
typedef struct {
73
typedef struct {
74
#ifndef MOZ_ENABLE_XFT
74
  nsIFreeType2  *ft2;
75
  nsIFreeType2  *ft2;
76
#endif
75
  FT_Face        face;
77
  FT_Face        face;
76
  int            elm_cnt;
78
  int            elm_cnt;
77
  int            len;
79
  int            len;
78
  double         cur_x;
80
  double         cur_x;
79
  double         cur_y;
81
  double         cur_y;
80
  unsigned char *buf;
82
  unsigned char *buf;
81
  int            wmode;
83
  int            wmode;
Lines 177-201 sideWidthAndBearing(FT_Vector *aEndPt, F Link Here
177
{
179
{
178
  int aw = 0;
180
  int aw = 0;
179
  int ah = 0;
181
  int ah = 0;
180
  FT_UShort upm = aFti->face->units_per_EM;
182
  FT_UShort upm = aFti->face->units_per_EM;
181
  FT_GlyphSlot slot;
183
  FT_GlyphSlot slot;
182
  FT_Glyph glyph;
184
  FT_Glyph glyph;
183
  FT_BBox bbox;
185
  FT_BBox bbox;
184
  nsresult rv;
185
186
186
  slot = aFti->face->glyph;
187
  slot = aFti->face->glyph;
187
188
188
  rv = aFti->ft2->GetGlyph(slot, &glyph);
189
#ifdef MOZ_ENABLE_XFT
190
  FT_Error error = FT_Get_Glyph(slot, &glyph);
191
  if (error) {
192
    NS_ERROR("sideWidthAndBearing failed to get glyph");
193
    return PR_FALSE;
194
  }
195
  FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_unscaled, &bbox);
196
#else
197
  nsresult rv = aFti->ft2->GetGlyph(slot, &glyph);
189
  if (NS_FAILED(rv)) {
198
  if (NS_FAILED(rv)) {
190
    NS_ERROR("sideWidthAndBearing failed to get glyph");
199
    NS_ERROR("sideWidthAndBearing failed to get glyph");
191
    return PR_FALSE;
200
    return PR_FALSE;
192
  }
201
  }
193
  aFti->ft2->GlyphGetCBox(glyph, ft_glyph_bbox_unscaled, &bbox);
202
  aFti->ft2->GlyphGetCBox(glyph, ft_glyph_bbox_unscaled, &bbox);
194
203
#endif
195
204
196
  if (aFti->wmode == 0)
205
  if (aFti->wmode == 0)
197
    aw = toCS(upm, slot->metrics.horiAdvance);
206
    aw = toCS(upm, slot->metrics.horiAdvance);
198
  else
207
  else
199
    aw = -toCS(upm, slot->metrics.vertAdvance);
208
    aw = -toCS(upm, slot->metrics.vertAdvance);
200
209
201
  if (aEndPt->y == 0) {
210
  if (aEndPt->y == 0) {
Lines 367-418 static FT_Outline_Funcs ft_outline_funcs Link Here
367
  conicto,
376
  conicto,
368
  cubicto,
377
  cubicto,
369
  0,
378
  0,
370
  0
379
  0
371
};
380
};
372
381
373
FT_Error
382
FT_Error
383
#ifdef MOZ_ENABLE_XFT
384
FT2GlyphToType1CharString(FT_Face aFace, PRUint32 aGlyphID,
385
                          int aWmode, int aLenIV, unsigned char *aBuf)
386
#else
374
FT2GlyphToType1CharString(nsIFreeType2 *aFt2, FT_Face aFace, PRUint32 aGlyphID,
387
FT2GlyphToType1CharString(nsIFreeType2 *aFt2, FT_Face aFace, PRUint32 aGlyphID,
375
                          int aWmode, int aLenIV, unsigned char *aBuf)
388
                          int aWmode, int aLenIV, unsigned char *aBuf)
389
#endif
376
{
390
{
377
  int j;
391
  int j;
378
  FT_Int32 flags = FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
392
  FT_Int32 flags = FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
379
  FT_GlyphSlot slot;
393
  FT_GlyphSlot slot;
380
  unsigned char *start = aBuf;
394
  unsigned char *start = aBuf;
381
  FT2PT1_info fti;
395
  FT2PT1_info fti;
382
  nsresult rv;
383
396
384
  rv = aFt2->LoadGlyph(aFace, aGlyphID, flags);
397
#ifdef MOZ_ENABLE_XFT
398
  FT_Error error = FT_Load_Glyph(aFace, aGlyphID, flags);
399
  if (error) {
400
    NS_ERROR("failed to load aGlyphID");
401
    return error;
402
  }
403
#else
404
  nsresult rv = aFt2->LoadGlyph(aFace, aGlyphID, flags);
385
  if (NS_FAILED(rv)) {
405
  if (NS_FAILED(rv)) {
386
    NS_ERROR("failed to load aGlyphID");
406
    NS_ERROR("failed to load aGlyphID");
387
    return 1;
407
    return 1;
388
  }
408
  }
409
#endif
389
  slot = aFace->glyph;
410
  slot = aFace->glyph;
390
411
391
  if (slot->format != ft_glyph_format_outline) {
412
  if (slot->format != ft_glyph_format_outline) {
392
    NS_ERROR("aGlyphID is not an outline glyph");
413
    NS_ERROR("aGlyphID is not an outline glyph");
393
    return 1;
414
    return 1;
394
  }
415
  }
395
416
417
#ifndef MOZ_ENABLE_XFT
396
  fti.ft2     = aFt2;
418
  fti.ft2     = aFt2;
419
#endif
397
  fti.face    = aFace;
420
  fti.face    = aFace;
398
  fti.buf     = aBuf;
421
  fti.buf     = aBuf;
399
  fti.elm_cnt = 0;
422
  fti.elm_cnt = 0;
400
  fti.len     = 0;
423
  fti.len     = 0;
401
  fti.wmode   = aWmode;
424
  fti.wmode   = aWmode;
402
425
403
  /* add space for "random" bytes */
426
  /* add space for "random" bytes */
404
  for (j=0; j< aLenIV; j++) {
427
  for (j=0; j< aLenIV; j++) {
405
    fti.len += ecsi(&fti.buf, 0);
428
    fti.len += ecsi(&fti.buf, 0);
406
  }
429
  }
430
#ifdef MOZ_ENABLE_XFT
431
  if (FT_Outline_Decompose(&slot->outline, &ft_outline_funcs, &fti))  {
432
    NS_ERROR("error decomposing aGlyphID");
433
    return 1;
434
  }
435
#else
407
  rv = aFt2->OutlineDecompose(&slot->outline, &ft_outline_funcs, &fti);
436
  rv = aFt2->OutlineDecompose(&slot->outline, &ft_outline_funcs, &fti);
408
  if (NS_FAILED(rv)) {
437
  if (NS_FAILED(rv)) {
409
    NS_ERROR("error decomposing aGlyphID");
438
    NS_ERROR("error decomposing aGlyphID");
410
    return 1;
439
    return 1;
411
  }
440
  }
441
#endif
412
442
413
  if (fti.elm_cnt) {
443
  if (fti.elm_cnt) {
414
    fti.len += csc(&fti.buf, T1_CLOSEPATH);
444
    fti.len += csc(&fti.buf, T1_CLOSEPATH);
415
    fti.len += csc(&fti.buf, T1_ENDCHAR);
445
    fti.len += csc(&fti.buf, T1_ENDCHAR);
416
  }
446
  }
417
  else {
447
  else {
418
    FT_Vector end_pt;
448
    FT_Vector end_pt;
(-)gfx/src/ps/nsType1.h (+12 lines)
Lines 50-64 Link Here
50
//
50
//
51
51
52
#ifndef TYPE1_H
52
#ifndef TYPE1_H
53
#define TYPE1_H
53
#define TYPE1_H
54
54
55
#include <stdio.h>
55
#include <stdio.h>
56
#include "nspr.h"
56
#include "nspr.h"
57
#ifdef MOZ_ENABLE_XFT
58
#include "nsISupports.h"
59
#include <ft2build.h>
60
#include FT_FREETYPE_H
61
#include FT_GLYPH_H
62
#include FT_OUTLINE_H
63
#else
57
#include "nsIFreeType2.h"
64
#include "nsIFreeType2.h"
65
#endif
58
66
59
/* to/from Character Space */
67
/* to/from Character Space */
60
inline int
68
inline int
61
toCS(double upm, double x)
69
toCS(double upm, double x)
62
{
70
{
63
  return (int)((x*1000.0)/upm);
71
  return (int)((x*1000.0)/upm);
64
}
72
}
Lines 91-102 fromCS(double upm, double x) Link Here
91
/* the 2 byte (escaped) Postscript Type 1 commands */
99
/* the 2 byte (escaped) Postscript Type 1 commands */
92
#define T1_ESC_SBW    7  /* 0x07 */
100
#define T1_ESC_SBW    7  /* 0x07 */
93
101
94
#define TYPE1_ENCRYPTION_KEY 4330
102
#define TYPE1_ENCRYPTION_KEY 4330
95
#define TYPE1_ENCRYPTION_C1  52845
103
#define TYPE1_ENCRYPTION_C1  52845
96
#define TYPE1_ENCRYPTION_C2  22719
104
#define TYPE1_ENCRYPTION_C2  22719
97
105
106
#ifdef MOZ_ENABLE_XFT  
107
FT_Error FT2GlyphToType1CharString(FT_Face aFace,
108
#else /* MOZ_ENABLE_FREETYPE2 */
98
FT_Error FT2GlyphToType1CharString(nsIFreeType2 *aFt2, FT_Face aFace,
109
FT_Error FT2GlyphToType1CharString(nsIFreeType2 *aFt2, FT_Face aFace,
110
#endif
99
                                   PRUint32 aGlyphID, int aWmode, int aLenIV,
111
                                   PRUint32 aGlyphID, int aWmode, int aLenIV,
100
                                   unsigned char *aBuf);
112
                                   unsigned char *aBuf);
101
113
102
#endif /* TYPE1_H */
114
#endif /* TYPE1_H */
(-)gfx/src/ps/nsType8.cpp (+37 lines)
Lines 49-77 Link Here
49
49
50
#include <string.h>
50
#include <string.h>
51
#include <unistd.h>
51
#include <unistd.h>
52
52
53
#include "nsCidMap.h"
53
#include "nsCidMap.h"
54
#include "nsType1.h"
54
#include "nsType1.h"
55
#include "nsType8.h"
55
#include "nsType8.h"
56
#ifndef MOZ_ENABLE_XFT
56
#include "nsIFreeType2.h"
57
#include "nsIFreeType2.h"
58
#endif
57
#include "nsIServiceManager.h"
59
#include "nsIServiceManager.h"
58
#include "nsISignatureVerifier.h"
60
#include "nsISignatureVerifier.h"
59
#include "plbase64.h"
61
#include "plbase64.h"
60
#include "nsCRT.h"
62
#include "nsCRT.h"
61
63
62
#define DEFAULT_CMAP_SIZE 10240
64
#define DEFAULT_CMAP_SIZE 10240
63
65
64
#define HEXASCII_LINE_LEN 64
66
#define HEXASCII_LINE_LEN 64
65
67
66
68
67
static void hex_out(unsigned char *buf, PRUint32 n, FILE *f, PRUint32 *pos);
69
static void hex_out(unsigned char *buf, PRUint32 n, FILE *f, PRUint32 *pos);
68
70
69
static void flatten_name(char *aToName);
71
static void flatten_name(char *aToName);
72
#ifdef MOZ_ENABLE_XFT
73
static int FT2SubsetToCidKeyedType1(FT_Face aFace,
74
#else
70
static int FT2SubsetToCidKeyedType1(nsIFreeType2 *aFt2, FT_Face aFace,
75
static int FT2SubsetToCidKeyedType1(nsIFreeType2 *aFt2, FT_Face aFace,
76
#endif
71
                                    const PRUnichar *aCharIDs, int aLen,
77
                                    const PRUnichar *aCharIDs, int aLen,
72
                                    const char *aFontName,
78
                                    const char *aFontName,
73
                                    const char *aRegistry,
79
                                    const char *aRegistry,
74
                                    const char *aEncoding, int aSupplement,
80
                                    const char *aEncoding, int aSupplement,
75
                                    int aWmode, int aLenIV, FILE *aFile);
81
                                    int aWmode, int aLenIV, FILE *aFile);
76
82
77
void
83
void
Lines 315-334 FT2SubsetToType8(FT_Face aFace, const PR Link Here
315
  char *encoding = NULL;
321
  char *encoding = NULL;
316
  int supplement, lenIV;
322
  int supplement, lenIV;
317
  PRUint32 CIDs_buf[5000];
323
  PRUint32 CIDs_buf[5000];
318
  PRUint32 *CIDs = CIDs_buf;
324
  PRUint32 *CIDs = CIDs_buf;
319
  int cmap_type = 0;
325
  int cmap_type = 0;
320
  PRBool status = PR_FALSE;
326
  PRBool status = PR_FALSE;
321
327
328
#ifndef MOZ_ENABLE_XFT
322
  nsresult rv;
329
  nsresult rv;
323
  nsCOMPtr<nsIFreeType2> ft2 = do_GetService(NS_FREETYPE2_CONTRACTID, &rv);
330
  nsCOMPtr<nsIFreeType2> ft2 = do_GetService(NS_FREETYPE2_CONTRACTID, &rv);
324
  if (NS_FAILED(rv)) {
331
  if (NS_FAILED(rv)) {
325
    NS_ERROR("Failed to get nsIFreeType2 service");
332
    NS_ERROR("Failed to get nsIFreeType2 service");
326
    goto done;
333
    goto done;
327
  }
334
  }
335
#endif
328
336
329
  if ((aNumChars+1) > sizeof(CIDs_buf)/sizeof(CIDs_buf[0]))
337
  if ((aNumChars+1) > sizeof(CIDs_buf)/sizeof(CIDs_buf[0]))
330
    CIDs = (PRUint32 *)PR_Malloc((aNumChars+1)*sizeof(CIDs_buf[0]));
338
    CIDs = (PRUint32 *)PR_Malloc((aNumChars+1)*sizeof(CIDs_buf[0]));
331
  if (!CIDs) {
339
  if (!CIDs) {
332
    NS_ERROR("Failed to alloc space for CIDs");
340
    NS_ERROR("Failed to alloc space for CIDs");
333
    goto done;
341
    goto done;
334
  }
342
  }
Lines 364-378 FT2SubsetToType8(FT_Face aFace, const PR Link Here
364
  WriteCmapHeader(cmapname, registry, encoding, supplement, cmap_type, aWmode,
372
  WriteCmapHeader(cmapname, registry, encoding, supplement, cmap_type, aWmode,
365
                  aFile);
373
                  aFile);
366
  WriteCodeSpaceRangeMapUCS2(aFile);
374
  WriteCodeSpaceRangeMapUCS2(aFile);
367
  WriteCidCharMap(aCharIDs, CIDs, aNumChars, aFile);
375
  WriteCidCharMap(aCharIDs, CIDs, aNumChars, aFile);
368
  WriteCmapFooter(aFile);
376
  WriteCmapFooter(aFile);
369
377
370
  /* output the Type 8 CID font */
378
  /* output the Type 8 CID font */
379
#ifdef MOZ_ENABLE_XFT
380
  FT2SubsetToCidKeyedType1(aFace, aCharIDs, aNumChars, fontname,
381
#else
371
  FT2SubsetToCidKeyedType1(ft2, aFace, aCharIDs, aNumChars, fontname,
382
  FT2SubsetToCidKeyedType1(ft2, aFace, aCharIDs, aNumChars, fontname,
383
#endif
372
                           registry, encoding, supplement, aWmode, lenIV,
384
                           registry, encoding, supplement, aWmode, lenIV,
373
                           aFile);
385
                           aFile);
374
  fprintf(aFile, "\n");
386
  fprintf(aFile, "\n");
375
387
376
  /* compose the cmap and font */
388
  /* compose the cmap and font */
377
  fprintf(aFile, "/%s\n", cidfontname);
389
  fprintf(aFile, "/%s\n", cidfontname);
378
  fprintf(aFile, "  /%s /CMap findresource\n", cmapname);
390
  fprintf(aFile, "  /%s /CMap findresource\n", cmapname);
Lines 388-402 done: Link Here
388
  PR_FREEIF(cidfontname);
400
  PR_FREEIF(cidfontname);
389
  if (CIDs != CIDs_buf)
401
  if (CIDs != CIDs_buf)
390
    PR_Free(CIDs);
402
    PR_Free(CIDs);
391
  return status;
403
  return status;
392
}
404
}
393
405
394
static PRBool
406
static PRBool
407
#ifdef MOZ_ENABLE_XFT
408
FT2SubsetToCidKeyedType1(FT_Face aFace,
409
#else
395
FT2SubsetToCidKeyedType1(nsIFreeType2 *aFt2, FT_Face aFace,
410
FT2SubsetToCidKeyedType1(nsIFreeType2 *aFt2, FT_Face aFace,
411
#endif
396
                         const PRUnichar *aCharIDs,
412
                         const PRUnichar *aCharIDs,
397
                         int aLen, const char *aFontName,
413
                         int aLen, const char *aFontName,
398
                         const char *aRegistry, const char *aEncoding,
414
                         const char *aRegistry, const char *aEncoding,
399
                         int aSupplement, int aWmode, int aLenIV, FILE *aFile)
415
                         int aSupplement, int aWmode, int aLenIV, FILE *aFile)
400
{
416
{
401
  int i, charstrings_len, data_offset;
417
  int i, charstrings_len, data_offset;
402
  unsigned int charstring_len;
418
  unsigned int charstring_len;
Lines 441-464 FT2SubsetToCidKeyedType1(nsIFreeType2 *a Link Here
441
                 toCS(upm, aFace->bbox.yMin),
457
                 toCS(upm, aFace->bbox.yMin),
442
                 toCS(upm, aFace->bbox.xMax),
458
                 toCS(upm, aFace->bbox.xMax),
443
                 toCS(upm, aFace->bbox.yMax));
459
                 toCS(upm, aFace->bbox.yMax));
444
460
445
  fprintf(aFile, "\n");
461
  fprintf(aFile, "\n");
446
462
447
  /* measure the notdef glyph length */
463
  /* measure the notdef glyph length */
464
#ifdef MOZ_ENABLE_XFT
465
  cmapinfo[0] = FT2GlyphToType1CharString(aFace, 0, aWmode, aLenIV, NULL);
466
#else
448
  cmapinfo[0] = FT2GlyphToType1CharString(aFt2, aFace, 0, aWmode, aLenIV, NULL);
467
  cmapinfo[0] = FT2GlyphToType1CharString(aFt2, aFace, 0, aWmode, aLenIV, NULL);
468
#endif
449
  num_charstrings = 1;
469
  num_charstrings = 1;
450
  charstrings_len = cmapinfo[0];
470
  charstrings_len = cmapinfo[0];
451
471
452
  /* get charstring lengths */
472
  /* get charstring lengths */
453
  max_charstring = cmapinfo[0];
473
  max_charstring = cmapinfo[0];
454
  for (i=0; i<aLen; i++) {
474
  for (i=0; i<aLen; i++) {
475
#ifdef MOZ_ENABLE_XFT
476
    glyphID = FT_Get_Char_Index(aFace, aCharIDs[i]);
477
    cmapinfo[i+1] = FT2GlyphToType1CharString(aFace, glyphID, aWmode,
478
                                              aLenIV, NULL);
479
#else
455
    aFt2->GetCharIndex(aFace, aCharIDs[i], &glyphID);
480
    aFt2->GetCharIndex(aFace, aCharIDs[i], &glyphID);
456
    cmapinfo[i+1] = FT2GlyphToType1CharString(aFt2, aFace, glyphID, aWmode,
481
    cmapinfo[i+1] = FT2GlyphToType1CharString(aFt2, aFace, glyphID, aWmode,
457
                                              aLenIV, NULL);
482
                                              aLenIV, NULL);
483
#endif
458
    charstrings_len += cmapinfo[i+1];
484
    charstrings_len += cmapinfo[i+1];
459
    if (cmapinfo[i+1])
485
    if (cmapinfo[i+1])
460
      num_charstrings++;
486
      num_charstrings++;
461
    if (cmapinfo[i+1] > max_charstring)
487
    if (cmapinfo[i+1] > max_charstring)
462
      max_charstring = cmapinfo[i+1];
488
      max_charstring = cmapinfo[i+1];
463
  }
489
  }
464
  cmapinfo[i+1] = 0;
490
  cmapinfo[i+1] = 0;
Lines 550-572 FT2SubsetToCidKeyedType1(nsIFreeType2 *a Link Here
550
    data_offset += cmapinfo[i];
576
    data_offset += cmapinfo[i];
551
  }
577
  }
552
578
553
  //
579
  //
554
  // output the charStrings
580
  // output the charStrings
555
  //
581
  //
556
  // output the notdef glyph
582
  // output the notdef glyph
583
#ifdef MOZ_ENABLE_XFT
584
  charstring_len = FT2GlyphToType1CharString(aFace, 0, aWmode, aLenIV,
585
                                             charstring);
586
#else
557
  charstring_len = FT2GlyphToType1CharString(aFt2, aFace, 0, aWmode, aLenIV,
587
  charstring_len = FT2GlyphToType1CharString(aFt2, aFace, 0, aWmode, aLenIV,
558
                                             charstring);
588
                                             charstring);
589
#endif
559
  hex_out(charstring, charstring_len, aFile, &line_pos);
590
  hex_out(charstring, charstring_len, aFile, &line_pos);
560
591
561
  /* output the charstrings for the glyphs */
592
  /* output the charstrings for the glyphs */
562
  for (i=0; i<aLen; i++) {
593
  for (i=0; i<aLen; i++) {
594
#ifdef MOZ_ENABLE_XFT
595
    glyphID = FT_Get_Char_Index(aFace, aCharIDs[i]);
596
    charstring_len = FT2GlyphToType1CharString(aFace, glyphID, aWmode,
597
                                               aLenIV, charstring);
598
#else
563
    aFt2->GetCharIndex(aFace, aCharIDs[i], &glyphID);
599
    aFt2->GetCharIndex(aFace, aCharIDs[i], &glyphID);
564
    charstring_len = FT2GlyphToType1CharString(aFt2, aFace, glyphID, aWmode,
600
    charstring_len = FT2GlyphToType1CharString(aFt2, aFace, glyphID, aWmode,
565
                                               aLenIV, charstring);
601
                                               aLenIV, charstring);
602
#endif
566
    NS_ASSERTION(charstring_len==cmapinfo[i+1], "glyph data changed");
603
    NS_ASSERTION(charstring_len==cmapinfo[i+1], "glyph data changed");
567
    hex_out(charstring, charstring_len, aFile, &line_pos);
604
    hex_out(charstring, charstring_len, aFile, &line_pos);
568
  }
605
  }
569
  // add one byte padding so the interperter can always do 2 byte reads
606
  // add one byte padding so the interperter can always do 2 byte reads
570
  charstring[0] = 0;
607
  charstring[0] = 0;
571
  hex_out(charstring, 1, aFile, &line_pos);
608
  hex_out(charstring, 1, aFile, &line_pos);
572
609
(-)gfx/src/ps/nsType8.h (+17 lines)
Lines 39-53 Link Here
39
 * ***** END LICENSE BLOCK ***** */
39
 * ***** END LICENSE BLOCK ***** */
40
40
41
#ifndef TYPE8_H
41
#ifndef TYPE8_H
42
#define TYPE8_H
42
#define TYPE8_H
43
43
44
#include <stdio.h>
44
#include <stdio.h>
45
#include "nspr.h"
45
#include "nspr.h"
46
#ifdef MOZ_ENABLE_XFT
47
#include <ft2build.h>
48
#include FT_FREETYPE_H
49
#include FT_GLYPH_H
50
#include FT_CACHE_H
51
#include FT_CACHE_IMAGE_H
52
#include FT_OUTLINE_H
53
// macros to handle FreeType2 26.6 numbers (26 bit number with 6 bit fraction)
54
#define FT_REG_TO_16_16(x) ((x)<<16)
55
#ifndef FT_MulFix
56
#define FT_MulFix(v, s) (((v)*(s))>>16)
57
#endif
58
#define FT_ROUND(x) (((x) + 32) & ~63) // 63 = 2^6 - 1
59
#define FT_TRUNC(x) ((x) >> 6)
60
#define FT_DESIGN_UNITS_TO_PIXELS(v, s) FT_TRUNC(FT_ROUND(FT_MulFix((v) , (s))))
61
#else /* MOZ_ENABLE_FREETYPE2 */
46
#include "nsIFreeType2.h"
62
#include "nsIFreeType2.h"
63
#endif /* MOZ_ENABLE_XFT */
47
64
48
void AddCIDCheckCode(FILE *aFile);
65
void AddCIDCheckCode(FILE *aFile);
49
PRBool FT2SubsetToType8(FT_Face aFace, const PRUnichar *aCharIDs,
66
PRBool FT2SubsetToType8(FT_Face aFace, const PRUnichar *aCharIDs,
50
                        PRUint32 aNumChars, int aWmode, FILE *aFile);
67
                        PRUint32 aNumChars, int aWmode, FILE *aFile);
51
char*  FT2ToType8CidFontName(FT_Face aFace, int aWmode);
68
char*  FT2ToType8CidFontName(FT_Face aFace, int aWmode);
52
69
53
70
(-)gfx/src/x11shared/nsFontDebug.h (+2 lines)
Lines 93-103 Link Here
93
                fflush(stdout); \
93
                fflush(stdout); \
94
              } \
94
              } \
95
            PR_END_MACRO
95
            PR_END_MACRO
96
96
97
#define FREETYPE_FONT_PRINTF(x) \
97
#define FREETYPE_FONT_PRINTF(x) \
98
         DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_FREETYPE_FONT)
98
         DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_FREETYPE_FONT)
99
99
100
#ifdef MOZ_ENABLE_FREETYPE2
100
extern PRUint32 gFontDebug;
101
extern PRUint32 gFontDebug;
102
#endif
101
103
102
#endif
104
#endif
103
105
(-)gfx/src/xlib/nsFontMetricsXlib.cpp (-25 / +181 lines)
Lines 60-77 Link Here
60
#include "nsCOMPtr.h"
60
#include "nsCOMPtr.h"
61
#include "nsPrintfCString.h"
61
#include "nsPrintfCString.h"
62
#include "nspr.h"
62
#include "nspr.h"
63
#include "nsHashtable.h"
63
#include "nsHashtable.h"
64
#include "nsReadableUtils.h"
64
#include "nsReadableUtils.h"
65
#include "nsAString.h"
65
#include "nsAString.h"
66
#include "nsXPIDLString.h"
66
#include "nsXPIDLString.h"
67
#ifdef USE_FREETYPE
67
#ifdef MOZ_ENABLE_FREETYPE2
68
#include "nsFT2FontCatalog.h"
68
#include "nsFT2FontCatalog.h"
69
#include "nsFreeType.h"
69
#include "nsFreeType.h"
70
#endif /* USE_FREETYPE */
70
#endif /* MOZ_ENABLE_FREETYPE2 */
71
#ifdef USE_X11SHARED_CODE
71
#ifdef USE_X11SHARED_CODE
72
#include "nsXFontNormal.h"
72
#include "nsXFontNormal.h"
73
#endif /* USE_X11SHARED_CODE */
73
#endif /* USE_X11SHARED_CODE */
74
#ifdef USE_AASB
74
#ifdef USE_AASB
75
#include "nsX11AlphaBlend.h"
75
#include "nsX11AlphaBlend.h"
76
#include "nsXFontAAScaledBitmap.h"
76
#include "nsXFontAAScaledBitmap.h"
77
#endif /* USE_AASB */
77
#endif /* USE_AASB */
Lines 109-125 static PRLogModuleInfo *FontMetricsXlibL Link Here
109
#define FONT_MAX_FONT_SCALE 2
109
#define FONT_MAX_FONT_SCALE 2
110
110
111
#undef NOISY_FONTS
111
#undef NOISY_FONTS
112
#undef REALLY_NOISY_FONTS
112
#undef REALLY_NOISY_FONTS
113
113
114
/* Local prototypes */
114
/* Local prototypes */
115
static PRBool                 FreeNode(nsHashKey* aKey, void* aData, void* aClosure);
115
static PRBool                 FreeNode(nsHashKey* aKey, void* aData, void* aClosure);
116
#ifdef USE_FREETYPE
116
#ifdef MOZ_ENABLE_FREETYPE2
117
static void                   CharSetNameToCodeRangeBits(const char*, PRUint32*, PRUint32*);
117
static void                   CharSetNameToCodeRangeBits(const char*, PRUint32*, PRUint32*);
118
#endif /* USE_FREETYPE */
118
#endif /* MOZ_ENABLE_FREETYPE2 */
119
static const nsFontCharSetMapXlib *GetCharSetMap(nsFontMetricsXlibContext *aFmctx, const char *aCharSetName);
119
static const nsFontCharSetMapXlib *GetCharSetMap(nsFontMetricsXlibContext *aFmctx, const char *aCharSetName);
120
120
121
// the font catalog is so expensive to generate
121
// the font catalog is so expensive to generate
122
// always tell the user what is happening
122
// always tell the user what is happening
123
static PRUint32 gFontDebug = 0 | NS_FONT_DEBUG_FONT_SCAN;
123
static PRUint32 gFontDebug = 0 | NS_FONT_DEBUG_FONT_SCAN;
124
124
125
struct nsFontCharSetMapXlib;
125
struct nsFontCharSetMapXlib;
Lines 211-229 public: Link Here
211
  double                                mBitmapUndersize;
211
  double                                mBitmapUndersize;
212
212
213
#ifdef USE_AASB
213
#ifdef USE_AASB
214
  PRInt32                               mAntiAliasMinimum;
214
  PRInt32                               mAntiAliasMinimum;
215
#endif /* USE_AASB */
215
#endif /* USE_AASB */
216
  PRInt32                               mEmbeddedBitmapMaximumHeight;
216
  PRInt32                               mEmbeddedBitmapMaximumHeight;
217
217
218
#ifdef USE_FREETYPE
218
#ifdef MOZ_ENABLE_FREETYPE2
219
  PRBool                                mEnableFreeType2;
219
  PRBool                                mEnableFreeType2;
220
  PRBool                                mFreeType2Autohinted;
220
  PRBool                                mFreeType2Autohinted;
221
  PRBool                                mFreeType2Unhinted;
221
  PRBool                                mFreeType2Unhinted;
222
#endif /* USE_FREETYPE */
222
#endif /* MOZ_ENABLE_FREETYPE2 */
223
#ifdef USE_AASB
223
#ifdef USE_AASB
224
  PRUint8                               mAATTDarkTextMinValue;
224
  PRUint8                               mAATTDarkTextMinValue;
225
  double                                mAATTDarkTextGain;
225
  double                                mAATTDarkTextGain;
226
#endif /* USE_AASB */
226
#endif /* USE_AASB */
227
227
228
#ifdef ENABLE_X_FONT_BANNING
228
#ifdef ENABLE_X_FONT_BANNING
229
  regex_t                              *mFontRejectRegEx,
229
  regex_t                              *mFontRejectRegEx,
Lines 232-247 public: Link Here
232
};
232
};
233
233
234
struct nsFontCharSetInfoXlib
234
struct nsFontCharSetInfoXlib
235
{
235
{
236
  const char*            mCharSet;
236
  const char*            mCharSet;
237
  nsFontCharSetConverterXlib Convert;
237
  nsFontCharSetConverterXlib Convert;
238
  PRUint8                mSpecialUnderline;
238
  PRUint8                mSpecialUnderline;
239
#ifdef MOZ_ENABLE_FREETYPE2
239
  PRInt32                mCodeRange1Bits;
240
  PRInt32                mCodeRange1Bits;
240
  PRInt32                mCodeRange2Bits;
241
  PRInt32                mCodeRange2Bits;
242
#endif
241
  PRUint16*              mCCMap;
243
  PRUint16*              mCCMap;
242
  nsIUnicodeEncoder*     mConverter;
244
  nsIUnicodeEncoder*     mConverter;
243
  nsIAtom*               mLangGroup;
245
  nsIAtom*               mLangGroup;
244
  PRBool                 mInitedSizeInfo;
246
  PRBool                 mInitedSizeInfo;
245
  PRInt32                mOutlineScaleMin;
247
  PRInt32                mOutlineScaleMin;
246
  PRInt32                mBitmapScaleMin;
248
  PRInt32                mBitmapScaleMin;
247
  double                 mBitmapOversize;
249
  double                 mBitmapOversize;
Lines 281-294 static int DoubleByteConvert(nsFontCharS Link Here
281
  const PRUnichar* aSrcBuf, PRInt32 aSrcLen, char* aDestBuf, PRInt32 aDestLen);
283
  const PRUnichar* aSrcBuf, PRInt32 aSrcLen, char* aDestBuf, PRInt32 aDestLen);
282
static int ISO10646Convert(nsFontCharSetInfoXlib* aSelf, XFontStruct* aFont,
284
static int ISO10646Convert(nsFontCharSetInfoXlib* aSelf, XFontStruct* aFont,
283
  const PRUnichar* aSrcBuf, PRInt32 aSrcLen, char* aDestBuf, PRInt32 aDestLen);
285
  const PRUnichar* aSrcBuf, PRInt32 aSrcLen, char* aDestBuf, PRInt32 aDestLen);
284
286
285
static nsFontCharSetInfoXlib Unknown = { nsnull };
287
static nsFontCharSetInfoXlib Unknown = { nsnull };
286
static nsFontCharSetInfoXlib Special = { nsnull };
288
static nsFontCharSetInfoXlib Special = { nsnull };
287
289
290
#ifdef MOZ_ENABLE_FREETYPE2
288
static nsFontCharSetInfoXlib USASCII =
291
static nsFontCharSetInfoXlib USASCII =
289
  { "us-ascii", SingleByteConvert, 0,
292
  { "us-ascii", SingleByteConvert, 0,
290
    TT_OS2_CPR1_LATIN1 | TT_OS2_CPR1_MAC_ROMAN,
293
    TT_OS2_CPR1_LATIN1 | TT_OS2_CPR1_MAC_ROMAN,
291
    TT_OS2_CPR2_CA_FRENCH |  TT_OS2_CPR2_PORTUGESE
294
    TT_OS2_CPR2_CA_FRENCH |  TT_OS2_CPR2_PORTUGESE
292
    | TT_OS2_CPR2_WE_LATIN1 |  TT_OS2_CPR2_US };
295
    | TT_OS2_CPR2_WE_LATIN1 |  TT_OS2_CPR2_US };
293
static nsFontCharSetInfoXlib ISO88591 =
296
static nsFontCharSetInfoXlib ISO88591 =
294
  { "ISO-8859-1", SingleByteConvert, 0,
297
  { "ISO-8859-1", SingleByteConvert, 0,
Lines 486-500 static nsFontCharSetInfoXlib Mathematica Link Here
486
   { "x-mathematica2", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
489
   { "x-mathematica2", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
487
static nsFontCharSetInfoXlib Mathematica3 =
490
static nsFontCharSetInfoXlib Mathematica3 =
488
   { "x-mathematica3", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
491
   { "x-mathematica3", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
489
static nsFontCharSetInfoXlib Mathematica4 =
492
static nsFontCharSetInfoXlib Mathematica4 =
490
   { "x-mathematica4", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
493
   { "x-mathematica4", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
491
static nsFontCharSetInfoXlib Mathematica5 =
494
static nsFontCharSetInfoXlib Mathematica5 =
492
   { "x-mathematica5", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
495
   { "x-mathematica5", SingleByteConvert, 0, TT_OS2_CPR1_SYMBOL, 0};
493
#endif /* MOZ_MATHML */
496
#endif /* MATHML */
497
498
#else
499
500
static nsFontCharSetInfoXlib USASCII =
501
  { "us-ascii", SingleByteConvert, 0 };
502
static nsFontCharSetInfoXlib ISO88591 =
503
  { "ISO-8859-1", SingleByteConvert, 0 };
504
static nsFontCharSetInfoXlib ISO88592 =
505
  { "ISO-8859-2", SingleByteConvert, 0 };
506
static nsFontCharSetInfoXlib ISO88593 =
507
  { "ISO-8859-3", SingleByteConvert, 0 };
508
static nsFontCharSetInfoXlib ISO88594 =
509
  { "ISO-8859-4", SingleByteConvert, 0 };
510
static nsFontCharSetInfoXlib ISO88595 =
511
  { "ISO-8859-5", SingleByteConvert, 0 };
512
static nsFontCharSetInfoXlib ISO88596 =
513
  { "ISO-8859-6", SingleByteConvert, 0 };
514
static nsFontCharSetInfoXlib ISO885968x =
515
  { "x-iso-8859-6-8-x", SingleByteConvert, 0 };
516
static nsFontCharSetInfoXlib ISO8859616 =
517
  { "x-iso-8859-6-16", SingleByteConvert, 0 };
518
static nsFontCharSetInfoXlib IBM1046 =
519
  { "x-IBM1046", SingleByteConvert, 0 };
520
static nsFontCharSetInfoXlib ISO88597 =
521
  { "ISO-8859-7", SingleByteConvert, 0 };
522
static nsFontCharSetInfoXlib ISO88598 =
523
  { "ISO-8859-8", SingleByteConvert, 0 };
524
// change from  
525
// { "ISO-8859-8", SingleByteConvertReverse, 0, 0, 0 };
526
// untill we fix the layout and ensure we only call this with pure RTL text
527
static nsFontCharSetInfoXlib ISO88599 =
528
  { "ISO-8859-9", SingleByteConvert, 0 };
529
// no support for iso-8859-10 (Nordic/Icelandic) currently
530
// static nsFontCharSetInfoXlib ISO885910 =
531
// { "ISO-8859-10", SingleByteConvert, 0,
532
//   0, TT_OS2_CPR2_NORDIC | TT_OS2_CPR2_ICELANDIC };
533
// no support for iso-8859-12 (Vietnamese) currently
534
// static nsFontCharSetInfoXlib ISO885912 =
535
// { "ISO-8859-12", SingleByteConvert, 0,
536
//   TT_OS2_CPR1_VIETNAMESE, 0 };
537
static nsFontCharSetInfoXlib ISO885913 =
538
  { "ISO-8859-13", SingleByteConvert, 0 };
539
static nsFontCharSetInfoXlib ISO885915 =
540
  { "ISO-8859-15", SingleByteConvert, 0 };
541
static nsFontCharSetInfoXlib JISX0201 =
542
  { "jis_0201", SingleByteConvert, 1 };
543
static nsFontCharSetInfoXlib KOI8R =
544
  { "KOI8-R", SingleByteConvert, 0 };
545
static nsFontCharSetInfoXlib KOI8U =
546
  { "KOI8-U", SingleByteConvert, 0 };
547
static nsFontCharSetInfoXlib TIS6202 =
548
/* Added to support thai context sensitive shaping if
549
 * CTL extension is is in force */
550
#ifdef SUNCTL
551
  { "tis620-2", SingleByteConvert, 0 };
552
#else
553
  { "windows-874", SingleByteConvert, 0 };
554
#endif /* SUNCTL */
555
static nsFontCharSetInfoXlib TIS620 =
556
  { "TIS-620", SingleByteConvert, 0 };
557
static nsFontCharSetInfoXlib ISO885911 =
558
  { "ISO-8859-11", SingleByteConvert, 0 };
559
static nsFontCharSetInfoXlib Big5 =
560
  { "x-x-big5", DoubleByteConvert, 1 };
561
// a kludge to distinguish zh-TW only fonts in Big5 (such as hpbig5-)
562
// from zh-TW/zh-HK common fonts in Big5 (such as big5-1)
563
static nsFontCharSetInfoXlib Big5TWHK =
564
  { "x-x-big5", DoubleByteConvert, 1 };
565
static nsFontCharSetInfoXlib CNS116431 =
566
  { "x-cns-11643-1", DoubleByteConvert, 1 };
567
static nsFontCharSetInfoXlib CNS116432 =
568
  { "x-cns-11643-2", DoubleByteConvert, 1 };
569
static nsFontCharSetInfoXlib CNS116433 =
570
  { "x-cns-11643-3", DoubleByteConvert, 1 };
571
static nsFontCharSetInfoXlib CNS116434 =
572
  { "x-cns-11643-4", DoubleByteConvert, 1 };
573
static nsFontCharSetInfoXlib CNS116435 =
574
  { "x-cns-11643-5", DoubleByteConvert, 1 };
575
static nsFontCharSetInfoXlib CNS116436 =
576
  { "x-cns-11643-6", DoubleByteConvert, 1 };
577
static nsFontCharSetInfoXlib CNS116437 =
578
  { "x-cns-11643-7", DoubleByteConvert, 1 };
579
static nsFontCharSetInfoXlib GB2312 =
580
  { "gb_2312-80", DoubleByteConvert, 1 };
581
static nsFontCharSetInfoXlib GB18030_0 =
582
  { "gb18030.2000-0", DoubleByteConvert, 1 };
583
static nsFontCharSetInfoXlib GB18030_1 =
584
  { "gb18030.2000-1", DoubleByteConvert, 1 };
585
static nsFontCharSetInfoXlib GBK =
586
  { "x-gbk-noascii", DoubleByteConvert, 1 };
587
static nsFontCharSetInfoXlib HKSCS =
588
  { "hkscs-1", DoubleByteConvert, 1 };
589
static nsFontCharSetInfoXlib JISX0208 =
590
  { "jis_0208-1983", DoubleByteConvert, 1 };
591
static nsFontCharSetInfoXlib JISX0212 =
592
  { "jis_0212-1990", DoubleByteConvert, 1 };
593
static nsFontCharSetInfoXlib KSC5601 =
594
  { "ks_c_5601-1987", DoubleByteConvert, 1 };
595
static nsFontCharSetInfoXlib X11Johab =
596
  { "x-x11johab", DoubleByteConvert, 1 };
597
static nsFontCharSetInfoXlib JohabNoAscii =
598
  { "x-johab-noascii", DoubleByteConvert, 1 };
599
static nsFontCharSetInfoXlib JamoTTF =
600
  { "x-koreanjamo-0", DoubleByteConvert, 1 };
601
static nsFontCharSetInfoXlib TamilTTF =
602
  { "x-tamilttf-0", DoubleByteConvert, 0 };
603
static nsFontCharSetInfoXlib CP1250 =
604
  { "windows-1250", SingleByteConvert, 0 };
605
static nsFontCharSetInfoXlib CP1251 =
606
  { "windows-1251", SingleByteConvert, 0 };
607
static nsFontCharSetInfoXlib CP1252 =
608
  { "windows-1252", SingleByteConvert, 0 };
609
static nsFontCharSetInfoXlib CP1253 =
610
  { "windows-1253", SingleByteConvert, 0 };
611
static nsFontCharSetInfoXlib CP1257 =
612
  { "windows-1257", SingleByteConvert, 0 };
613
614
#ifdef SUNCTL
615
/* Hindi range currently unsupported in FT2 range. Change TT* once we 
616
   arrive at a way to identify hindi */
617
static nsFontCharSetInfoXlib SunIndic =
618
  { "x-sun-unicode-india-0", DoubleByteConvert, 0 };
619
#endif /* SUNCTL */
620
621
static nsFontCharSetInfoXlib ISO106461 =
622
  { nsnull, ISO10646Convert, 1};
623
624
static nsFontCharSetInfoXlib AdobeSymbol =
625
   { "Adobe-Symbol-Encoding", SingleByteConvert, 0 };
626
static nsFontCharSetInfoXlib AdobeEuro =
627
  { "x-adobe-euro", SingleByteConvert, 0 };
628
         
629
#ifdef MOZ_MATHML
630
static nsFontCharSetInfoXlib CMCMEX =
631
   { "x-t1-cmex", SingleByteConvert, 0};
632
static nsFontCharSetInfoXlib CMCMSY =
633
   { "x-t1-cmsy", SingleByteConvert, 0};
634
static nsFontCharSetInfoXlib CMCMR =
635
   { "x-t1-cmr", SingleByteConvert, 0};
636
static nsFontCharSetInfoXlib CMCMMI =
637
   { "x-t1-cmmi", SingleByteConvert, 0};
638
static nsFontCharSetInfoXlib Mathematica1 =
639
   { "x-mathematica1", SingleByteConvert, 0};
640
static nsFontCharSetInfoXlib Mathematica2 =
641
   { "x-mathematica2", SingleByteConvert, 0}; 
642
static nsFontCharSetInfoXlib Mathematica3 =
643
   { "x-mathematica3", SingleByteConvert, 0};
644
static nsFontCharSetInfoXlib Mathematica4 =
645
   { "x-mathematica4", SingleByteConvert, 0}; 
646
static nsFontCharSetInfoXlib Mathematica5 =
647
   { "x-mathematica5", SingleByteConvert, 0};
648
#endif /* MATHML */
649
#endif /* FREETYPE2 */
494
650
495
static nsFontLangGroupXlib FLG_WESTERN = { "x-western",     nsnull };
651
static nsFontLangGroupXlib FLG_WESTERN = { "x-western",     nsnull };
496
static nsFontLangGroupXlib FLG_BALTIC  = { "x-baltic",      nsnull };
652
static nsFontLangGroupXlib FLG_BALTIC  = { "x-baltic",      nsnull };
497
static nsFontLangGroupXlib FLG_CE      = { "x-central-euro",nsnull };
653
static nsFontLangGroupXlib FLG_CE      = { "x-central-euro",nsnull };
498
static nsFontLangGroupXlib FLG_RUSSIAN = { "x-cyrillic",    nsnull };
654
static nsFontLangGroupXlib FLG_RUSSIAN = { "x-cyrillic",    nsnull };
499
static nsFontLangGroupXlib FLG_GREEK   = { "el",            nsnull };
655
static nsFontLangGroupXlib FLG_GREEK   = { "el",            nsnull };
500
static nsFontLangGroupXlib FLG_TURKISH = { "tr",            nsnull };
656
static nsFontLangGroupXlib FLG_TURKISH = { "tr",            nsnull };
Lines 1044-1060 FreeNodeArray(nsHashKey* aKey, void* aDa Link Here
1044
/* This is only required for the main display */
1200
/* This is only required for the main display */
1045
static nsFontMetricsXlibContext *global_fmctx = nsnull;
1201
static nsFontMetricsXlibContext *global_fmctx = nsnull;
1046
1202
1047
nsFontMetricsXlibContext::~nsFontMetricsXlibContext()
1203
nsFontMetricsXlibContext::~nsFontMetricsXlibContext()
1048
{
1204
{
1049
  PR_LOG(FontMetricsXlibLM, PR_LOG_DEBUG, ("# nsFontMetricsXlibContext destroy()\n"));
1205
  PR_LOG(FontMetricsXlibLM, PR_LOG_DEBUG, ("# nsFontMetricsXlibContext destroy()\n"));
1050
1206
1051
#ifdef USE_FREETYPE
1207
#ifdef MOZ_ENABLE_FREETYPE2
1052
  nsFreeTypeFreeGlobals();
1208
  nsFreeTypeFreeGlobals();
1053
#endif /* USE_FREETYPE */
1209
#endif /* MOZ_ENABLE_FREETYPE2 */
1054
1210
1055
#ifdef ENABLE_X_FONT_BANNING
1211
#ifdef ENABLE_X_FONT_BANNING
1056
  if (mFontRejectRegEx) {
1212
  if (mFontRejectRegEx) {
1057
    regfree(mFontRejectRegEx);
1213
    regfree(mFontRejectRegEx);
1058
    delete mFontRejectRegEx;
1214
    delete mFontRejectRegEx;
1059
  }
1215
  }
1060
  
1216
  
Lines 1176-1194 nsFontMetricsXlibContext::Init(nsIDevice Link Here
1176
  mBitmapUndersize = 0.8;
1332
  mBitmapUndersize = 0.8;
1177
1333
1178
#ifdef USE_AASB
1334
#ifdef USE_AASB
1179
  mAntiAliasMinimum = 8;
1335
  mAntiAliasMinimum = 8;
1180
#endif /* USE_AASB */
1336
#endif /* USE_AASB */
1181
  mEmbeddedBitmapMaximumHeight = 1000000;
1337
  mEmbeddedBitmapMaximumHeight = 1000000;
1182
1338
1183
#ifdef USE_FREETYPE
1339
#ifdef MOZ_ENABLE_FREETYPE2
1184
  mEnableFreeType2 = PR_TRUE;
1340
  mEnableFreeType2 = PR_TRUE;
1185
  mFreeType2Autohinted = PR_FALSE;
1341
  mFreeType2Autohinted = PR_FALSE;
1186
  mFreeType2Unhinted = PR_TRUE;
1342
  mFreeType2Unhinted = PR_TRUE;
1187
#endif /* USE_FREETYPE */
1343
#endif /* MOZ_ENABLE_FREETYPE2 */
1188
#ifdef USE_AASB
1344
#ifdef USE_AASB
1189
  mAATTDarkTextMinValue = 64;
1345
  mAATTDarkTextMinValue = 64;
1190
  mAATTDarkTextGain = 0.8;
1346
  mAATTDarkTextGain = 0.8;
1191
#endif /* USE_AASB */
1347
#endif /* USE_AASB */
1192
1348
1193
#ifdef ENABLE_X_FONT_BANNING
1349
#ifdef ENABLE_X_FONT_BANNING
1194
  mFontRejectRegEx = nsnull;
1350
  mFontRejectRegEx = nsnull;
Lines 1364-1378 nsFontMetricsXlibContext::Init(nsIDevice Link Here
1364
#ifdef USE_XPRINT
1520
#ifdef USE_XPRINT
1365
  }
1521
  }
1366
#endif /* USE_XPRINT */
1522
#endif /* USE_XPRINT */
1367
  if (NS_SUCCEEDED(rv)) {
1523
  if (NS_SUCCEEDED(rv)) {
1368
    mForceOutlineScaledFonts = force_outline_scaled_fonts;
1524
    mForceOutlineScaledFonts = force_outline_scaled_fonts;
1369
  }
1525
  }
1370
1526
1371
#ifdef USE_FREETYPE
1527
#ifdef MOZ_ENABLE_FREETYPE2
1372
  PRBool enable_freetype2 = PR_TRUE;
1528
  PRBool enable_freetype2 = PR_TRUE;
1373
  rv = mPref->GetBoolPref("font.FreeType2.enable", &enable_freetype2);
1529
  rv = mPref->GetBoolPref("font.FreeType2.enable", &enable_freetype2);
1374
  if (NS_SUCCEEDED(rv)) {
1530
  if (NS_SUCCEEDED(rv)) {
1375
    mEnableFreeType2 = enable_freetype2;
1531
    mEnableFreeType2 = enable_freetype2;
1376
    FREETYPE_FONT_PRINTF(("mEnableFreeType2 = %d", mEnableFreeType2));
1532
    FREETYPE_FONT_PRINTF(("mEnableFreeType2 = %d", mEnableFreeType2));
1377
  }
1533
  }
1378
1534
Lines 1385-1399 nsFontMetricsXlibContext::Init(nsIDevice Link Here
1385
1541
1386
  PRBool freetype2_unhinted = PR_TRUE;
1542
  PRBool freetype2_unhinted = PR_TRUE;
1387
  rv = mPref->GetBoolPref("font.FreeType2.unhinted", &freetype2_unhinted);
1543
  rv = mPref->GetBoolPref("font.FreeType2.unhinted", &freetype2_unhinted);
1388
  if (NS_SUCCEEDED(rv)) {
1544
  if (NS_SUCCEEDED(rv)) {
1389
    mFreeType2Unhinted = freetype2_unhinted;
1545
    mFreeType2Unhinted = freetype2_unhinted;
1390
    FREETYPE_FONT_PRINTF(("mFreeType2Unhinted = %d", mFreeType2Unhinted));
1546
    FREETYPE_FONT_PRINTF(("mFreeType2Unhinted = %d", mFreeType2Unhinted));
1391
  }
1547
  }
1392
#endif /* USE_FREETYPE */
1548
#endif /* MOZ_ENABLE_FREETYPE2 */
1393
1549
1394
#ifdef USE_AASB
1550
#ifdef USE_AASB
1395
  PRInt32 antialias_minimum = 8;
1551
  PRInt32 antialias_minimum = 8;
1396
  rv = mPref->GetIntPref("font.antialias.min", &antialias_minimum);
1552
  rv = mPref->GetIntPref("font.antialias.min", &antialias_minimum);
1397
  if (NS_SUCCEEDED(rv)) {
1553
  if (NS_SUCCEEDED(rv)) {
1398
    mAntiAliasMinimum = antialias_minimum;
1554
    mAntiAliasMinimum = antialias_minimum;
1399
    FREETYPE_FONT_PRINTF(("mAntiAliasMinimum = %d", mAntiAliasMinimum));
1555
    FREETYPE_FONT_PRINTF(("mAntiAliasMinimum = %d", mAntiAliasMinimum));
Lines 1581-1600 nsFontMetricsXlibContext::Init(nsIDevice Link Here
1581
      mFontAcceptRegEx = nsnull;
1737
      mFontAcceptRegEx = nsnull;
1582
      
1738
      
1583
      return NS_ERROR_INVALID_ARG;
1739
      return NS_ERROR_INVALID_ARG;
1584
    }    
1740
    }    
1585
  }
1741
  }
1586
#endif /* ENABLE_X_FONT_BANNING */
1742
#endif /* ENABLE_X_FONT_BANNING */
1587
1743
1588
#ifdef USE_FREETYPE
1744
#ifdef MOZ_ENABLE_FREETYPE2
1589
  rv = nsFreeTypeInitGlobals();
1745
  rv = nsFreeTypeInitGlobals();
1590
  if (NS_FAILED(rv)) {
1746
  if (NS_FAILED(rv)) {
1591
    return NS_ERROR_OUT_OF_MEMORY;
1747
    return NS_ERROR_OUT_OF_MEMORY;
1592
  }
1748
  }
1593
#endif /* USE_FREETYPE */
1749
#endif /* MOZ_ENABLE_FREETYPE2 */
1594
1750
1595
  return NS_OK;
1751
  return NS_OK;
1596
}
1752
}
1597
1753
1598
#ifdef USE_X11SHARED_CODE
1754
#ifdef USE_X11SHARED_CODE
1599
#error not implemented yet
1755
#error not implemented yet
1600
#else
1756
#else
Lines 1912-1926 NS_IMETHODIMP nsFontMetricsXlib::Destro Link Here
1912
}
2068
}
1913
2069
1914
void nsFontMetricsXlib::RealizeFont()
2070
void nsFontMetricsXlib::RealizeFont()
1915
{
2071
{
1916
  float f;
2072
  float f;
1917
  f = mDeviceContext->DevUnitsToAppUnits();
2073
  f = mDeviceContext->DevUnitsToAppUnits();
1918
2074
1919
#ifdef USE_FREETYPE
2075
#ifdef MOZ_ENABLE_FREETYPE2
1920
  if (mWesternFont->IsFreeTypeFont()) {
2076
  if (mWesternFont->IsFreeTypeFont()) {
1921
    nsFreeTypeFont *ft = (nsFreeTypeFont *)mWesternFont;
2077
    nsFreeTypeFont *ft = (nsFreeTypeFont *)mWesternFont;
1922
    if (!ft)
2078
    if (!ft)
1923
      return;
2079
      return;
1924
    // now that there are multiple font types (eg: core X fonts
2080
    // now that there are multiple font types (eg: core X fonts
1925
    // and TrueType fonts) there should be a common set of methods 
2081
    // and TrueType fonts) there should be a common set of methods 
1926
    // to get the metrics info from the font object. These methods
2082
    // to get the metrics info from the font object. These methods
Lines 1995-2009 void nsFontMetricsXlib::RealizeFont() Link Here
1995
    /* need better way to calculate this */
2151
    /* need better way to calculate this */
1996
    mStrikeoutOffset = NSToCoordRound(mXHeight / 2.0);
2152
    mStrikeoutOffset = NSToCoordRound(mXHeight / 2.0);
1997
    mStrikeoutSize = mUnderlineSize;
2153
    mStrikeoutSize = mUnderlineSize;
1998
2154
1999
    return;
2155
    return;
2000
#endif /* MOZ_ENABLE_FREETYPE2 */
2156
#endif /* MOZ_ENABLE_FREETYPE2 */
2001
  }
2157
  }
2002
#endif /* USE_FREETYPE */
2158
#endif /* MOZ_ENABLE_FREETYPE2 */
2003
  nsXFont *xFont = mWesternFont->GetXFont();
2159
  nsXFont *xFont = mWesternFont->GetXFont();
2004
  XFontStruct *fontInfo = xFont->GetXFontStruct();
2160
  XFontStruct *fontInfo = xFont->GetXFontStruct();
2005
  f = mDeviceContext->DevUnitsToAppUnits();
2161
  f = mDeviceContext->DevUnitsToAppUnits();
2006
2162
2007
  nscoord lineSpacing = nscoord((fontInfo->ascent + fontInfo->descent) * f);
2163
  nscoord lineSpacing = nscoord((fontInfo->ascent + fontInfo->descent) * f);
2008
  mEmHeight = PR_MAX(1, nscoord(mWesternFont->mSize * f));
2164
  mEmHeight = PR_MAX(1, nscoord(mWesternFont->mSize * f));
2009
  if (lineSpacing > mEmHeight) {
2165
  if (lineSpacing > mEmHeight) {
Lines 3006-3026 nsFontXlib::GetXFont(void) Link Here
3006
3162
3007
PRBool
3163
PRBool
3008
nsFontXlib::GetXFontIs10646(void)
3164
nsFontXlib::GetXFontIs10646(void)
3009
{
3165
{
3010
  return ((PRBool) (mCharSetInfo == mFontMetricsContext->mISO106461));
3166
  return ((PRBool) (mCharSetInfo == mFontMetricsContext->mISO106461));
3011
}
3167
}
3012
3168
3013
#ifdef USE_FREETYPE
3169
#ifdef MOZ_ENABLE_FREETYPE2
3014
PRBool
3170
PRBool
3015
nsFontXlib::IsFreeTypeFont(void)
3171
nsFontXlib::IsFreeTypeFont(void)
3016
{
3172
{
3017
  return PR_FALSE;
3173
  return PR_FALSE;
3018
}
3174
}
3019
#endif /* USE_FREETYPE */
3175
#endif /* MOZ_ENABLE_FREETYPE2 */
3020
3176
3021
MOZ_DECL_CTOR_COUNTER(nsFontXlib)
3177
MOZ_DECL_CTOR_COUNTER(nsFontXlib)
3022
3178
3023
nsFontXlib::nsFontXlib()
3179
nsFontXlib::nsFontXlib()
3024
{
3180
{
3025
  MOZ_COUNT_CTOR(nsFontXlib);
3181
  MOZ_COUNT_CTOR(nsFontXlib);
3026
}
3182
}
Lines 3650-3664 nsFontMetricsXlib::GetAASBBaseFont(nsFon Link Here
3650
}
3806
}
3651
#endif /* USE_AASB */
3807
#endif /* USE_AASB */
3652
3808
3653
nsFontXlib*
3809
nsFontXlib*
3654
nsFontMetricsXlib::PickASizeAndLoad(nsFontStretchXlib* aStretch,
3810
nsFontMetricsXlib::PickASizeAndLoad(nsFontStretchXlib* aStretch,
3655
  nsFontCharSetInfoXlib* aCharSet, PRUnichar aChar, const char *aName)
3811
  nsFontCharSetInfoXlib* aCharSet, PRUnichar aChar, const char *aName)
3656
{
3812
{
3657
#ifdef USE_FREETYPE
3813
#ifdef MOZ_ENABLE_FREETYPE2
3658
  if (aStretch->mFreeTypeFaceID) {
3814
  if (aStretch->mFreeTypeFaceID) {
3659
    //FREETYPE_FONT_PRINTF(("mFreeTypeFaceID = 0x%p", aStretch->mFreeTypeFaceID));
3815
    //FREETYPE_FONT_PRINTF(("mFreeTypeFaceID = 0x%p", aStretch->mFreeTypeFaceID));
3660
    nsFreeTypeFont *ftfont = nsFreeTypeFont::NewFont(aStretch->mFreeTypeFaceID,
3816
    nsFreeTypeFont *ftfont = nsFreeTypeFont::NewFont(aStretch->mFreeTypeFaceID,
3661
                                                     mPixelSize,
3817
                                                     mPixelSize,
3662
                                                     aName);
3818
                                                     aName);
3663
    if (!ftfont) {
3819
    if (!ftfont) {
3664
      FREETYPE_FONT_PRINTF(("failed to create font"));
3820
      FREETYPE_FONT_PRINTF(("failed to create font"));
Lines 3678-3692 nsFontMetricsXlib::PickASizeAndLoad(nsFo Link Here
3678
    SetCharsetLangGroup(mFontMetricsContext, aCharSet);
3834
    SetCharsetLangGroup(mFontMetricsContext, aCharSet);
3679
    ftfont->mSize = mPixelSize;
3835
    ftfont->mSize = mPixelSize;
3680
    ftfont->LoadFont();
3836
    ftfont->LoadFont();
3681
    ftfont->mCharSetInfo = mFontMetricsContext->mISO106461;
3837
    ftfont->mCharSetInfo = mFontMetricsContext->mISO106461;
3682
    //FREETYPE_FONT_PRINTF(("add the ftfont"));
3838
    //FREETYPE_FONT_PRINTF(("add the ftfont"));
3683
    return AddToLoadedFontsList(ftfont);
3839
    return AddToLoadedFontsList(ftfont);
3684
  }
3840
  }
3685
#endif /* USE_FREETYPE */
3841
#endif /* MOZ_ENABLE_FREETYPE2 */
3686
3842
3687
  PRBool      use_scaled_font               = PR_FALSE;
3843
  PRBool      use_scaled_font               = PR_FALSE;
3688
  PRBool      have_nearly_rightsized_bitmap = PR_FALSE;
3844
  PRBool      have_nearly_rightsized_bitmap = PR_FALSE;
3689
#ifdef USE_AASB
3845
#ifdef USE_AASB
3690
  nsFontXlib *base_aafont                   = nsnull;
3846
  nsFontXlib *base_aafont                   = nsnull;
3691
#endif /* USE_AASB */
3847
#endif /* USE_AASB */
3692
3848
Lines 4494-4511 GetFontNames(nsFontMetricsXlibContext *a Link Here
4494
4650
4495
#ifdef NS_FONT_DEBUG_CALL_TRACE
4651
#ifdef NS_FONT_DEBUG_CALL_TRACE
4496
  if (gFontDebug & NS_FONT_DEBUG_CALL_TRACE) {
4652
  if (gFontDebug & NS_FONT_DEBUG_CALL_TRACE) {
4497
    printf("GetFontNames %s\n", aPattern);
4653
    printf("GetFontNames %s\n", aPattern);
4498
  }
4654
  }
4499
#endif
4655
#endif
4500
4656
4501
#ifdef USE_FREETYPE
4657
#ifdef MOZ_ENABLE_FREETYPE2
4502
  // get FreeType fonts
4658
  // get FreeType fonts
4503
  nsFT2FontCatalog::GetFontNames(aFmctx, aPattern, aNodes);
4659
  nsFT2FontCatalog::GetFontNames(aFmctx, aPattern, aNodes);
4504
#endif /* USE_FREETYPE */
4660
#endif /* MOZ_ENABLE_FREETYPE2 */
4505
4661
4506
  nsCAutoString previousNodeName;
4662
  nsCAutoString previousNodeName;
4507
  nsHashtable* node_hash;
4663
  nsHashtable* node_hash;
4508
  if (aAnyFoundry) {
4664
  if (aAnyFoundry) {
4509
    NS_ASSERTION(aPattern[1] == '*', "invalid 'anyFoundry' pattern");
4665
    NS_ASSERTION(aPattern[1] == '*', "invalid 'anyFoundry' pattern");
4510
    node_hash = &aFmctx->mAFRENodes;
4666
    node_hash = &aFmctx->mAFRENodes;
4511
  }
4667
  }
Lines 5892-5911 const nsFontCharSetMapXlib *GetCharSetMa Link Here
5892
  nsCStringKey charSetKey(aCharSetName);
6048
  nsCStringKey charSetKey(aCharSetName);
5893
  const nsFontCharSetMapXlib* charSetMap = (const nsFontCharSetMapXlib *) aFmctx->mCharSetMaps.Get(&charSetKey);
6049
  const nsFontCharSetMapXlib* charSetMap = (const nsFontCharSetMapXlib *) aFmctx->mCharSetMaps.Get(&charSetKey);
5894
  if (!charSetMap)
6050
  if (!charSetMap)
5895
    charSetMap = aFmctx->mNoneCharSetMap;
6051
    charSetMap = aFmctx->mNoneCharSetMap;
5896
  return charSetMap;
6052
  return charSetMap;
5897
}
6053
}
5898
6054
5899
#ifdef USE_FREETYPE
6055
#ifdef MOZ_ENABLE_FREETYPE2
5900
static
6056
static
5901
void CharSetNameToCodeRangeBits(const char *aCharset,
6057
void CharSetNameToCodeRangeBits(const char *aCharset,
5902
                                PRUint32 *aCodeRange1, PRUint32 *aCodeRange2)
6058
                                PRUint32 *aCodeRange1, PRUint32 *aCodeRange2)
5903
{
6059
{
5904
  nsFontCharSetMapXlib  *charSetMap  = GetCharSetMap(aFmctx, aCharset);
6060
  nsFontCharSetMapXlib  *charSetMap  = GetCharSetMap(aFmctx, aCharset);
5905
  nsFontCharSetInfoXlib *charSetInfo = charSetMap->mInfo;
6061
  nsFontCharSetInfoXlib *charSetInfo = charSetMap->mInfo;
5906
6062
5907
  *aCodeRange1 = charSetInfo->mCodeRange1Bits;
6063
  *aCodeRange1 = charSetInfo->mCodeRange1Bits;
5908
  *aCodeRange2 = charSetInfo->mCodeRange2Bits;
6064
  *aCodeRange2 = charSetInfo->mCodeRange2Bits;
5909
}
6065
}
5910
#endif /* USE_FREETYPE */
6066
#endif /* MOZ_ENABLE_FREETYPE2 */
5911
6067
(-)gfx/src/xlib/nsFontMetricsXlib.h (-9 / +9 lines)
Lines 52-66 Link Here
52
#include "nsCRT.h"
52
#include "nsCRT.h"
53
#include "nsCOMPtr.h"
53
#include "nsCOMPtr.h"
54
#include "nsRenderingContextXlib.h"
54
#include "nsRenderingContextXlib.h"
55
#include "nsICharRepresentable.h"
55
#include "nsICharRepresentable.h"
56
#include "nsCompressedCharMap.h"
56
#include "nsCompressedCharMap.h"
57
57
58
/* Undefine some CPP symbols which wrap not-yet-implemented code */
58
/* Undefine some CPP symbols which wrap not-yet-implemented code */
59
#undef USE_FREETYPE
59
#undef MOZ_ENABLE_FREETYPE2
60
#undef USE_AASB
60
#undef USE_AASB
61
#undef USE_X11SHARED_CODE
61
#undef USE_X11SHARED_CODE
62
62
63
#ifdef USE_X11SHARED_CODE
63
#ifdef USE_X11SHARED_CODE
64
/* XXX: I wish I would use the code in gfx/src/x11shared/ - unfortunately
64
/* XXX: I wish I would use the code in gfx/src/x11shared/ - unfortunately
65
 * it is full of GDK/GTK+ dependices which makes it impossible to use it
65
 * it is full of GDK/GTK+ dependices which makes it impossible to use it
66
 * yet... ;-(
66
 * yet... ;-(
Lines 183-216 struct nsFontCharSetXlib; Link Here
183
struct nsFontFamilyXlib;
183
struct nsFontFamilyXlib;
184
struct nsFontNodeXlib;
184
struct nsFontNodeXlib;
185
struct nsFontStretchXlib;
185
struct nsFontStretchXlib;
186
struct nsFontWeightXlib;
186
struct nsFontWeightXlib;
187
187
188
class nsFontXlibUserDefined;
188
class nsFontXlibUserDefined;
189
class nsFontMetricsXlib;
189
class nsFontMetricsXlib;
190
#ifdef USE_FREETYPE
190
#ifdef MOZ_ENABLE_FREETYPE2
191
class nsFreeTypeFace;
191
class nsFreeTypeFace;
192
#endif /* USE_FREETYPE */
192
#endif /* MOZ_ENABLE_FREETYPE2 */
193
193
194
struct nsFontStretchXlib
194
struct nsFontStretchXlib
195
{
195
{
196
  NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
196
  NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
197
197
198
  void SortSizes(void);
198
  void SortSizes(void);
199
199
200
  nsFontXlib       **mSizes;
200
  nsFontXlib       **mSizes;
201
  PRUint16           mSizesAlloc;
201
  PRUint16           mSizesAlloc;
202
  PRUint16           mSizesCount;
202
  PRUint16           mSizesCount;
203
203
204
  char*              mScalable;
204
  char*              mScalable;
205
  PRBool             mOutlineScaled;
205
  PRBool             mOutlineScaled;
206
  nsVoidArray        mScaledFonts;
206
  nsVoidArray        mScaledFonts;
207
#ifdef USE_FREETYPE
207
#ifdef MOZ_ENABLE_FREETYPE2
208
  nsFreeTypeFace    *mFreeTypeFaceID;
208
  nsFreeTypeFace    *mFreeTypeFaceID;
209
#endif /* USE_FREETYPE */
209
#endif /* MOZ_ENABLE_FREETYPE2 */
210
};
210
};
211
211
212
struct nsFontStyleXlib
212
struct nsFontStyleXlib
213
{
213
{
214
  NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
214
  NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
215
215
216
  void FillWeightHoles(void);
216
  void FillWeightHoles(void);
Lines 285-301 public: Link Here
285
285
286
  inline int SupportsChar(PRUnichar aChar)
286
  inline int SupportsChar(PRUnichar aChar)
287
    { return mCCMap && CCMAP_HAS_CHAR(mCCMap, aChar); };
287
    { return mCCMap && CCMAP_HAS_CHAR(mCCMap, aChar); };
288
288
289
  virtual XFontStruct *GetXFontStruct(void);
289
  virtual XFontStruct *GetXFontStruct(void);
290
  virtual nsXFont     *GetXFont(void);
290
  virtual nsXFont     *GetXFont(void);
291
  virtual PRBool       GetXFontIs10646(void);
291
  virtual PRBool       GetXFontIs10646(void);
292
#ifdef USE_FREETYPE
292
#ifdef MOZ_ENABLE_FREETYPE2
293
  virtual PRBool       IsFreeTypeFont(void);
293
  virtual PRBool       IsFreeTypeFont(void);
294
#endif /* USE_FREETYPE */
294
#endif /* MOZ_ENABLE_FREETYPE2 */
295
  virtual int          GetWidth(const PRUnichar* aString, PRUint32 aLength) = 0;
295
  virtual int          GetWidth(const PRUnichar* aString, PRUint32 aLength) = 0;
296
  virtual int          DrawString(nsRenderingContextXlib *aContext,
296
  virtual int          DrawString(nsRenderingContextXlib *aContext,
297
                                  nsIDrawingSurfaceXlib *aSurface, nscoord aX,
297
                                  nsIDrawingSurfaceXlib *aSurface, nscoord aX,
298
                                  nscoord aY, const PRUnichar* aString,
298
                                  nscoord aY, const PRUnichar* aString,
299
                                  PRUint32 aLength) = 0;
299
                                  PRUint32 aLength) = 0;
300
#ifdef MOZ_MATHML
300
#ifdef MOZ_MATHML
301
  // bounding metrics for a string 
301
  // bounding metrics for a string 
Lines 472-486 public: Link Here
472
472
473
class nsHashKey;
473
class nsHashKey;
474
474
475
/* XXX: We can't include gfx/src/x11shared/nsFreeType.h because it relies on
475
/* XXX: We can't include gfx/src/x11shared/nsFreeType.h because it relies on
476
 * GDK/GTK+ includes which are not available in Xlib builds (fix is to remove
476
 * GDK/GTK+ includes which are not available in Xlib builds (fix is to remove
477
 * the GDK/GTK+ dependicy from the code in gfx/src/x11shared/ ...)
477
 * the GDK/GTK+ dependicy from the code in gfx/src/x11shared/ ...)
478
 */
478
 */
479
#ifndef USE_FREETYPE
479
#ifndef MOZ_ENABLE_FREETYPE2
480
/*
480
/*
481
 * Defines for the TrueType codepage bits.
481
 * Defines for the TrueType codepage bits.
482
 * Used as a hint for the languages supported in a TrueType font.
482
 * Used as a hint for the languages supported in a TrueType font.
483
 */
483
 */
484
484
485
/*
485
/*
486
 * ulCodePageRange1
486
 * ulCodePageRange1
Lines 521-531 class nsHashKey; Link Here
521
#define TT_OS2_CPR2_CYRILLIC     (0x02000000)/*IBM Cyrillic; primarily Russian*/
521
#define TT_OS2_CPR2_CYRILLIC     (0x02000000)/*IBM Cyrillic; primarily Russian*/
522
#define TT_OS2_CPR2_LATIN2       (0x04000000) /* Latin 2                     */
522
#define TT_OS2_CPR2_LATIN2       (0x04000000) /* Latin 2                     */
523
#define TT_OS2_CPR2_BALTIC       (0x08000000) /* MS-DOS Baltic               */
523
#define TT_OS2_CPR2_BALTIC       (0x08000000) /* MS-DOS Baltic               */
524
#define TT_OS2_CPR2_GREEK_437G   (0x10000000) /* Greek; former 437 G         */
524
#define TT_OS2_CPR2_GREEK_437G   (0x10000000) /* Greek; former 437 G         */
525
#define TT_OS2_CPR2_ARABIC_708   (0x20000000) /* Arabic; ASMO 708            */
525
#define TT_OS2_CPR2_ARABIC_708   (0x20000000) /* Arabic; ASMO 708            */
526
#define TT_OS2_CPR2_WE_LATIN1    (0x40000000) /* WE/Latin 1                  */
526
#define TT_OS2_CPR2_WE_LATIN1    (0x40000000) /* WE/Latin 1                  */
527
#define TT_OS2_CPR2_US           (0x80000000) /* US                          */
527
#define TT_OS2_CPR2_US           (0x80000000) /* US                          */
528
#endif /* !USE_FREETYPE */
528
#endif /* !MOZ_ENABLE_FREETYPE2 */
529
529
530
#endif /* !nsFontMetricsXlib_h__ */
530
#endif /* !nsFontMetricsXlib_h__ */
531
531
(-)gfx/src/shared/Makefile.in (+5 lines)
Lines 50-59 CPPSRCS = \ Link Here
50
50
51
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
51
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
52
CPPSRCS += nsNativeTheme.cpp
52
CPPSRCS += nsNativeTheme.cpp
53
endif
53
endif
54
54
55
LOCAL_INCLUDES = -I$(srcdir)/.. \
55
LOCAL_INCLUDES = -I$(srcdir)/.. \
56
                 $(NULL)
56
                 $(NULL)
57
  
58
ifdef MOZ_ENABLE_XFT
59
CPPSRCS += nsFontConfigUtils.cpp
60
LOCAL_INCLUDES += $(MOZ_XFT_CFLAGS)
61
endif
57
62
58
include $(topsrcdir)/config/rules.mk
63
include $(topsrcdir)/config/rules.mk
59
64
(-)gfx/src/shared/nsFontConfigUtils.cpp (+227 lines)
Added Link Here
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 *
5
 * The contents of this file are subject to the Mozilla Public License Version
6
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 * the License. You may obtain a copy of the License at
8
 * http://www.mozilla.org/MPL/
9
 *
10
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 * for the specific language governing rights and limitations under the
13
 * License.
14
 *
15
 * The Original Code is mozilla.org code.
16
 *
17
 * The Initial Developer of the Original Code is Christopher Blizzard
18
 * <blizzard@mozilla.org>.  Portions created by the Initial Developer
19
 * are Copyright (C) 2002 the Initial Developer. All Rights Reserved.
20
 *
21
 * Contributor(s):
22
 *
23
 * Alternatively, the contents of this file may be used under the terms of
24
 * either of the GNU General Public License Version 2 or later (the "GPL"),
25
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
 * in which case the provisions of the GPL or the LGPL are applicable instead
27
 * of those above. If you wish to allow use of your version of this file only
28
 * under the terms of either the GPL or the LGPL, and not to allow others to
29
 * use your version of this file under the terms of the MPL, indicate your
30
 * decision by deleting the provisions above and replace them with the notice
31
 * and other provisions required by the GPL or the LGPL. If you do not delete
32
 * the provisions above, a recipient may use your version of this file under
33
 * the terms of any one of the MPL, the GPL or the LGPL.
34
 *
35
 * ***** END LICENSE BLOCK ***** */
36
37
#include "nsFontConfigUtils.h"
38
39
struct MozXftLangGroup {
40
    const char    *mozLangGroup;
41
    FcChar32       character;
42
    const FcChar8 *XftLang;
43
};
44
45
const MozXftLangGroup MozXftLangGroups[] = {
46
    { "x-western",      0x0041, (const FcChar8 *)"en" },
47
    { "x-central-euro", 0x0100, (const FcChar8 *)"pl" },
48
    { "x-cyrillic",     0x0411, (const FcChar8 *)"ru" },
49
    { "x-baltic",       0x0104, (const FcChar8 *)"lv" },
50
    { "x-devanagari",   0x0905, (const FcChar8 *)"hi" },
51
    { "x-tamil",        0x0B85, (const FcChar8 *)"ta" },
52
    { "x-unicode",      0x0000,                  0    },
53
    { "x-user-def",     0x0000,                  0    },
54
};
55
56
#define NUM_XFT_LANG_GROUPS (sizeof (MozXftLangGroups) / \
57
                             sizeof (MozXftLangGroups[0]))
58
59
static 
60
void FFREToFamily(nsACString &aFFREName, nsACString &oFamily);
61
62
static
63
const MozXftLangGroup*
64
FindFCLangGroup (nsACString &aLangGroup)
65
{
66
    for (unsigned int i=0; i < NUM_XFT_LANG_GROUPS; ++i) {
67
        if (aLangGroup.Equals(MozXftLangGroups[i].mozLangGroup,
68
                              nsCaseInsensitiveCStringComparator())) {
69
            return &MozXftLangGroups[i];
70
        }
71
    }
72
73
    return nsnull;
74
}
75
76
int
77
NS_CalculateSlant(PRUint8 aStyle)
78
{
79
    int fcSlant;
80
81
    switch(aStyle) {
82
    case NS_FONT_STYLE_ITALIC:
83
        fcSlant = FC_SLANT_ITALIC;
84
        break;
85
    case NS_FONT_STYLE_OBLIQUE:
86
        fcSlant = FC_SLANT_OBLIQUE;
87
        break;
88
    default:
89
        fcSlant = FC_SLANT_ROMAN;
90
        break;
91
    }
92
93
    return fcSlant;
94
}
95
96
int
97
NS_CalculateWeight (PRUint16 aWeight)
98
{
99
    /*
100
     * weights come in two parts crammed into one
101
     * integer -- the "base" weight is weight / 100,
102
     * the rest of the value is the "offset" from that
103
     * weight -- the number of steps to move to adjust
104
     * the weight in the list of supported font weights,
105
     * this value can be negative or positive.
106
     */
107
    PRInt32 baseWeight = (aWeight + 50) / 100;
108
    PRInt32 offset = aWeight - baseWeight * 100;
109
110
    /* clip weights to range 0 to 9 */
111
    if (baseWeight < 0)
112
        baseWeight = 0;
113
    if (baseWeight > 9)
114
        baseWeight = 9;
115
116
    /* Map from weight value to fcWeights index */
117
    static int fcWeightLookup[10] = {
118
        0, 0, 0, 0, 1, 1, 2, 3, 3, 4,
119
    };
120
121
    PRInt32 fcWeight = fcWeightLookup[baseWeight];
122
123
    /*
124
     * adjust by the offset value, make sure we stay inside the
125
     * fcWeights table
126
     */
127
    fcWeight += offset;
128
    if (fcWeight < 0)
129
        fcWeight = 0;
130
    if (fcWeight > 4)
131
        fcWeight = 4;
132
133
    /* Map to final FC_WEIGHT value */
134
    static int fcWeights[5] = {
135
        FC_WEIGHT_LIGHT,      /* 0 */
136
        FC_WEIGHT_MEDIUM,     /* 1 */
137
        FC_WEIGHT_DEMIBOLD,   /* 2 */
138
        FC_WEIGHT_BOLD,       /* 3 */
139
        FC_WEIGHT_BLACK,      /* 4 */
140
    };
141
142
    return fcWeights[fcWeight];
143
}
144
145
void
146
NS_AddLangGroup(FcPattern *aPattern, nsIAtom *aLangGroup)
147
{
148
    // Find the FC lang group for this lang group
149
    nsCAutoString cname;
150
    aLangGroup->ToUTF8String(cname);
151
152
    // see if the lang group needs to be translated from mozilla's
153
    // internal mapping into fontconfig's
154
    const struct MozXftLangGroup *langGroup;
155
    langGroup = FindFCLangGroup(cname);
156
157
    // if there's no lang group, just use the lang group as it was
158
    // passed to us
159
    //
160
    // we're casting away the const here for the strings - should be
161
    // safe.
162
    if (!langGroup)
163
        FcPatternAddString(aPattern, FC_LANG, (FcChar8 *)cname.get());
164
    else if (langGroup->XftLang)
165
        FcPatternAddString(aPattern, FC_LANG, (FcChar8 *)langGroup->XftLang);
166
}
167
168
void
169
NS_AddFFRE(FcPattern *aPattern, nsCString *aFamily, PRBool aWeak)
170
{
171
    nsCAutoString family;
172
    FFREToFamily(*aFamily, family);
173
174
    FcValue v;
175
    v.type = FcTypeString;
176
    // casting away the const here, should be safe
177
    v.u.s = (FcChar8 *)family.get();
178
179
    if (aWeak)
180
        FcPatternAddWeak(aPattern, FC_FAMILY, v, FcTrue);
181
    else
182
        FcPatternAdd(aPattern, FC_FAMILY, v, FcTrue);
183
}
184
185
/* static */
186
void
187
FFREToFamily(nsACString &aFFREName, nsACString &oFamily)
188
{
189
  if (NS_FFRECountHyphens(aFFREName) == 3) {
190
      PRInt32 familyHyphen = aFFREName.FindChar('-') + 1;
191
      PRInt32 registryHyphen = aFFREName.FindChar('-',familyHyphen);
192
      oFamily.Append(Substring(aFFREName, familyHyphen,
193
                               registryHyphen-familyHyphen));
194
  }
195
  else {
196
      oFamily.Append(aFFREName);
197
  }
198
}
199
200
int
201
NS_FFRECountHyphens (nsACString &aFFREName)
202
{
203
    int h = 0;
204
    PRInt32 hyphen = 0;
205
    while ((hyphen = aFFREName.FindChar('-', hyphen)) >= 0) {
206
        ++h;
207
        ++hyphen;
208
    }
209
    return h;
210
}
211
212
PRBool
213
NS_IsASCIIFontName(const nsString& aName)
214
{
215
    PRUint32 len = aName.Length();
216
    const PRUnichar* str = aName.get();
217
    for (PRUint32 i = 0; i < len; i++) {
218
        /*
219
         * X font names are printable ASCII, ignore others (for now)
220
         */
221
        if ((str[i] < 0x20) || (str[i] > 0x7E)) {
222
            return PR_FALSE;
223
        }
224
    }
225
226
    return PR_TRUE;
227
}
(-)gfx/src/shared/nsFontConfigUtils.h (+55 lines)
Added Link Here
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
 *
5
 * The contents of this file are subject to the Mozilla Public License Version
6
 * 1.1 (the "License"); you may not use this file except in compliance with
7
 * the License. You may obtain a copy of the License at
8
 * http://www.mozilla.org/MPL/
9
 *
10
 * Software distributed under the License is distributed on an "AS IS" basis,
11
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
 * for the specific language governing rights and limitations under the
13
 * License.
14
 *
15
 * The Original Code is mozilla.org code.
16
 *
17
 * The Initial Developer of the Original Code is Christopher Blizzard
18
 * <blizzard@mozilla.org>.  Portions created by the Initial Developer
19
 * are Copyright (C) 2002 the Initial Developer. All Rights Reserved.
20
 *
21
 * Contributor(s):
22
 *
23
 * Alternatively, the contents of this file may be used under the terms of
24
 * either of the GNU General Public License Version 2 or later (the "GPL"),
25
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
 * in which case the provisions of the GPL or the LGPL are applicable instead
27
 * of those above. If you wish to allow use of your version of this file only
28
 * under the terms of either the GPL or the LGPL, and not to allow others to
29
 * use your version of this file under the terms of the MPL, indicate your
30
 * decision by deleting the provisions above and replace them with the notice
31
 * and other provisions required by the GPL or the LGPL. If you do not delete
32
 * the provisions above, a recipient may use your version of this file under
33
 * the terms of any one of the MPL, the GPL or the LGPL.
34
 *
35
 * ***** END LICENSE BLOCK ***** */
36
37
#ifndef nsFontConfigUtils_h__
38
#define nsFontConfigUtils_h__
39
40
#include "nspr.h"
41
#include "nsString.h"
42
#include "nsIAtom.h"
43
#include "nsFont.h"
44
45
#include <fontconfig/fontconfig.h>
46
47
extern int     NS_CalculateSlant   (PRUint8  aStyle);
48
extern int     NS_CalculateWeight  (PRUint16 aWeight);
49
extern void    NS_AddLangGroup     (FcPattern *aPattern, nsIAtom *aLangGroup);
50
extern void    NS_AddFFRE          (FcPattern *aPattern, nsCString *aFamily,
51
                                    PRBool aWeak);
52
extern int     NS_FFRECountHyphens (nsACString &aFFREName);
53
extern PRBool  NS_IsASCIIFontName  (const nsString& aName);
54
#endif
55

Return to bug 6151