1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
/* vim:expandtab:shiftwidth=4:tabstop=4:
4
/* ***** BEGIN LICENSE BLOCK *****
5
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
7
* The contents of this file are subject to the Mozilla Public License Version
8
* 1.1 (the "License"); you may not use this file except in compliance with
9
* the License. You may obtain a copy of the License at
10
* http://www.mozilla.org/MPL/
12
* Software distributed under the License is distributed on an "AS IS" basis,
13
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14
* for the specific language governing rights and limitations under the
17
* The Original Code is mozilla.org code.
19
* The Initial Developer of the Original Code Christopher Blizzard
20
* <blizzard@mozilla.org>. Portions created by the Initial Developer
21
* are Copyright (C) 2002 the Initial Developer. All Rights Reserved.
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the MPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the MPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
39
// welcome to the dumping ground for font metrics stuff that has to
40
// know about both the xft and core fonts code.
43
#include "nsFontMetricsXft.h"
45
#include "nsIServiceManagerUtils.h"
47
#endif /* MOZ_ENABLE_XFT */
49
#ifdef MOZ_ENABLE_COREXFONTS
50
#include "nsFontMetricsGTK.h"
53
#include "nsFontMetricsUtils.h"
56
NS_FontMetricsGetHints(void)
59
if (NS_IsXftEnabled()) {
60
return nsFontMetricsXft::GetHints();
64
#ifdef MOZ_ENABLE_COREXFONTS
65
return nsFontMetricsGTK::GetHints();
70
NS_FontMetricsFamilyExists(nsIDeviceContext *aDevice, const nsString &aName)
73
// try to fall through to the core fonts if xft fails
74
if (NS_IsXftEnabled()) {
75
return nsFontMetricsXft::FamilyExists(aDevice, aName);
79
#ifdef MOZ_ENABLE_COREXFONTS
80
return nsFontMetricsGTK::FamilyExists(aDevice, aName);
89
static PRBool been_here = PR_FALSE;
90
static PRBool cachedXftSetting = PR_TRUE;
94
nsCOMPtr<nsIPref> prefService;
95
prefService = do_GetService(NS_PREF_CONTRACTID);
101
rv = prefService->GetBoolPref("fonts.xft.enabled", &cachedXftSetting);
103
// Yes, this makes sense. If xft is compiled in and there's no
104
// pref, it's automatically enabled. If there's no pref, check
107
char *val = PR_GetEnv("GDK_USE_XFT");
109
if (val && val[0] == '0') {
110
cachedXftSetting = PR_FALSE;
114
cachedXftSetting = PR_TRUE;
120
return cachedXftSetting;
123
#endif /* MOZ_ENABLE_XFT */