summaryrefslogtreecommitdiffstats
path: root/webkit/port/platform/graphics/FontUtilsWin.h
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/port/platform/graphics/FontUtilsWin.h')
-rw-r--r--webkit/port/platform/graphics/FontUtilsWin.h87
1 files changed, 87 insertions, 0 deletions
diff --git a/webkit/port/platform/graphics/FontUtilsWin.h b/webkit/port/platform/graphics/FontUtilsWin.h
new file mode 100644
index 0000000..1ec49eb
--- /dev/null
+++ b/webkit/port/platform/graphics/FontUtilsWin.h
@@ -0,0 +1,87 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// A collection of utilities for font handling.
+
+#ifndef FontUtilsWin_h
+#define FontUtilsWin_h
+
+#include <usp10.h>
+#include <wchar.h>
+#include <windows.h>
+
+#include <unicode/uscript.h>
+
+namespace WebCore {
+
+// The order of family types needs to be exactly the same as
+// WebCore::FontDescription::GenericFamilyType. We may lift that restriction
+// when we make webkit_glue::WebkitGenericToChromeGenericFamily more
+// intelligent.
+enum GenericFamilyType {
+ GENERIC_FAMILY_NONE = 0,
+ GENERIC_FAMILY_STANDARD,
+ GENERIC_FAMILY_SERIF,
+ GENERIC_FAMILY_SANSSERIF,
+ GENERIC_FAMILY_MONOSPACE,
+ GENERIC_FAMILY_CURSIVE,
+ GENERIC_FAMILY_FANTASY
+};
+
+// Return a font family that supports a script and belongs to |generic| font family.
+// It can return NULL and a caller has to implement its own fallback.
+const UChar* GetFontFamilyForScript(UScriptCode script,
+ GenericFamilyType generic);
+
+// Return a font family that can render |characters| based on
+// what script characters belong to. When char_checked is non-NULL,
+// it's filled with the character used to determine the script.
+// When script_checked is non-NULL, the script used to determine
+// the family is returned.
+// TODO(jungshik) : This function needs a total overhaul.
+const UChar* GetFallbackFamily(const UChar* characters,
+ int length,
+ GenericFamilyType generic,
+ UChar32 *char_checked,
+ UScriptCode *script_checked);
+
+// Derive a new HFONT by replacing lfFaceName of LOGFONT with |family|,
+// calculate the ascent for the derived HFONT, and initialize SCRIPT_CACHE
+// in FontData.
+// |style| is only used for cache key generation. |style| is
+// bit-wise OR of BOLD(1), UNDERLINED(2) and ITALIC(4) and
+// should match what's contained in LOGFONT. It should be calculated
+// by calling GetStyleFromLogFont.
+// Returns false if the font is not accessible, in which case |ascent| field
+// of |fontdata| is set to kUndefinedAscent.
+// Be aware that this is not thread-safe.
+// TODO(jungshik): Instead of having three out params, we'd better have one
+// (|*FontData|), but somehow it mysteriously messes up the layout for
+// certain complex script pages (e.g. hi.wikipedia.org) and also crashes
+// at the start-up if recently visited page list includes pages with complex
+// scripts in their title. Moreover, somehow the very first-pass of
+// intl2 page-cycler test is noticeably slower with one out param than
+// the current version although the subsequent 9 passes take about the
+// same time.
+bool GetDerivedFontData(const UChar *family,
+ int style,
+ LOGFONT *logfont,
+ int *ascent,
+ HFONT *hfont,
+ SCRIPT_CACHE **script_cache);
+
+enum {
+ FONT_STYLE_NORMAL = 0,
+ FONT_STYLE_BOLD = 1,
+ FONT_STYLE_ITALIC = 2,
+ FONT_STYLE_UNDERLINED = 4
+};
+
+// Derive style (bit-wise OR of FONT_STYLE_BOLD, FONT_STYLE_UNDERLINED, and
+// FONT_STYLE_ITALIC) from LOGFONT. Returns 0 if |*logfont| is NULL.
+int GetStyleFromLogfont(const LOGFONT *logfont);
+
+} // namespace WebCore
+
+#endif // FontUtilsWin_h