gecko-dev/gfx/thebes/gfxFontMissingGlyphs.h
Jonathan Kew c96601cb34 Bug 376129 - Scale the missing-glyph hex digits more usefully for large font sizes. r=gfx-reviewers,lsalzman
This makes the digits scale up to better fill the box, as it looks a bit odd to have
the box grow with the font size but the digits remain tiny in the middle of it.

One thing that may look a little odd with this version is that 6-digit hexboxes tend
to get smaller digits than 4-digit ones with large font sizes. But I think that's
OK; it allows the 4-digit chars to be more readable, and 6-digit (non-BMP) ones are
generally much rarer.

(And the whole thing is basically cosmetic anyhow; this isn't about rendering web
content as intended, but trying to provide a bit of useful information when the
content is somehow broken or not renderable.)

Differential Revision: https://phabricator.services.mozilla.com/D173463
2023-03-24 09:07:04 +00:00

57 lines
1.7 KiB
C++

/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef GFX_FONTMISSINGGLYPHS_H
#define GFX_FONTMISSINGGLYPHS_H
#include "mozilla/Attributes.h"
#include "mozilla/gfx/MatrixFwd.h"
#include "mozilla/gfx/Rect.h"
namespace mozilla {
namespace gfx {
class DrawTarget;
class Pattern;
} // namespace gfx
} // namespace mozilla
/**
* This class should not be instantiated. It's just a container
* for some helper functions.
*/
class gfxFontMissingGlyphs final {
typedef mozilla::gfx::DrawTarget DrawTarget;
typedef mozilla::gfx::Float Float;
typedef mozilla::gfx::Matrix Matrix;
typedef mozilla::gfx::Pattern Pattern;
typedef mozilla::gfx::Rect Rect;
gfxFontMissingGlyphs() = delete; // prevent instantiation
public:
/**
* Draw hexboxes for a missing glyph.
* @param aChar the UTF16 codepoint for the character
* @param aRect the glyph-box for the glyph that is missing
* @param aDrawTarget the DrawTarget to draw to
* @param aPattern the pattern currently being used to paint
* @param aMat optional local-space orientation matrix
*/
static void DrawMissingGlyph(uint32_t aChar, const Rect& aRect,
DrawTarget& aDrawTarget, const Pattern& aPattern,
const Matrix* aMat = nullptr);
/**
* @return the desired minimum width for a glyph-box that will allow
* the hexboxes to be drawn reasonably.
*/
static Float GetDesiredMinWidth(uint32_t aChar, uint32_t aAppUnitsPerDevUnit);
static void Purge();
static void Shutdown();
};
#endif