Commit graph

135 commits

Author SHA1 Message Date
Simon Sapin
6319ad0124 FreeType: don’t use usable_size() as deallocation size
Instead use C-level malloc()/free() so that the size doesn’t need
to be known during deallocation, since FreeType doesn’t provide it.

Hopefully fixes https://github.com/servo/servo/issues/19058
2017-10-30 18:22:30 +01:00
Matt Brubeck
865e81749a Use actual size for old allocation in ft_realloc.
Prevents crashes from improperly freed memory.

Fixes #19008, fixes #18950, fixes #18949.
2017-10-24 15:45:31 -07:00
Simon Sapin
959ce482dd Stop relying on linking details of std’s default allocator
We’ve been bitten before by symbol names changing:
https://github.com/servo/heapsize/pull/46
and upstream is planning to stop using jemalloc by default:
https://github.com/rust-lang/rust/issues/33082#issuecomment-309781465

So use the (relatively) new `#[global_allocator]` attribute
to explicitly select the system allocator on Windows
and jemalloc (now in an external crate) on other platforms.
This choice matches current defaults.
2017-10-19 09:52:50 +02:00
Nicholas Nethercote
4506f0d30c Replace all uses of the heapsize crate with malloc_size_of.
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`.
2017-10-18 22:20:37 +11:00
tigercosmos
81ed4ea7be clean up cjk for os 2017-10-18 00:50:03 +08:00
Simon Sapin
ff23a8536e Abuse Vec as an allocator in gfx 2017-10-13 11:11:00 +02:00
Simon Sapin
aa5761a5fb Remove usage of unstable box syntax, except in the script crate
… because there’s a lot of it,
and script still uses any other unstable features anyway.
2017-10-12 12:10:56 +02:00
Clément DAVID
c5fe235112 order derivable traits lists
Ignoring :
 - **generated**.rs
 - python/tidy/servo_tidy_tests/rust_tidy.rs
2017-08-23 21:38:44 +02:00
bors-servo
af48b42c57 Auto merge of #17706 - glennw:linux-fonts, r=stshine,emilio
Improve font layout in Linux / Freetype platforms.

This patch contains two small changes:

* Fix the font size calculation that is passed to Freetype. This
  now matches exactly how Webrender and Gecko calculate font size
  to pass to layout.
* Enable light hinting by default for fonts when using Freetype.
  We should make this configurable in the future, but this is a
  better default than no hinting (and matches what most Linux
  distros default to).

These two changes (along with the pending WR update) fix a lot
of the font layout issues on Linux. There is still at least one
remaining issue with hidpi displays on Linux that will be fixed
in a follow up patch.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17706)
<!-- Reviewable:end -->
2017-07-13 16:13:41 -07:00
Glenn Watson
83e5a82388 Improve font layout in Linux / Freetype platforms.
This patch contains two small changes:

* Fix the font size calculation that is passed to Freetype. This
  now matches exactly how Webrender and Gecko calculate font size
  to pass to layout.
* Enable light hinting by default for fonts when using Freetype.
  We should make this configurable in the future, but this is a
  better default than no hinting (and matches what most Linux
  distros default to).

These two changes (along with the pending WR update) fix a lot
of the font layout issues on Linux. There is still at least one
remaining issue with hidpi displays on Linux that will be fixed
in a follow up patch.
2017-07-14 08:40:10 +10:00
Simon Sapin
db1a3e54b0 Use heap API from std rather than the alloc crate 2017-07-13 15:26:40 +02:00
Anthony Ramine
612dbb868d Update to rustc 1.20.0-nightly (f85579d4a 2017-07-12) 2017-07-13 15:20:51 +02:00
bors-servo
173181a491 Auto merge of #17694 - glennw:webrender-update, r=glennw
Upgrade to the latest version of WebRender

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17694)
<!-- Reviewable:end -->
2017-07-12 21:52:27 -07:00
Martin Robinson
e58e8ab42e Upgrade to the latest version of WebRender 2017-07-13 07:44:08 +10:00
Emilio Cobos Álvarez
dc28d6244c
Revert "Auto merge of #17633 - servo:rustup, r=nox"
This reverts commit 327e72aa14, reversing
changes made to eec51cdd57.
2017-07-12 23:00:07 +02:00
Simon Sapin
665e9203a1 Upgrade to rustc 1.20.0-nightly (696412de7 2017-07-06) 2017-07-07 15:28:22 +02:00
Xidorn Quan
8b842f5417 Use integer for specified and computed font-weight 2017-07-06 15:31:24 +10:00
Simon Sapin
316cd35767 Untry 2017-06-18 13:21:51 +02:00
Bastien Orivel
76d8573393 Bump serde to 1.0 2017-06-16 13:31:18 +02:00
hinaria
ead828d992 scale line gap by em size 2017-06-15 23:46:17 +10:00
Imanol Fernandez
19fbec9d54 Ged rid of libfontconfig in Android. Query available fonts from Android system font configuration files. 2017-06-02 18:40:08 +02:00
alfredoyang
13dd197c96 Use NativeFontHandle instead of CGFont 2017-04-21 13:21:25 +10:00
Dominik Boehi
ecab3cd796 Fix panic when font face name is not available 2017-04-12 20:36:27 +02:00
Anthony Ramine
bba0be13dd Make ServoUrl::as_url return a &Url 2017-03-23 15:37:32 +01:00
Jonathan Turner
cf911cef28 Change windows font metrics 2017-03-20 11:57:39 +13:00
Anthony Ramine
fe3f4ff0c2 Update serde to 0.9 (fixes #15325) 2017-02-18 21:09:46 +01:00
Tetsuharu OHZEKI
550d726ad2 Use 'alloc' gate only for platforms which use freetype in gfx 2017-02-07 01:32:19 +09:00
Ms2ger
14fe337866 Update rustc to 1.16.0-nightly (7821a9b99 2017-01-23). 2017-01-24 11:02:51 +01:00
Vladimir Vukicevic
a9611c31a7 Implement downloadable fonts on Windows 2017-01-18 13:30:58 -05:00
Emilio Cobos Álvarez
65c388cd06
gfx: Use proper freetype bindings. 2017-01-16 20:49:07 +01:00
Emilio Cobos Álvarez
39e082af18
gfx: Simplify OSX font template bytes accessor. 2016-12-25 19:18:31 +01:00
Emilio Cobos Álvarez
913c874cb5
Urlmageddon: Use refcounted urls more often. 2016-11-17 18:34:23 +01:00
UK992
b4b8ccd7cd Remove dummy fonts from gfx 2016-11-13 17:50:31 +01:00
Vladimir Vukicevic
473df194fc tidy and warning fixes 2016-11-10 16:07:40 -05:00
Vladimir Vukicevic
db357b0334 DirectWrite font backend for Windows 2016-11-10 14:58:51 -05:00
Simon Sapin
53b638c0e2 Update to string-cache 0.3 2016-11-03 16:23:05 +01:00
Simon Sapin
5bb4c6c884 Use heapsize_derive instead of heapsize_plugin 2016-11-03 01:10:32 +01:00
Patrick Walton
56b41fa2ea gfx: On the Mac, take the scale into account when determining the
x-height of a font.
2016-10-11 12:36:19 -07:00
Glenn Watson
0849607239 Minimal Win32 font platform implementation.
This uses a (very simple) Win32 API call to enumerate font
families available, and load them as byte buffers.

The font rasterization itself is done by freetype.

This gets Servo + WR + Windows working, but should be improved
by adding a proper implementation that matches fonts correctly
and also uses DirectWrite (or GDI) to handle font rasterization.
2016-10-05 07:46:02 +10:00
Josh Matthews
d985741701 Make dummy font implementation conform to API changes. 2016-09-19 14:38:36 -04:00
bors-servo
a82d5106bd Auto merge of #12076 - jdm:font-load, r=pcwalton
Make font template data load fallible

Remove a TODO around dealing with a failed file operation.

Can we write an automated test for this? I don't really know what font template data is, but this failure seems to be fontconfig-specific...

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #12037
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12076)
<!-- Reviewable:end -->
2016-09-19 09:14:55 -05:00
UK992
93a103ba73 Reorder use statements 2016-09-09 04:55:19 +02:00
Vladimir Vukicevic
5bbec7469d Native MSVC windows build, convert to cmake 2016-08-17 09:50:51 -04:00
Matt Brubeck
5582fcc219 Bail out gracefully on malformed kern table headers.
Fixes #12081.
2016-07-06 08:16:37 -07:00
Josh Matthews
fb943ab54b Make font template data load fallible. Fixes #12037. 2016-07-05 10:02:40 -04:00
Ms2ger
50e1e8bf02 Make the gfx::platform module private. 2016-06-05 12:31:53 +02:00
Ms2ger
2767133ff3 Move c_str_to_string to its only consumer. 2016-06-05 12:31:52 +02:00
Ms2ger
24546b4da2 Use snake case in freetype. 2016-06-05 11:47:12 +02:00
Cullen Rhodes
40acd24e8f Report use statements that use {} with only one entry 2016-05-27 10:18:44 +01:00
Matt Brubeck
5991afafa4 Add a fast path for shaping ASCII text 2016-05-20 16:47:01 -07:00