aboutsummaryrefslogtreecommitdiffstats
path: root/components/gfx/font_context.rs
Commit message (Collapse)AuthorAgeFilesLines
* Fix deprecation warningsSimon Sapin2019-01-281-2/+2
|
* Rustfmt has changed its default style :/Simon Sapin2018-12-281-1/+1
|
* Remove redundant `.clone()`sShotaro Yamada2018-12-111-1/+1
|
* Update MPL license to https (part 4)Jan Andre Ikenmeyer2018-11-191-1/+1
|
* Remove useless `use crate_name;` imports.Simon Sapin2018-11-081-1/+0
| | | | A `crate_name::foo` path always works in 2018
* Reorder importsPyfisch2018-11-061-1/+3
|
* Format remaining filesPyfisch2018-11-061-1/+2
|
* Sort `use` statementsSimon Sapin2018-11-061-2/+2
|
* `cargo fix --edition`Simon Sapin2018-11-061-5/+5
|
* Format the rest of gfx #21373kingdido9992018-09-081-25/+43
|
* FontContext: Cache data fetched from the cache threadJon Leighton2018-05-191-6/+39
| | | | | | | Before this change, if we needed to create a Font which we've already created, but at a new size, then we'd fetch the FontTemplateInfo again. If the bytes of the font are held in memory, then this could be expensive as we need to pass those bytes over IPC.
* Implement font fallbackJon Leighton2018-05-191-128/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prior to this change, if none of the fonts specified in CSS contained a glyph for a codepoint, we tried only one fallback font. If that font didn't contain the glyph, we'd give up. With this change, we try multiple fonts in turn. The font names we try differ across each platform, and based on the codepoint we're trying to match. The current implementation is heavily inspired by the analogous code in Gecko, but I've used to ucd lib to make it more readable, whereas Gecko matches raw unicode ranges. This fixes some of the issues reported in #17267, although colour emoji support is not implemented. == Notes on changes to WPT metadata == === css/css-text/i18n/css3-text-line-break-opclns-* === A bunch of these have started failing on macos when they previously passed. These tests check that the browser automatically inserts line breaks near certain characters that are classified as "opening and closing punctuation". The idea is that if we have e.g. an opening parenthesis, it does not make sense for it to appear at the end of a line box; it should "stick" to the next character and go into the next line box. Before this change, a lot of these codepoints rendered as a missing glyph on Mac and Linux. In some cases, that meant that the test was passing. After this change, a bunch of these codepoints are now rendering glyphs on Mac (but not Linux). In some cases, the test should continue to pass where it previously did when rendering with the missing glyph. However, it seems this has also exposed a layout bug. The "ref" div in these tests contains a <br> element, and it seems that this, combined with these punctuation characters, makes the spacing between glyphs ever so slightly different to the "test" div. (Speculation: might be something to do with shaping?) Therefore I've had to mark a bunch of these tests failing on mac. === css/css-text/i18n/css3-text-line-break-baspglwj-* === Some of these previously passed on Mac due to a missing glyph. Now that we're rendering the correct glyph, they are failing. === css/css-text/word-break/word-break-normal-bo-000.html === The characters now render correctly on Mac, and the test is passing. But we do not find a suitable fallback font on Linux, so it is still failing on that platform. === css/css-text/word-break/word-break-break-all-007.html === This was previously passing on Mac, but only because missing character glyphs were rendered. Now that a fallback font is able to be found, it (correctly) fails. === mozilla/tests/css/font_fallback_* === These are new tests added in this commit. 01 and 02 are marked failing on Linux because the builders don't have the appropriate fonts installed (that will be a follow-up). Fix build errors from rebase FontTemplateDescriptor can no longer just derive(Hash). We need to implement it on each component part, because the components now generally wrap floats, which do not impl Hash because of NaN. However in this case we know that we won't have a NaN, so it is safe to manually impl Hash.
* Add test for FontContext/FontGroup functionalityJon Leighton2018-02-221-14/+27
| | | | | | | | | | | | | | | | | | | | | | Unfortunately, this required quite a bit of changes to the non-test code. That's because FontContext depends on a FontCacheThread, which in turn depends on a CoreResourceThread and therefore lots of other data structures. It seemed like it would be very difficult to instantiate a FontContext as it was, and even if we could it seems like overkill to have all these data structures present for a relatively focused test. Therefore, I created a FontSource trait which represents the interface which FontContext uses to talk to FontCacheThread. FontCacheThread then implements FontSource. Then, in the test, we can create a dummy implementation of FontSource rather than using FontCacheThread. This actually has the advantage that we can make our dummy implementation behave in certain specific way which are useful for testing, for example it can count the number of times find_font_template() is called, which helps us verify that caching/lazy-loading is working as intended.
* Lazy load fonts in a FontGroupJon Leighton2018-02-221-150/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | This is a step towards fixing #17267. To fix that, we need to be able to try various different fallback fonts in turn, which would become unweildy with the prior eager-loading strategy. Prior to this change, FontGroup loaded up all Font instances, including the fallback font, before any of them were checked for the presence of the glyphs we're trying to render. So for the following CSS: font-family: Helvetica, Arial; The FontGroup would contain a Font instance for Helvetica, and a Font instance for Arial, and a Font instance for the fallback font. It may be that Helvetica contains glyphs for every character in the document, and therefore Arial and the fallback font are not needed at all. This change makes the strategy lazy, so that we'll only create a Font for Arial if we cannot find a glyph within Helvetica. I've also substantially refactored the existing code in the process and added some documentation along the way.
* Fix FontTemplateDescriptor under FreeTypeJon Leighton2018-02-071-1/+1
| | | | | | | | | | | | | | Issue #17321. Under Linux, using "font-family: sans-serif" previously caused Servo to select the "UltraLight" face (of DejaVu Sans). There were two reasons for this: 1. Font weight was only retrieved from the OS/2 table for bold faces. This neglected to retrieve the weight information for "lighter than normal" weight faces. This meant that the UltraLight face appeared as normal weight, and was selected. 2. Retrieval of font stretch information from the OS/2 table was not implemented at all.
* style: Make all keywords CamelCase for consistency.Emilio Cobos Álvarez2017-12-061-6/+7
| | | | This prevents confusion and paves the ground for derive(Parse) of them.
* Replace all uses of the `heapsize` crate with `malloc_size_of`.Nicholas Nethercote2017-10-181-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Servo currently uses `heapsize`, but Stylo/Gecko use `malloc_size_of`. `malloc_size_of` is better -- it handles various cases that `heapsize` does not -- so this patch changes Servo to use `malloc_size_of`. This patch makes the following changes to the `malloc_size_of` crate. - Adds `MallocSizeOf` trait implementations for numerous types, some built-in (e.g. `VecDeque`), some external and Servo-only (e.g. `string_cache`). - Makes `enclosing_size_of_op` optional, because vanilla jemalloc doesn't support that operation. - For `HashSet`/`HashMap`, falls back to a computed estimate when `enclosing_size_of_op` isn't available. - Adds an extern "C" `malloc_size_of` function that does the actual heap measurement; this is based on the same functions from the `heapsize` crate. This patch makes the following changes elsewhere. - Converts all the uses of `heapsize` to instead use `malloc_size_of`. - Disables the "heapsize"/"heap_size" feature for the external crates that provide it. - Removes the `HeapSizeOf` implementation from `hashglobe`. - Adds `ignore` annotations to a few `Rc`/`Arc`, because `malloc_size_of` doesn't derive those types, unlike `heapsize`.
* style: Use a SharedFontList object to store font-family values for Gecko.Cameron McCormack2017-10-041-1/+1
|
* stylo: Add keyword info to computed value of font-sizeManish Goregaokar2017-09-231-5/+5
|
* Introduce CSSPixelLength and update NonNegativeLength.Boris Chiou2017-09-131-5/+5
| | | | | | | | | | | First, we define computed::CSSPixelLength which contains a CSSFloat, a pixel value, and then we replace computed::Length with CSSPixelLength. Therefore, the |ComputedValue| of NoCalcLength, AbsoluteLength, FontRelativeLength, ViewportPercentageLength, CharacterWidth, and PhysicalLength is CSSPixelLength. Besides, we drop NonNegativeAu, and replace computed::NonNegativeLength with NonNegative<computed::Length>. (i.e. NonNegative<CSSPixelLength>)
* Update WR (font instance API).Glenn Watson2017-08-311-4/+5
| | | | | | | | | | | | | | | | | | | | WR now has a concept of font templates and font instances. This makes the WR font interfaces closer to Cairo and Gecko, and also makes some future performance optimizations possible. A font template is the font family, and data backing the font. A font instance is a reference to a font template and per-instance options, such as font size, anti-aliasing settings etc. To update Servo in a minimally invasive way, I added a new font cache call, that creates a font instance. This means that when a font is created, and doesn't exist in the cache there are now two calls to the font cache thread. We could refactor the font cache to make this work in one call, which we should do in the future. However, refactoring the font cache is a large chunk of work by itself. The extra call is only when a font doesn't already exist in the font context cache, so it should have minimal performance impact.
* Bug 1374233 - Part 3: Use NonNegativeAu as computed values for font-size ↵Boris Chiou2017-08-041-5/+5
| | | | | | | | related properties. For font-size and font-size-adjust. MozReview-Commit-ID: 5rrfVSzB7WF
* Replace all uses of the style::stylearc alias with servo_arc.Michael Partheil2017-07-191-3/+3
| | | | | | The alias is left there temporarilly and will be removed completely in a later commit where also components/style/gecko/generated/structs_{debug|release}.rs are re-generated (they still use the old alias).
* Upgrade to the latest version of WebRenderMartin Robinson2017-07-131-2/+2
|
* UntrySimon Sapin2017-06-181-2/+2
|
* Fix up script and layout.Bobby Holley2017-05-021-2/+3
|
* Make font-variant shorthand.Hiroyuki Ikezoe2017-04-141-8/+8
|
* Remove unused FontContext::font_cache_thread().Ms2ger2016-10-311-5/+0
|
* Remove always-empty FontContext::paint_font_cache.Ms2ger2016-10-311-17/+0
|
* Remove FontContext::paint_font_from_template.Ms2ger2016-10-311-37/+0
|
* Remove old rendering backend.Glenn Watson2016-10-181-3/+4
| | | | | | | | | | | | | | This removes paint threads, rust-layers dependency, and changes optional webrender types to be required. The use_webrender option has been removed, however I've left the "-w" command line option in place so that wpt runner can continue to pass that. Once it's removed from there we can also remove the -w option. Once this stage is complete, it should be fine to change the display list building code to generate webrender display lists directly and avoid the conversion step.
* Remove the ComputedValue traits and style_struct_traitsSimon Sapin2016-07-201-3/+3
|
* Always include the last-resort fontMatt Brubeck2016-05-241-29/+26
| | | | | This is used as a fallback for any characters that don't have glyphs in the specified font.
* Simplify FontContext::create_layout_font.Ms2ger2016-05-171-5/+4
|
* Make some Font fields privateMatt Brubeck2016-05-131-17/+2
|
* Remove unnecessary ServoFont type aliasMatt Brubeck2016-05-131-5/+4
|
* gfx: Clamp the font size we supply to Core Text to 0.01pt.Patrick Walton2016-04-111-1/+1
| | | | | | | | | | Core Text treats a font size of 0.0 as 12.0, which is obviously not what we want. Improves Twitter. Improves Reddit /r/rust. Closes #10492.
* Add WebRender integration to Servo.Glenn Watson2016-02-181-12/+19
| | | | | | | | WebRender is an experimental GPU accelerated rendering backend for Servo. The WebRender backend can be specified by running Servo with the -w option (otherwise the default rendering backend will be used). WebRender has many bugs, and missing features - but it is usable to browse most websites - please report any WebRender specific rendering bugs you encounter!
* Auto merge of #9523 - ruud-v-a:hasher, r=Wafflespeanutbors-servo2016-02-051-4/+3
|\ | | | | | | | | | | | | | | | | | | Upgrade to new Hasher API This fixes #9494. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9523) <!-- Reviewable:end -->
| * Upgrade to new Hasher APIRuud van Asseldonk2016-02-031-4/+3
| |
* | Say farewell to in-tree HeapSizeOfAnthony Ramine2016-02-041-1/+1
|/
* win32: use fontconfig/freetype on windows as well (for now)Vladimir Vukicevic2016-01-201-2/+2
|
* task -> threadrohan.prinja2016-01-101-12/+12
|
* Remove the fontgroup address cache.Patrick Walton2016-01-061-11/+0
| | | | | | It's not clear to me that it actually helps. Moreover, it's wrong and results in fonts randomly changing e.g. on GitHub when mousing over elements.
* Auto merge of #9070 - antrik:debug-fonts, r=noxbors-servo2016-01-031-0/+5
|\ | | | | | | | | | | | | | | | | | | Derive Debug for more font-related types Needs to pull in newer ipc-channel and azure. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9070) <!-- Reviewable:end -->
| * Derive Debug for more font-related typesOlaf Buddenhagen2016-01-031-0/+5
| |
* | Enabled use of FontFamily enum type and replaced plain string parameters ↵David Raifaizen2015-12-301-3/+1
|/ | | | with enum
* Remove unused imports.Ms2ger2015-12-121-1/+0
|
* Cache font style struct addresses in a separate font group cache.Patrick Walton2015-12-111-10/+8
| | | | | | | On http://en.wikipedia.org/wiki/Spotted_hyena, I was seeing a 100% miss rate in the first fast cache lookup and 45% of total layout time in this function. After making this change, the first cache lookup almost always succeeds, and the time spent in this function drops to 8%.
* Derive PartialEq on the style Font structureAnthony Ramine2015-10-081-6/+1
| | | | We check the hash first.