Commit graph

10 commits

Author SHA1 Message Date
Simon Wülker
3d320fa96a
Update rustfmt to the 2024 style edition (#35764)
* Use 2024 style edition

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Reformat all code

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-03-03 11:26:53 +00:00
chickenleaf
1ae90dcd95
clippy: Fix a variety of clippy warnings in fonts, layout_2020 and the DOM code (#33894)
* fixed some clippy warnings

Signed-off-by: L Ashwin B <lashwinib@gmail.com>

* Delete extra file

Signed-off-by: chickenleaf <lashwinib@gmail.com>

* preserved newline in compositionevent.rs

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: chickenleaf <lashwinib@gmail.com>

* removed the newline in PrototypeList

Signed-off-by: L Ashwin B <lashwinib@gmail.com>

* removed the trailing whitespace

Signed-off-by: L Ashwin B <lashwinib@gmail.com>

---------

Signed-off-by: L Ashwin B <lashwinib@gmail.com>
Signed-off-by: chickenleaf <lashwinib@gmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-10-18 13:57:13 +00:00
Martin Robinson
0553789d48
fonts: Instantiate system fonts using system font loaders (#33747)
System fonts used to be instantiated using the system font loader and
this change restores that behavior. In addition, on macOS and FreeType
platforms font data for system fonts is loaded using memory mapping. The
benefit is that system font loaders typically are able to cache fonts in
system memory (using memory mapping, for instance) and we'd like to load
them in a the way most compatible with other applications.

On my Linux system, this manages to get the overhead of loading a very
large font down from 10ms to approximately 1ms. Subsequent runs show
even less overhead. We've measured similar gains on macOS systems.

Currently, system font data must be loaded into memory manually for
canvas and this is unlikely to change even with a switch to `vello`. The
use of explicit memmory mapping should help in this case -- though it
probably won't be possible to use this properly on macOS and Windows if
we ever want to load fonts from TTCs properly.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-10-10 23:09:51 +00:00
chickenleaf
9862df877d
Fix clamp-like pattern warning in font.rs (#33705)
Signed-off-by: L Ashwin B <lashwinib@gmail.com>
2024-10-08 10:18:53 +00:00
Martin Robinson
64f32f7ab3
fonts: Make fast shaping determination platform-independent (#33540)
This makes the determination of whether or not to use fast shaping
platform independent. Previously it was less stringent for Windows,
leading to using it in cases where a font had a GSUB or GPOS table --
which broke proper shaping.

In addition, the test is made platform independent and expanded to be
more complete.

Finally, comments are added indicating that "fast shaping" will be
removed.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-09-25 10:00:36 +00:00
Cristian Brinza
4ae2610c24
fonts: Enable fast text shaping on Windows (#33123)
* Use patched dwrote

Signed-off-by: crbrz <cristianb@gmail.com>

* Enable fast text shaping

Signed-off-by: crbrz <cristianb@gmail.com>

* Add fast text shape test

Signed-off-by: crbrz <cristianb@gmail.com>

* Update dwrote to 0.11.1

Signed-off-by: crbrz <cristianb@gmail.com>

---------

Signed-off-by: crbrz <cristianb@gmail.com>
2024-08-30 23:16:26 +00:00
Martin Robinson
78e2691d3f
shaping: Don't assume there's a space glyph when rendering tabs (#32979)
Previously if a font didn't have a space advance and it was needed to
make advances for tabs, Servo would try to read the advance from the
font. If the font didn't have a space glyph, Servo would panic. This
fixes that issue by making the space advance part of the `FontMetrics`
of a font (like Gecko) and falling back properly if that glyph doesn't
exist. The rendered glyph is still the "space" glyph, but we make
sure to select a font that supports that glyph explicitly.

This prevents a crash, but tabs still aren't handled properly. In
reality, tab stops should be calculated in layout and the size of
the space character of the current font shouldn't come into play.
The addition of the space advance metric will make this easier.

Fixes #32970.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-08-23 11:17:44 +00:00
Cristian Brinza
8f82b2a7cb
Use FontInstanceFlags::SUBPIXEL_POSITION for font instances on Windows (#33045)
Signed-off-by: crbrz <cristianb@gmail.com>
2024-08-15 10:25:57 +00:00
Chocolate Pie
1223335547
enhance: Implement CanvasRenderingContext2D.measureText (#32704)
Signed-off-by: Chocolate Pie <106949016+chocolate-pie@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-07-17 19:20:18 +00:00
Martin Robinson
cd2ab36759
Rename gfx to fonts (#32556)
This crate only takes care of fonts now as graphics related things are
split into other crates. In addition, this exposes data structures at
the top of the crate, hiding the implementation details and making it
simpler to import them.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-06-19 20:26:19 +00:00
Renamed from components/gfx/platform/windows/font.rs (Browse further)