Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2675)

Side by Side Diff: base/gfx/font_utils.h

Issue 10785: Debase our Uniscribe code. This moves FontUtils and all our Uniscribe code fr... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 // A collection of utilities for font handling.
6
7 #ifndef BASE_GFX_FONT_UTILS_H__
8 #define BASE_GFX_FONT_UTILS_H__
9
10 #include <usp10.h>
11 #include <wchar.h>
12 #include <windows.h>
13
14 #include <unicode/uscript.h>
15
16 namespace gfx {
17
18 // The order of family types needs to be exactly the same as
19 // WebCore::FontDescription::GenericFamilyType. We may lift that restriction
20 // when we make webkit_glue::WebkitGenericToChromeGenericFamily more
21 // intelligent.
22 enum GenericFamilyType {
23 GENERIC_FAMILY_NONE = 0,
24 GENERIC_FAMILY_STANDARD,
25 GENERIC_FAMILY_SERIF,
26 GENERIC_FAMILY_SANSSERIF,
27 GENERIC_FAMILY_MONOSPACE,
28 GENERIC_FAMILY_CURSIVE,
29 GENERIC_FAMILY_FANTASY
30 };
31
32 // Return a font family that supports a script and belongs to |generic| font fam ily.
33 // It can return NULL and a caller has to implement its own fallback.
34 const wchar_t* GetFontFamilyForScript(UScriptCode script,
35 GenericFamilyType generic);
36
37 // Return a font family that can render |characters| based on
38 // what script characters belong to. When char_checked is non-NULL,
39 // it's filled with the character used to determine the script.
40 // When script_checked is non-NULL, the script used to determine
41 // the family is returned.
42 // TODO(jungshik) : This function needs a total overhaul.
43 const wchar_t* GetFallbackFamily(const wchar_t* characters,
44 int length,
45 GenericFamilyType generic,
46 UChar32 *char_checked,
47 UScriptCode *script_checked);
48 // Derive a new HFONT by replacing lfFaceName of LOGFONT with |family|,
49 // calculate the ascent for the derived HFONT, and initialize SCRIPT_CACHE
50 // in FontData.
51 // |style| is only used for cache key generation. |style| is
52 // bit-wise OR of BOLD(1), UNDERLINED(2) and ITALIC(4) and
53 // should match what's contained in LOGFONT. It should be calculated
54 // by calling GetStyleFromLogFont.
55 // Returns false if the font is not accessible, in which case |ascent| field
56 // of |fontdata| is set to kUndefinedAscent.
57 // Be aware that this is not thread-safe.
58 // TODO(jungshik): Instead of having three out params, we'd better have one
59 // (|*FontData|), but somehow it mysteriously messes up the layout for
60 // certain complex script pages (e.g. hi.wikipedia.org) and also crashes
61 // at the start-up if recently visited page list includes pages with complex
62 // scripts in their title. Moreover, somehow the very first-pass of
63 // intl2 page-cycler test is noticeably slower with one out param than
64 // the current version although the subsequent 9 passes take about the
65 // same time.
66 bool GetDerivedFontData(const wchar_t *family,
67 int style,
68 LOGFONT *logfont,
69 int *ascent,
70 HFONT *hfont,
71 SCRIPT_CACHE **script_cache);
72
73 enum {
74 FONT_STYLE_NORMAL = 0,
75 FONT_STYLE_BOLD = 1,
76 FONT_STYLE_ITALIC = 2,
77 FONT_STYLE_UNDERLINED = 4
78 };
79
80 // Derive style (bit-wise OR of FONT_STYLE_BOLD, FONT_STYLE_UNDERLINED, and
81 // FONT_STYLE_ITALIC) from LOGFONT. Returns 0 if |*logfont| is NULL.
82 int GetStyleFromLogfont(const LOGFONT *logfont);
83
84 } // namespace gfx
85
86 #endif // BASE_GFX_FONT_UTILS_H__
87
OLDNEW
« no previous file with comments | « base/gfx/base_gfx.scons ('k') | base/gfx/font_utils.cc » ('j') | webkit/build/port/port.vcproj » ('J')

Powered by Google App Engine
This is Rietveld 408576698