mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1232822 (part 3) - Moz2Dify gfxFont::CalcXScale() and gfxFont::PostShapingFixup(). r=jfkthame.
This boils down to these two lines being equivalent: Size t = aContext->UserToDevice(Size(1.0, 0.0)); Size t = aDrawTarget->GetTransform() * Size(1.0, 0.0); The rest is just plumbing.
This commit is contained in:
parent
6d5095441f
commit
f1171fdfa1
@ -55,8 +55,8 @@ gfxFT2Font::ShapeText(gfxContext *aContext,
|
||||
aVertical, aShapedText)) {
|
||||
// harfbuzz must have failed(?!), just render raw glyphs
|
||||
AddRange(aText, aOffset, aLength, aShapedText);
|
||||
PostShapingFixup(aContext, aText, aOffset, aLength, aVertical,
|
||||
aShapedText);
|
||||
PostShapingFixup(aContext->GetDrawTarget(), aText, aOffset, aLength,
|
||||
aVertical, aShapedText);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -1642,10 +1642,10 @@ private:
|
||||
// the second draw occurs at a constant offset in device pixels.
|
||||
|
||||
double
|
||||
gfxFont::CalcXScale(gfxContext *aContext)
|
||||
gfxFont::CalcXScale(DrawTarget* aDrawTarget)
|
||||
{
|
||||
// determine magnitude of a 1px x offset in device space
|
||||
Size t = aContext->UserToDevice(Size(1.0, 0.0));
|
||||
Size t = aDrawTarget->GetTransform() * Size(1.0, 0.0);
|
||||
if (t.width == 1.0 && t.height == 0.0) {
|
||||
// short-circuit the most common case to avoid sqrt() and division
|
||||
return 1.0;
|
||||
@ -1970,7 +1970,7 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
|
||||
// Synthetic-bold strikes are each offset one device pixel in run direction.
|
||||
// (these values are only needed if IsSyntheticBold() is true)
|
||||
if (IsSyntheticBold()) {
|
||||
double xscale = CalcXScale(aRunParams.context);
|
||||
double xscale = CalcXScale(aRunParams.context->GetDrawTarget());
|
||||
fontParams.synBoldOnePixelOffset = aRunParams.direction * xscale;
|
||||
if (xscale != 0.0) {
|
||||
// use as many strikes as needed for the the increased advance
|
||||
@ -2577,26 +2577,26 @@ gfxFont::ShapeText(gfxContext *aContext,
|
||||
|
||||
NS_WARN_IF_FALSE(ok, "shaper failed, expect scrambled or missing text");
|
||||
|
||||
PostShapingFixup(aContext, aText, aOffset, aLength, aVertical,
|
||||
aShapedText);
|
||||
PostShapingFixup(aContext->GetDrawTarget(), aText, aOffset, aLength,
|
||||
aVertical, aShapedText);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
void
|
||||
gfxFont::PostShapingFixup(gfxContext *aContext,
|
||||
const char16_t *aText,
|
||||
uint32_t aOffset,
|
||||
uint32_t aLength,
|
||||
bool aVertical,
|
||||
gfxShapedText *aShapedText)
|
||||
gfxFont::PostShapingFixup(DrawTarget* aDrawTarget,
|
||||
const char16_t* aText,
|
||||
uint32_t aOffset,
|
||||
uint32_t aLength,
|
||||
bool aVertical,
|
||||
gfxShapedText* aShapedText)
|
||||
{
|
||||
if (IsSyntheticBold()) {
|
||||
const Metrics& metrics =
|
||||
GetMetrics(aVertical ? eVertical : eHorizontal);
|
||||
if (metrics.maxAdvance > metrics.aveCharWidth) {
|
||||
float synBoldOffset =
|
||||
GetSyntheticBoldOffset() * CalcXScale(aContext);
|
||||
GetSyntheticBoldOffset() * CalcXScale(aDrawTarget);
|
||||
aShapedText->AdjustAdvancesForSyntheticBold(synBoldOffset,
|
||||
aOffset, aLength);
|
||||
}
|
||||
|
@ -1926,12 +1926,12 @@ protected:
|
||||
// Helper to adjust for synthetic bold and set character-type flags
|
||||
// in the shaped text; implementations of ShapeText should call this
|
||||
// after glyph shaping has been completed.
|
||||
void PostShapingFixup(gfxContext *aContext,
|
||||
const char16_t *aText,
|
||||
uint32_t aOffset, // position within aShapedText
|
||||
uint32_t aLength,
|
||||
bool aVertical,
|
||||
gfxShapedText *aShapedText);
|
||||
void PostShapingFixup(DrawTarget* aContext,
|
||||
const char16_t* aText,
|
||||
uint32_t aOffset, // position within aShapedText
|
||||
uint32_t aLength,
|
||||
bool aVertical,
|
||||
gfxShapedText* aShapedText);
|
||||
|
||||
// Shape text directly into a range within a textrun, without using the
|
||||
// font's word cache. Intended for use when the font has layout features
|
||||
@ -2139,7 +2139,7 @@ protected:
|
||||
// the second draw occurs at a constant offset in device pixels.
|
||||
// This helper calculates the scale factor we need to apply to the
|
||||
// synthetic-bold offset.
|
||||
static double CalcXScale(gfxContext *aContext);
|
||||
static double CalcXScale(DrawTarget* aDrawTarget);
|
||||
};
|
||||
|
||||
// proportion of ascent used for x-height, if unable to read value from font
|
||||
|
@ -142,8 +142,8 @@ gfxMacFont::ShapeText(gfxContext *aContext,
|
||||
}
|
||||
if (mCoreTextShaper->ShapeText(aContext, aText, aOffset, aLength,
|
||||
aScript, aVertical, aShapedText)) {
|
||||
PostShapingFixup(aContext, aText, aOffset, aLength, aVertical,
|
||||
aShapedText);
|
||||
PostShapingFixup(aContext->GetDrawTarget(), aText, aOffset,
|
||||
aLength, aVertical, aShapedText);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user