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

Side by Side Diff: webkit/port/platform/graphics/FontUtilsWin.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
Property Changes:
Added: svn:mergeinfo
Merged /branches/chrome_webkit_merge_branch/base/gfx/font_utils.h:r69-2775
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // A collection of utilities for font handling. 5 // A collection of utilities for font handling.
6 6
7 #ifndef BASE_GFX_FONT_UTILS_H__ 7 #ifndef FontUtilsWin_h
8 #define BASE_GFX_FONT_UTILS_H__ 8 #define FontUtilsWin_h
9 9
10 #include <usp10.h> 10 #include <usp10.h>
11 #include <wchar.h> 11 #include <wchar.h>
12 #include <windows.h> 12 #include <windows.h>
13 13
14 #include <unicode/uscript.h> 14 #include <unicode/uscript.h>
15 15
16 namespace gfx { 16 namespace WebCore {
17 17
18 // The order of family types needs to be exactly the same as 18 // The order of family types needs to be exactly the same as
19 // WebCore::FontDescription::GenericFamilyType. We may lift that restriction 19 // WebCore::FontDescription::GenericFamilyType. We may lift that restriction
20 // when we make webkit_glue::WebkitGenericToChromeGenericFamily more 20 // when we make webkit_glue::WebkitGenericToChromeGenericFamily more
21 // intelligent. 21 // intelligent.
22 enum GenericFamilyType { 22 enum GenericFamilyType {
23 GENERIC_FAMILY_NONE = 0, 23 GENERIC_FAMILY_NONE = 0,
24 GENERIC_FAMILY_STANDARD, 24 GENERIC_FAMILY_STANDARD,
25 GENERIC_FAMILY_SERIF, 25 GENERIC_FAMILY_SERIF,
26 GENERIC_FAMILY_SANSSERIF, 26 GENERIC_FAMILY_SANSSERIF,
27 GENERIC_FAMILY_MONOSPACE, 27 GENERIC_FAMILY_MONOSPACE,
28 GENERIC_FAMILY_CURSIVE, 28 GENERIC_FAMILY_CURSIVE,
29 GENERIC_FAMILY_FANTASY 29 GENERIC_FAMILY_FANTASY
30 }; 30 };
31 31
32 // Return a font family that supports a script and belongs to |generic| font fam ily. 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. 33 // It can return NULL and a caller has to implement its own fallback.
34 const wchar_t* GetFontFamilyForScript(UScriptCode script, 34 const UChar* GetFontFamilyForScript(UScriptCode script,
35 GenericFamilyType generic); 35 GenericFamilyType generic);
36 36
37 // Return a font family that can render |characters| based on 37 // Return a font family that can render |characters| based on
38 // what script characters belong to. When char_checked is non-NULL, 38 // what script characters belong to. When char_checked is non-NULL,
39 // it's filled with the character used to determine the script. 39 // it's filled with the character used to determine the script.
40 // When script_checked is non-NULL, the script used to determine 40 // When script_checked is non-NULL, the script used to determine
41 // the family is returned. 41 // the family is returned.
42 // TODO(jungshik) : This function needs a total overhaul. 42 // TODO(jungshik) : This function needs a total overhaul.
43 const wchar_t* GetFallbackFamily(const wchar_t* characters, 43 const UChar* GetFallbackFamily(const UChar* characters,
44 int length, 44 int length,
45 GenericFamilyType generic, 45 GenericFamilyType generic,
46 UChar32 *char_checked, 46 UChar32 *char_checked,
47 UScriptCode *script_checked); 47 UScriptCode *script_checked);
48
48 // Derive a new HFONT by replacing lfFaceName of LOGFONT with |family|, 49 // Derive a new HFONT by replacing lfFaceName of LOGFONT with |family|,
49 // calculate the ascent for the derived HFONT, and initialize SCRIPT_CACHE 50 // calculate the ascent for the derived HFONT, and initialize SCRIPT_CACHE
50 // in FontData. 51 // in FontData.
51 // |style| is only used for cache key generation. |style| is 52 // |style| is only used for cache key generation. |style| is
52 // bit-wise OR of BOLD(1), UNDERLINED(2) and ITALIC(4) and 53 // 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 // should match what's contained in LOGFONT. It should be calculated
54 // by calling GetStyleFromLogFont. 55 // by calling GetStyleFromLogFont.
55 // Returns false if the font is not accessible, in which case |ascent| field 56 // Returns false if the font is not accessible, in which case |ascent| field
56 // of |fontdata| is set to kUndefinedAscent. 57 // of |fontdata| is set to kUndefinedAscent.
57 // Be aware that this is not thread-safe. 58 // Be aware that this is not thread-safe.
58 // TODO(jungshik): Instead of having three out params, we'd better have one 59 // 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 // (|*FontData|), but somehow it mysteriously messes up the layout for
60 // certain complex script pages (e.g. hi.wikipedia.org) and also crashes 61 // 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 // 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 // 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 // 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 // the current version although the subsequent 9 passes take about the
65 // same time. 66 // same time.
66 bool GetDerivedFontData(const wchar_t *family, 67 bool GetDerivedFontData(const UChar *family,
67 int style, 68 int style,
68 LOGFONT *logfont, 69 LOGFONT *logfont,
69 int *ascent, 70 int *ascent,
70 HFONT *hfont, 71 HFONT *hfont,
71 SCRIPT_CACHE **script_cache); 72 SCRIPT_CACHE **script_cache);
72 73
73 enum { 74 enum {
74 FONT_STYLE_NORMAL = 0, 75 FONT_STYLE_NORMAL = 0,
75 FONT_STYLE_BOLD = 1, 76 FONT_STYLE_BOLD = 1,
76 FONT_STYLE_ITALIC = 2, 77 FONT_STYLE_ITALIC = 2,
77 FONT_STYLE_UNDERLINED = 4 78 FONT_STYLE_UNDERLINED = 4
78 }; 79 };
79 80
80 // Derive style (bit-wise OR of FONT_STYLE_BOLD, FONT_STYLE_UNDERLINED, and 81 // 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 // FONT_STYLE_ITALIC) from LOGFONT. Returns 0 if |*logfont| is NULL.
82 int GetStyleFromLogfont(const LOGFONT *logfont); 83 int GetStyleFromLogfont(const LOGFONT *logfont);
83 84
84 } // namespace gfx 85 } // namespace WebCore
85 86
86 #endif // BASE_GFX_FONT_UTILS_H__ 87 #endif // FontUtilsWin_h
87
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698