mac: Add the flag "-gline-tables-only" to reduce dSYM size. (attempt #2)
[chromium-blink-merge.git] / ui / gfx / font_fallback_win.h
blob6c3541267f10a38ebc6097f126707390c5ea96ea
1 // Copyright (c) 2012 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.
5 #ifndef UI_GFX_FONT_FALLBACK_WIN_H_
6 #define UI_GFX_FONT_FALLBACK_WIN_H_
8 #include <string>
9 #include <vector>
11 #include "ui/gfx/font.h"
12 #include "ui/gfx/font_fallback.h"
14 namespace gfx {
16 // Internals of font_fallback_win.cc exposed for testing.
17 namespace internal {
19 // Parses comma separated SystemLink |entry|, per the format described here:
20 // http://msdn.microsoft.com/en-us/goglobal/bb688134.aspx
22 // Sets |filename| and |font_name| respectively. If a field is not present
23 // or could not be parsed, the corresponding parameter will be cleared.
24 void GFX_EXPORT ParseFontLinkEntry(const std::string& entry,
25 std::string* filename,
26 std::string* font_name);
28 // Parses a font |family| in the format "FamilyFoo & FamilyBar (TrueType)".
29 // Splits by '&' and strips off the trailing parenthesized expression.
30 void GFX_EXPORT ParseFontFamilyString(const std::string& family,
31 std::vector<std::string>* font_names);
33 // Iterator over linked fallback fonts for a given font. The linked font chain
34 // comes from the Windows registry, but gets cached between uses.
35 class GFX_EXPORT LinkedFontsIterator {
36 public:
37 // Instantiates the iterator over the linked font chain for |font|. The first
38 // item will be |font| itself.
39 explicit LinkedFontsIterator(Font font);
40 virtual ~LinkedFontsIterator();
42 // Sets the font that would be returned by the next call to |NextFont()|,
43 // useful for inserting one-time entries into the iterator chain.
44 void SetNextFont(Font font);
46 // Gets the next font in the link chain, if available, and increments the
47 // iterator. Returns |true| on success or |false| if the iterator is past
48 // last item (in that case, the value of |font| should not be used). If
49 // |SetNextFont()| was called, returns the font set that way and clears it.
50 bool NextFont(Font* font);
52 protected:
53 // Retrieves the list of linked fonts. Protected and virtual so that it may
54 // be overridden by tests.
55 virtual const std::vector<Font>* GetLinkedFonts() const;
57 private:
58 // Original font whose linked fonts are being iterated over.
59 Font original_font_;
61 // Font that was set via |SetNextFont()|.
62 Font next_font_;
64 // Indicates whether |SetNextFont()| was called.
65 bool next_font_set_;
67 // The font most recently returned by |NextFont()|.
68 Font current_font_;
70 // List of linked fonts; weak pointer.
71 const std::vector<Font>* linked_fonts_;
73 // Index of the current entry in the |linked_fonts_| list.
74 size_t linked_font_index_;
76 DISALLOW_COPY_AND_ASSIGN(LinkedFontsIterator);
79 } // namespace internal
81 // Finds a fallback font to render the specified |text| with respect to an
82 // initial |font|. Returns the resulting font via out param |result|. Returns
83 // |true| if a fallback font was found.
84 bool GetUniscribeFallbackFont(const Font& font,
85 const wchar_t* text,
86 int text_length,
87 Font* result);
89 } // namespace gfx
91 #endif // UI_GFX_FONT_FALLBACK_WIN_H_