Bug 1738700 - Don't use FT_LOAD_COLOR for COLR-format fonts within WebRender, because color-font layers are handled at the Gecko level. r=lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D130271
This commit is contained in:
Jonathan Kew 2021-11-09 23:17:44 +00:00
parent 379e516511
commit 413d0572e0
6 changed files with 112 additions and 2 deletions

View File

@ -482,12 +482,19 @@ impl FontContext {
load_flags |= FT_LOAD_NO_BITMAP;
}
load_flags |= FT_LOAD_COLOR;
let face_flags = unsafe { (*face).face_flags };
if (face_flags & (FT_FACE_FLAG_FIXED_SIZES as FT_Long)) != 0 {
// We only set FT_LOAD_COLOR if there are bitmap strikes;
// COLR (color-layer) fonts are handled internally by Gecko, and
// WebRender is just asked to paint individual layers.
load_flags |= FT_LOAD_COLOR;
}
load_flags |= FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH;
let (x_scale, y_scale) = font.transform.compute_scale().unwrap_or((1.0, 1.0));
let req_size = font.size.to_f64_px();
let face_flags = unsafe { (*face).face_flags };
let mut result = if (face_flags & (FT_FACE_FLAG_FIXED_SIZES as FT_Long)) != 0 &&
(face_flags & (FT_FACE_FLAG_SCALABLE as FT_Long)) == 0 &&
(load_flags & FT_LOAD_NO_BITMAP) == 0 {

View File

@ -0,0 +1,40 @@
<html>
<head>
<meta charset=UTF-8>
<title>“Amiri Quran Colored” test</title>
<style>
@font-face {
font-family: AmiriMonochrome;
font-style: normal;
font-weight: 400;
src: url('../fonts/AmiriQuran.otf');
}
.test {
direction: rtl;
text-align: justify;
text-align-last: center;
font-size: 40px;
margin: 1em;
position: absolute;
}
.monochrome {
font-family: AmiriMonochrome;
-webkit-text-stroke: 3px black;
}
</style>
</head>
<div>The colored Arabic text should be exactly covered by (thicker) black text:</div>
<div class="test monochrome">
<p>
﷽ ۝١
<br>
ٱلۡحَمۡدُ لِلَّهِ رَبِّ ٱلۡعَـٰلَمِینَ ۝٢
ٱلرَّحۡمَـٰنِ ٱلرَّحِیمِ ۝٣
مَـٰلِكِ یَوۡمِ ٱلدِّینِ ۝٤
إِیَّاكَ نَعۡبُدُ وَإِیَّاكَ نَسۡتَعِینُ ۝٥
ٱهۡدِنَا ٱلصِّرَ ٰطَ ٱلۡمُسۡتَقِیمَ ۝٦
صِرَ ٰطَ ٱلَّذِینَ أَنۡعَمۡتَ عَلَیۡهِمۡ غَیۡرِ ٱلۡمَغۡضُوبِ عَلَیۡهِمۡ وَلَا ٱلضَّاۤلِّینَ ۝٧
</p>
</div>
</html>

View File

@ -0,0 +1,62 @@
<html>
<head>
<meta charset=UTF-8>
<title>“Amiri Quran Colored” test</title>
<style>
@font-face {
font-family: AmiriColored;
font-style: normal;
font-weight: 400;
src: url('../fonts/AmiriQuranColored.otf');
}
@font-face {
font-family: AmiriMonochrome;
font-style: normal;
font-weight: 400;
src: url('../fonts/AmiriQuran.otf');
}
.test {
direction: rtl;
text-align: justify;
text-align-last: center;
font-size: 40px;
margin: 1em;
position: absolute;
}
.colored {
font-family: AmiriColored;
}
.monochrome {
font-family: AmiriMonochrome;
/* Add some stroke to hide antialiased edges of the colored glyphs */
-webkit-text-stroke: 3px black;
}
</style>
</head>
<div>The colored Arabic text should be exactly covered by (thicker) black text:</div>
<div class="test colored">
<p>
﷽ ۝١
<br>
ٱلۡحَمۡدُ لِلَّهِ رَبِّ ٱلۡعَـٰلَمِینَ ۝٢
ٱلرَّحۡمَـٰنِ ٱلرَّحِیمِ ۝٣
مَـٰلِكِ یَوۡمِ ٱلدِّینِ ۝٤
إِیَّاكَ نَعۡبُدُ وَإِیَّاكَ نَسۡتَعِینُ ۝٥
ٱهۡدِنَا ٱلصِّرَ ٰطَ ٱلۡمُسۡتَقِیمَ ۝٦
صِرَ ٰطَ ٱلَّذِینَ أَنۡعَمۡتَ عَلَیۡهِمۡ غَیۡرِ ٱلۡمَغۡضُوبِ عَلَیۡهِمۡ وَلَا ٱلضَّاۤلِّینَ ۝٧
</p>
</div>
<div class="test monochrome">
<p>
﷽ ۝١
<br>
ٱلۡحَمۡدُ لِلَّهِ رَبِّ ٱلۡعَـٰلَمِینَ ۝٢
ٱلرَّحۡمَـٰنِ ٱلرَّحِیمِ ۝٣
مَـٰلِكِ یَوۡمِ ٱلدِّینِ ۝٤
إِیَّاكَ نَعۡبُدُ وَإِیَّاكَ نَسۡتَعِینُ ۝٥
ٱهۡدِنَا ٱلصِّرَ ٰطَ ٱلۡمُسۡتَقِیمَ ۝٦
صِرَ ٰطَ ٱلَّذِینَ أَنۡعَمۡتَ عَلَیۡهِمۡ غَیۡرِ ٱلۡمَغۡضُوبِ عَلَیۡهِمۡ وَلَا ٱلضَّاۤلِّینَ ۝٧
</p>
</div>
</html>

View File

@ -2104,3 +2104,4 @@ skip-if(!appleSilicon) != 1721223-1.html 1721223-1-notref.html # Big Sur require
skip-if(Android) == 1727172-1.xhtml 1727172-1-ref.html
== 1726663-1.html 1726663-1-ref.html
!= 1730314-1.html 1730314-1-ref.html
fuzzy(0-3,0-3) fuzzy-if(Android,0-3,0-180) fuzzy-if(winWidget,0-154,0-118) == 1738700-1.html 1738700-1-ref.html

Binary file not shown.

Binary file not shown.