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_
11 #include "ui/gfx/font.h"
15 // Internals of font_fallback_win.cc exposed for testing.
18 // Parses comma separated SystemLink |entry|, per the format described here:
19 // http://msdn.microsoft.com/en-us/goglobal/bb688134.aspx
21 // Sets |filename| and |font_name| respectively. If a field is not present
22 // or could not be parsed, the corresponding parameter will be cleared.
23 void GFX_EXPORT
ParseFontLinkEntry(const std::string
& entry
,
24 std::string
* filename
,
25 std::string
* font_name
);
27 // Parses a font |family| in the format "FamilyFoo & FamilyBar (TrueType)".
28 // Splits by '&' and strips off the trailing parenthesized expression.
29 void GFX_EXPORT
ParseFontFamilyString(const std::string
& family
,
30 std::vector
<std::string
>* font_names
);
32 } // namespace internal
34 // Iterator over linked fallback fonts for a given font. The linked font chain
35 // comes from the Windows registry, but gets cached between uses.
36 class GFX_EXPORT LinkedFontsIterator
{
38 // Instantiates the iterator over the linked font chain for |font|. The first
39 // item will be |font| itself.
40 explicit LinkedFontsIterator(Font font
);
41 virtual ~LinkedFontsIterator();
43 // Sets the font that would be returned by the next call to |NextFont()|,
44 // useful for inserting one-time entries into the iterator chain.
45 void SetNextFont(Font font
);
47 // Gets the next font in the link chain, if available, and increments the
48 // iterator. Returns |true| on success or |false| if the iterator is past
49 // last item (in that case, the value of |font| should not be used). If
50 // |SetNextFont()| was called, returns the font set that way and clears it.
51 bool NextFont(Font
* font
);
54 // Retrieves the list of linked fonts. Protected and virtual so that it may
55 // be overridden by tests.
56 virtual const std::vector
<Font
>* GetLinkedFonts() const;
59 // Original font whose linked fonts are being iterated over.
62 // Font that was set via |SetNextFont()|.
65 // Indicates whether |SetNextFont()| was called.
68 // The font most recently returned by |NextFont()|.
71 // List of linked fonts; weak pointer.
72 const std::vector
<Font
>* linked_fonts_
;
74 // Index of the current entry in the |linked_fonts_| list.
75 size_t linked_font_index_
;
77 DISALLOW_COPY_AND_ASSIGN(LinkedFontsIterator
);
82 #endif // UI_GFX_FONT_FALLBACK_WIN_H_