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

Side by Side Diff: webkit/port/platform/UniscribeStateTextRun.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 /*
6 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
21 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 #ifndef UniscribeStateTextRun_H
31 #define UniscribeStateTextRun_H
32
33 #include "base/gfx/uniscribe.h"
34
35 namespace WebCore {
36
37 class Font;
38 class TextRun;
39
40 }
41
42 // Wrapper around the Uniscribe state that automatically sets it up with the
43 // WebKit types we supply.
44 class UniscribeStateTextRun : public gfx::UniscribeState {
45 public:
46 // Regular constructor used for WebCore text run processing.
47 UniscribeStateTextRun(const WebCore::TextRun& run,
48 const WebCore::Font& font);
49
50 // Constructor with the same interface as the gfx::UniscribeState. Using
51 // this constructor will not give you font fallback, but it will provide
52 // the ability to load fonts that may not be in the OS cache
53 // ("TryToPreloadFont") if the caller does not have a TextRun/Font.
54 UniscribeStateTextRun(const wchar_t* input,
55 int input_length,
56 bool is_rtl,
57 HFONT hfont,
58 SCRIPT_CACHE* script_cache,
59 SCRIPT_FONTPROPERTIES* font_properties);
60
61 protected:
62 virtual void TryToPreloadFont(HFONT font);
63
64 private:
65 // This function retrieves the Windows font data (HFONT, etc)
66 // for the next WebKit font in the list. If the font data
67 // corresponding to font_index_ has been obtained before,
68 // returns the values stored in our internal vectors (hfonts_, etc).
69 // Otherwise, it gets next SimpleFontData from WebKit and adds them to
70 // in hfonts_ and friends so that font data can be returned
71 // quickly next time they're requested.
72 virtual bool NextWinFontData(HFONT* hfont,
73 SCRIPT_CACHE** script_cache,
74 SCRIPT_FONTPROPERTIES** font_properties,
75 int* ascent);
76 virtual void ResetFontIndex();
77
78 // Reference to WebKit::Font that contains all the information
79 // about fonts we can use to render this input run of text.
80 // It is used in NextWinFontData to retrieve Windows font data
81 // for a series of non-primary fonts.
82 //
83 // This pointer can be NULL for no font fallback handling.
84 const WebCore::Font* font_;
85
86 // It's rare that many fonts are listed in stylesheets.
87 // Four would be large enough in most cases.
88 const static size_t kNumberOfFonts = 4;
89
90 // These vectors are used to store Windows font data for
91 // non-primary fonts.
92 StackVector<HFONT, kNumberOfFonts> hfonts_;
93 StackVector<SCRIPT_CACHE*, kNumberOfFonts> script_caches_;
94 StackVector<SCRIPT_FONTPROPERTIES*, kNumberOfFonts> font_properties_;
95 StackVector<int, kNumberOfFonts> ascents_;
96
97 //
98 int font_index_;
99 };
100
101 #endif // UniscribeStateTextRun_H
102
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698