mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
LibGfx: Take into account unicode ranges to find font for space glyph
Instead of assuming that the first font in the cascade font list will have a glyph for space, we need to find it in the list taking into account unicode ranges.
This commit is contained in:
parent
8b32f4ae7a
commit
5c02b960ab
13
Tests/LibWeb/Ref/reference/space-glyph-width-ref.html
Normal file
13
Tests/LibWeb/Ref/reference/space-glyph-width-ref.html
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
.text {
|
||||||
|
font-size: 100px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="text">A B</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
21
Tests/LibWeb/Ref/space-glyph-width.html
Normal file
21
Tests/LibWeb/Ref/space-glyph-width.html
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link rel="match" href="reference/space-glyph-width-ref.html" />
|
||||||
|
<style>
|
||||||
|
@font-face {
|
||||||
|
font-family: 'HashFont';
|
||||||
|
src: url('assets/HashSans.woff');
|
||||||
|
unicode-range: U+0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
font-family: 'HashFont', 'SerenitySans';
|
||||||
|
font-size: 100px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="text">A B</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -105,7 +105,8 @@ Variant<DrawGlyph, DrawEmoji> prepare_draw_glyph_or_emoji(FloatPoint point, Utf8
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
void for_each_glyph_position(FloatPoint baseline_start, Utf8View string, FontCascadeList const& font_list, Callback callback, IncludeLeftBearing include_left_bearing = IncludeLeftBearing::No, Optional<float&> width = {})
|
void for_each_glyph_position(FloatPoint baseline_start, Utf8View string, FontCascadeList const& font_list, Callback callback, IncludeLeftBearing include_left_bearing = IncludeLeftBearing::No, Optional<float&> width = {})
|
||||||
{
|
{
|
||||||
float space_width = font_list.first().glyph_width(' ') + font_list.first().glyph_spacing();
|
auto const& space_glyph_font = font_list.font_for_code_point(' ');
|
||||||
|
float space_width = space_glyph_font.glyph_width(' ') + space_glyph_font.glyph_spacing();
|
||||||
|
|
||||||
u32 last_code_point = 0;
|
u32 last_code_point = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue