mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
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
This commit is contained in:
parent
6996eb2bcc
commit
c96601cb34
@ -2199,10 +2199,9 @@ bool gfxFont::DrawMissingGlyph(const TextRunDrawParams& aRunParams,
|
|||||||
aRunParams.context->SetMatrix(mat);
|
aRunParams.context->SetMatrix(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxFontMissingGlyphs::DrawMissingGlyph(aDetails->mGlyphID, glyphRect,
|
gfxFontMissingGlyphs::DrawMissingGlyph(
|
||||||
*aRunParams.dt,
|
aDetails->mGlyphID, glyphRect, *aRunParams.dt,
|
||||||
PatternFromState(aRunParams.context),
|
PatternFromState(aRunParams.context), matPtr);
|
||||||
1.0 / aRunParams.devPerApp, matPtr);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,6 @@ void gfxFontMissingGlyphs::Shutdown() { Purge(); }
|
|||||||
void gfxFontMissingGlyphs::DrawMissingGlyph(uint32_t aChar, const Rect& aRect,
|
void gfxFontMissingGlyphs::DrawMissingGlyph(uint32_t aChar, const Rect& aRect,
|
||||||
DrawTarget& aDrawTarget,
|
DrawTarget& aDrawTarget,
|
||||||
const Pattern& aPattern,
|
const Pattern& aPattern,
|
||||||
uint32_t aAppUnitsPerDevPixel,
|
|
||||||
const Matrix* aMat) {
|
const Matrix* aMat) {
|
||||||
Rect rect(aRect);
|
Rect rect(aRect);
|
||||||
// If there is an orientation transform, reorient the bounding rect.
|
// If there is an orientation transform, reorient the bounding rect.
|
||||||
@ -426,10 +425,19 @@ void gfxFontMissingGlyphs::DrawMissingGlyph(uint32_t aChar, const Rect& aRect,
|
|||||||
Point center = rect.Center();
|
Point center = rect.Center();
|
||||||
Float halfGap = HEX_CHAR_GAP / 2.f;
|
Float halfGap = HEX_CHAR_GAP / 2.f;
|
||||||
Float top = -(MINIFONT_HEIGHT + halfGap);
|
Float top = -(MINIFONT_HEIGHT + halfGap);
|
||||||
|
|
||||||
|
// Figure out a scaling factor that will fit the glyphs in the target rect
|
||||||
|
// both horizontally and vertically.
|
||||||
|
Float width = HEX_CHAR_GAP + MINIFONT_WIDTH + HEX_CHAR_GAP + MINIFONT_WIDTH +
|
||||||
|
((aChar < 0x10000) ? 0 : HEX_CHAR_GAP + MINIFONT_WIDTH) +
|
||||||
|
HEX_CHAR_GAP;
|
||||||
|
Float height = HEX_CHAR_GAP + MINIFONT_HEIGHT + HEX_CHAR_GAP +
|
||||||
|
MINIFONT_HEIGHT + HEX_CHAR_GAP;
|
||||||
|
Float scaling = std::min(rect.Height() / height, rect.Width() / width);
|
||||||
|
|
||||||
// We always want integer scaling, otherwise the "bitmap" glyphs will look
|
// We always want integer scaling, otherwise the "bitmap" glyphs will look
|
||||||
// even uglier than usual when zoomed
|
// even uglier than usual when scaled to the target.
|
||||||
int32_t devPixelsPerCSSPx =
|
int32_t devPixelsPerCSSPx = std::max<int32_t>(1, std::floor(scaling));
|
||||||
std::max<int32_t>(1, AppUnitsPerCSSPixel() / aAppUnitsPerDevPixel);
|
|
||||||
|
|
||||||
Matrix tempMat;
|
Matrix tempMat;
|
||||||
if (aMat) {
|
if (aMat) {
|
||||||
|
@ -37,13 +37,10 @@ class gfxFontMissingGlyphs final {
|
|||||||
* @param aRect the glyph-box for the glyph that is missing
|
* @param aRect the glyph-box for the glyph that is missing
|
||||||
* @param aDrawTarget the DrawTarget to draw to
|
* @param aDrawTarget the DrawTarget to draw to
|
||||||
* @param aPattern the pattern currently being used to paint
|
* @param aPattern the pattern currently being used to paint
|
||||||
* @param aAppUnitsPerDevPixel the appUnits to devPixel ratio we're using,
|
|
||||||
* (so we can scale glyphs to a sensible size)
|
|
||||||
* @param aMat optional local-space orientation matrix
|
* @param aMat optional local-space orientation matrix
|
||||||
*/
|
*/
|
||||||
static void DrawMissingGlyph(uint32_t aChar, const Rect& aRect,
|
static void DrawMissingGlyph(uint32_t aChar, const Rect& aRect,
|
||||||
DrawTarget& aDrawTarget, const Pattern& aPattern,
|
DrawTarget& aDrawTarget, const Pattern& aPattern,
|
||||||
uint32_t aAppUnitsPerDevPixel,
|
|
||||||
const Matrix* aMat = nullptr);
|
const Matrix* aMat = nullptr);
|
||||||
/**
|
/**
|
||||||
* @return the desired minimum width for a glyph-box that will allow
|
* @return the desired minimum width for a glyph-box that will allow
|
||||||
|
Loading…
Reference in New Issue
Block a user