2 * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 // A collection of utilities for font handling.
33 // FIXME: Move all methods to the files that have their callsites and remove this file.
34 // *Utils files are not very WebKit-ty.
36 #ifndef FontUtilsChromiumWin_h
37 #define FontUtilsChromiumWin_h
43 #include "FontDescription.h"
44 #include <unicode/uscript.h>
48 // Return a font family that supports a script and belongs to |generic| font
49 // family. It can return NULL and a caller has to implement its own fallback.
50 const UChar* getFontFamilyForScript(UScriptCode, FontDescription::GenericFamilyType);
52 // Return a font family that can render |characters| based on
53 // what script characters belong to. When char_checked is non-NULL,
54 // it's filled with the character used to determine the script.
55 // When script_checked is non-NULL, the script used to determine
56 // the family is returned.
57 // FIXME: This function needs a total overhaul.
58 const UChar* getFallbackFamily(const UChar* characters, int length,
59 FontDescription::GenericFamilyType,
61 UScriptCode* scriptChecked);
63 // Derive a new HFONT by replacing lfFaceName of LOGFONT with |family|,
64 // calculate the ascent for the derived HFONT, and initialize SCRIPT_CACHE
66 // |style| is only used for cache key generation. |style| is
67 // bit-wise OR of BOLD(1), UNDERLINED(2) and ITALIC(4) and
68 // should match what's contained in LOGFONT. It should be calculated
69 // by calling GetStyleFromLogFont.
70 // Returns false if the font is not accessible, in which case |ascent| field
71 // of |fontdata| is set to kUndefinedAscent.
72 // Be aware that this is not thread-safe.
73 // FIXME: Instead of having three out params, we'd better have one
74 // (|*FontData|), but somehow it mysteriously messes up the layout for
75 // certain complex script pages (e.g. hi.wikipedia.org) and also crashes
76 // at the start-up if recently visited page list includes pages with complex
77 // scripts in their title. Moreover, somehow the very first-pass of
78 // intl2 page-cycler test is noticeably slower with one out param than
79 // the current version although the subsequent 9 passes take about the
81 bool getDerivedFontData(const UChar* family, int style, LOGFONT*, int* ascent, HFONT*, SCRIPT_CACHE**, WORD* spaceGlyph);
87 FontStyleUnderlined = 4
90 // Derive style (bit-wise OR of FONT_STYLE_BOLD, FONT_STYLE_UNDERLINED, and
91 // FONT_STYLE_ITALIC) from LOGFONT. Returns 0 if |*logfont| is NULL.
92 int getStyleFromLogfont(const LOGFONT*);
94 } // namespace WebCore
96 #endif // FontUtilsChromiumWin_h