1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 
6 #ifndef GFX_FONTMISSINGGLYPHS_H
7 #define GFX_FONTMISSINGGLYPHS_H
8 
9 #include "mozilla/Attributes.h"
10 #include "mozilla/gfx/Rect.h"
11 
12 namespace mozilla {
13 namespace gfx {
14 class DrawTarget;
15 class Pattern;
16 } // namespace gfx
17 } // namespace mozilla
18 
19 /**
20  * This class should not be instantiated. It's just a container
21  * for some helper functions.
22  */
23 class gfxFontMissingGlyphs final
24 {
25     typedef mozilla::gfx::DrawTarget DrawTarget;
26     typedef mozilla::gfx::Float Float;
27     typedef mozilla::gfx::Pattern Pattern;
28     typedef mozilla::gfx::Rect Rect;
29 
30     gfxFontMissingGlyphs() = delete; // prevent instantiation
31 
32 public:
33     /**
34      * Draw hexboxes for a missing glyph.
35      * @param aChar the UTF16 codepoint for the character
36      * @param aRect the glyph-box for the glyph that is missing
37      * @param aDrawTarget the DrawTarget to draw to
38      * @param aPattern the pattern currently being used to paint
39      * @param aAppUnitsPerDevPixel the appUnits to devPixel ratio we're using,
40      *                             (so we can scale glyphs to a sensible size)
41      */
42     static void DrawMissingGlyph(uint32_t aChar,
43                                  const Rect& aRect,
44                                  DrawTarget& aDrawTarget,
45                                  const Pattern& aPattern,
46                                  uint32_t aAppUnitsPerDevPixel);
47     /**
48      * @return the desired minimum width for a glyph-box that will allow
49      * the hexboxes to be drawn reasonably.
50      */
51     static Float GetDesiredMinWidth(uint32_t aChar,
52                                     uint32_t aAppUnitsPerDevUnit);
53 };
54 
55 #endif
56