Skip to content

Commit 89f8801

Browse files
authored
Fonts 2024 Queries (#3696)
* Update font_format_usage_without_services.sql * Update font_size_quantiles.sql * Update font_size_quantiles_by_opentype_table.sql * Update font_size_quantiles_without_services.sql * Update font_usage_by_service.sql * Update font_usage_over_time.sql * Update font_variant_values.sql * Update outline_formats.sql * Make a few cosmetic adjustments to design * Update resource_hints_usage.sql * Make a few cosmetic adjustments to performance * Update usage_by_country.sql * Update usage_of_font_loading_api.sql * Rename the queries in design and performance * Add headers to design * Change sizes_self_hosted.sql to sizes_by_service.sql * Change formats_file_self_hosted.sql to formats_file_by_service.sql * Move pages_style_font_variant.sql to development * Add headers to performance * Remove requests_over_time.sql * Switch to using requests instead of pages * Capitalize functions in design and performance * Update color_font_usage.sql * Update color_fonts.sql * Update color_fonts_emoji_usage.sql * Rename the queries about color fonts * Update font_palettes.sql * Update font_palettes_colors.sql * Make a cosmetic adjustment * Rename another color query * Make a cosmetic adjustment * Update font_feature_settings_tags_usage.sql * Update font_feature_settings_vs_font_variant.sql * Add a few headers * Make a cosmetic adjustment * Update font_kerning.sql * Update pages_style_font_variant.sql * Update font_metric_override_usage.sq * Rename font_metric_override_usage.sql * Make a few cosmetic adjustments * Rename a few queries * Update font_smoothing_usage.sql * Update font_opentype_support.sql * Update font_opentype_features_usage.sql * Update types_of_variable_font.sql * Update variable_font_animation.sql * Update variable_font_axes.sql * Rename a few queries * Rename a few queries * Fix a few typos * Update variable_font_axes_css.sql * Simplify fonts_variable_by_format.sql * Update variable_font_usage.sql * Update variable_font_googlefonts_vs_other.sql * Fix styles in JavaScript * Make a few cosmetic adjustments to performance * Revisit COUNT(0) in design * Revisit COUNT(0) in performance * Revisit COUNT(0) in development * Make a cosmetic adjustment * Rename a few queries * Order by client in design * Add performance/fonts_service_by_family.sql * Add design/fonts_designer.sql * Add fonts/design/pages_script.sql * Update performance/fonts_size_by_country.sql to the latest CrUX * Add design/fonts_license.sql * Update pages_link_relationship.sql to use pages * Add design/fonts_metric.sql * Rename a query * Adjust the query comments * Add design/fonts_family_by_script.sql * Fix a typo * Add development/fonts_compiler.sql * Adjust a few comments * Rename a few queries * Use NAME in two other queries * Add development/fonts_color_family.sql * Introduce VARIABLE_FORMATS and IS_VARIABLE * Add development/fonts_variable_family.sql * Extract common functions into a separate file * Make a few cosmetic adjustments * Add development/fonts_variable_range.sql * Annotate the common functions * Update the readme * Change the date to 2024-07-01 * Revert the definition of Edge Fonts * Add a query for the color distribution * Limit performance/fonts_family_by_service.sql * Adjust the ordering in performance/fonts_size_by_country.sql * Add rounding to the size-related queries * Filter out in performance/fonts_size_by_table.sql * Make a few cosmetic adjustments * Simplify performance/pages_link_relationship.sql * Order in performance/styles_font_display.sql * Adjust the question in performance/fonts_family_by_service.sql * Filter out outliers in performance/fonts_size.sql * Filter out outliers in performance/fonts_size_by_service.sql * Filter out outliers in performance/fonts_size_by_table.sql * Refine FILE_FORMAT * Rebase FILE_FORMAT on summary * Rebase the file size on summary * Change performance/fonts_service.sql to show trends over time * Change performance/fonts_service.sql to show all services used * Debug performance/fonts_service.sql * Update performance/scripts_font_face.sql to show the trend * Check href and as in performance/pages_link_relationship.sql * Update performance/styles_font_display.sql to show the trend * Debug performance/pages_link_relationship.sql * Make a cosmetic adjustment * Adjust FOUNDRY * Adjust the percentiles in design/fonts_metric.sql * Limit to 100 in design/styles_family.sql * Polish JavaScript * Correct the normalization in design/fonts_script.sql * Correct the ranking in performance/fonts_family_by_service.sql * Correct the ranking in design/styles_family.sql * Limit to 100 in design/fonts_license.sql * Make use of FOUNDRY in design/fonts_foundry.sql * Limit to 100 in design/fonts_foundry.sql * Adjust FOUNDRY * Fix the ranking in design/fonts_foundry.sql * Limit to 100 in design/fonts_designer.sql * Adjust FOUNDRY * Adjust FOUNDRY * Fix a typo in development/fonts_variable_family.sql * Limit to the 99th in development/fonts_variable_range.sql * Limit to 100 and 10 in design/fonts_family_by_foundry.sql * Limit to 100 in development/fonts_variable_family.sql * Debug design/fonts_family_by_foundry.sql * Debug development/fonts_opentype.sql * Debug development/fonts_feature_kerning.sql * Rename development/fonts_feature_kerning.sql * Make a few cosmetic adjustments * Limit to 100 in development/fonts_compiler.sql * Debug design/styles_family.sql * Simplify design/fonts_family_by_foundry.sql * Make a cosmetic adjustment * Adjust the sorting in development/styles_font_variant.sql * Adjust the sorting in development/styles_font_feature_settings.sql * Adjust the sorting in development/styles_metric_override.sql * Debug development/styles_feature_control.sql * Extend design/fonts_license.sql * Adjust the sorting in performance/fonts_size_by_country.sql * Limit to 10 in performance/fonts_format_file.sql * Limit to 10 in performance/fonts_format_file_by_service.sql * Remove data from performance/styles_font_display.sql and limit to 10 * Adjust a question * Adjust the sorting in development/styles_feature_control.sql * Break down performance/fonts_size.sql by format * Break down performance/fonts_size_by_service.sql by format * Break down performance/fonts_size_by_country.sql by format * Refine development/fonts_compiler.sql * Refine and clarify the normalization in design * Refine and clarify the normalization in development * Refine and clarify the normalization in performance * Switch performance/fonts_format_file.sql to fonts on pages * Add Pages to performance/fonts_format_file.sql * Reduce design/fonts_family_by_script.sql in half * Introduce performance/fonts_service.sql and performance/fonts_services.sql * Constrain the performance queries to is_root_page * Constrain the design queries to is_root_page * Remove design/pages_script.sql * Constrain the development queries to is_root_page * Limit to 10 in development/styles_smoothing.sql * Rename pages to sites * Rewrite performance/pages_link_relationship.sql to join with requests * Introduce performance/fonts_size_by_format.sql * Sync performance/fonts_format_file_by_service.sql with performance/fonts_format_file.sql * Change the normalization in development/fonts_color_emoji.sql * Add dates to development/fonts_color.sql * Add dates to development/fonts_color_emoji.sql * Add dates to development/fonts_variable.sql * Remove the format from performance/fonts_size_by_country.sql * Rename Fonts on sites to Links * Add more dates to development/fonts_variable_service.sql * Fix the percentage calculation with dates * Clean up performance/styles_font_display.sql * Add more dates to development/fonts_feature_opentype.sql * Add more dates to development/fonts_feature_kerning.sql * Add more dates to development/fonts_variable_format.sql * Correct the normalization in performance/fonts_service.sql * Rename requests to links * Correct the normalization in performance/fonts_format_outline.sql * Rename fonts to links in performance/fonts_format_file_by_service.sql * Correct the normalization in design/fonts_script.sql * Correct the normalization in design/fonts_license.sql * Make a cosmetic adjustment in performance/fonts_size_by_table.sql * Move the totals in performance/fonts_format_file_by_service.sql * Move is_root_page * Move the totals in performance/fonts_format_file.sql * Move the totals in performance/fonts_family_by_service.sql * Correct the normalization in design/fonts_license.sql * Move the totals in design/fonts_family_by_foundry.sql * Move the totals in design/fonts_family_by_script.sql * Change the normalization to Fonts in development/fonts_variable_service.sql * Make a cosmetic adjustment * Move the totals in development/fonts_variable_format.sql * Move the totals in development/fonts_variable_family.sql * Correct the normalization in development/fonts_variable_axis.sql * Move the totals in development/fonts_feature_opentype.sql * Move the totals in development/fonts_feature_kerning.sql * Move the totals in development/fonts_feature.sql * Move the totals in development/fonts_compiler.sql * Move the totals in development/fonts_color_palette.sql * Move the totals in development/fonts_color_format.sql * Move the totals in development/fonts_color_family.sql * Move the totals in development/fonts_color_entry.sql * Move the totals in development/fonts_color_emoji.sql * Move the totals in development/fonts_color_color.sql * Make a few cosmetic adjustments * Make a few cosmetic adjustments * Make a cosmetic adjustment * Exclude non-parseable fonts from the size calculations * Exclude non-parseable fonts in performance/fonts_family_by_service.sql and performance/fonts_format_outline.sql * Exclude non-parseable fonts in design/fonts_*.sql * Remove baseline_at_zero * Normalize metrics by the granularity * Add (parsed only) * Use SAFE_DIVIDE in design/fonts_metric.sql * Exclude non-parseable fonts in development/fonts_*.sql * Add 2022-06-01 to performance/scripts_font_face.sql * Attempt to remove styles in family names * Add a secondary normalization to development/fonts_variable_service.sql * Update development/styles_font_variable_settings_axis.sql to variable sites * Increase to top 100 in performance/fonts_family_by_service.sql * Refine the FAMILY function * Refine the FAMILY function * Clean up design/styles_family.sql * Address a lint * Add granularity to design/fonts_metric.sql * Add performance/fonts.sql * Clean up the foundry names * Update the variable-font animation detection * Add development/fonts_hinting.sql * Drop the downsampling in design/fonts_family_by_script.sql * Add more dates to development/fonts_color_format.sql * Fix the totals in development/fonts_color_format.sql * Provide the full path to the common script * Introduce development/fonts_color_family_by_format.sql * Clean up performance/styles_font_display.sql * Introduce performance/styles_font_display_by_family.sql * Do not limit in development/fonts_color_format_by_family.sq * Refine the definition of COLOR_FORMATS and IS_COLOR * Add more dates to performance/pages_link_relationship.sql * Rename sites and links to websites and requests, respectively * Rename websites to pages * Move fonts_format_outline.sql to development * Move styles_family_system.sql to development * Add examples to development/fonts_color_format_by_family.sql
1 parent 05a096c commit 89f8801

53 files changed

Lines changed: 3199 additions & 13 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

sql/2024/fonts/README.md

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,54 @@
11
# 2024 Fonts queries
22

3-
<!--
4-
This directory contains all of the 2024 Fonts chapter queries.
3+
## Resources
54

6-
Each query should have a corresponding `metric_name.sql` file.
7-
Note that readers are linked to this directory, so try to make the SQL file names descriptive for easy browsing.
5+
* 📄 [Planning document]
6+
* 📊 [Results sheet]
7+
* 📝 [Chapter content]
88

9-
Analysts: if helpful, you can use this README to give additional info about the queries.
10-
-->
9+
## Structure
1110

12-
## Resources
11+
The queries are split by the section where they are used:
12+
13+
* `design/` is about foundries and families,
14+
* `development/` is about tools and technologies, and
15+
* `performance/` is about hosting and serving.
16+
17+
Each file name starts with one of the following prefixes indicating the primary
18+
subject of the corresponding analysis:
19+
20+
* `fonts_` is about font files,
21+
* `pages_` is about HTML pages,
22+
* `scripts_` is about JavaScript scripts, and
23+
* `styles_` is about CSS style sheets.
24+
25+
The prefix is followed by the property studied given in singular, potentially
26+
extended one or several suffixes narrowing down the scope, as in
27+
`fonts_size_by_table.sql` and `pages_link_relation.sql`.
28+
29+
## Contents
30+
31+
Each query starts with a preamble indicating the section, question, and
32+
normalization type:
33+
34+
```sql
35+
-- Section: Performance
36+
-- Question: What is the distribution of the file size broken down by table?
37+
-- Normalization: Pages
38+
```
39+
40+
Many queries rely on temporary functions for convenience and clarity. The
41+
functions appear in several queries are extracted into a common file:
42+
`common.sql`. Whenever any of the functions defined in `common.sql` is used by a
43+
query, the query has the following line at the top:
44+
45+
```sql
46+
-- INCLUDE https://github.com/HTTPArchive/almanac.httparchive.org/blob/main/sql/2024/fonts/common.sql
47+
```
1348

14-
- [📄 Planning doc][~google-doc]
15-
- [📊 Results sheet][~google-sheets]
16-
- [📝 Markdown file][~chapter-markdown]
49+
It signalizes that, prior to executing the query, `common.sql` has to be
50+
inlined.
1751

18-
[~google-doc]: https://docs.google.com/document/d/1ljEHbDvXComXnW5s_EXZ0nM3_JCLnYr28Xrcf0YYtP8/edit#heading=h.vp0ukb2pxxzp
19-
[~google-sheets]: https://docs.google.com/spreadsheets/d/1EkdvJ8e0B9Rr42evC2Ds5Ekwq6gF9oLBW0BA5cmSUT4/edit#gid=1778117656
20-
[~chapter-markdown]: https://github.com/HTTPArchive/almanac.httparchive.org/tree/main/src/content/en/2024/fonts.md
52+
[Planning document]: https://docs.google.com/document/d/1ljEHbDvXComXnW5s_EXZ0nM3_JCLnYr28Xrcf0YYtP8/edit
53+
[Results sheet]: https://docs.google.com/spreadsheets/d/1EkdvJ8e0B9Rr42evC2Ds5Ekwq6gF9oLBW0BA5cmSUT4/edit
54+
[Chapter content]: https://github.com/HTTPArchive/almanac.httparchive.org/tree/main/src/content/en/2024/fonts.md

sql/2024/fonts/common.sql

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
-- Normalize a family name. Used in FAMILY_INNER.
2+
CREATE TEMPORARY FUNCTION FAMILY_INNER_INNER(name STRING) AS (
3+
CASE
4+
WHEN REGEXP_CONTAINS(name, r'(?i)font\s?awesome') THEN 'Font Awesome'
5+
ELSE IF(LENGTH(TRIM(name)) < 3, NULL, NULLIF(TRIM(name), ''))
6+
END
7+
);
8+
9+
-- Normalize a family name. Used in FAMILY.
10+
CREATE TEMPORARY FUNCTION FAMILY_INNER(name STRING) AS (
11+
FAMILY_INNER_INNER(
12+
REGEXP_REPLACE(
13+
name,
14+
r'(?i)([\s-]?(black|bold|book|cond(ensed)?|demi|ex(tra)?|heavy|italic|light|medium|narrow|regular|semi|thin|ultra|wide|\d00|\d+pt))+$',
15+
''
16+
)
17+
)
18+
);
19+
20+
-- Extract the family name from a payload.
21+
CREATE TEMPORARY FUNCTION FAMILY(payload STRING) AS (
22+
FAMILY_INNER(
23+
COALESCE(
24+
JSON_EXTRACT_SCALAR(payload, '$._font_details.names[16]'),
25+
JSON_EXTRACT_SCALAR(payload, '$._font_details.names[1]')
26+
)
27+
)
28+
);
29+
30+
-- Extract the file format from an extension and a MIME type.
31+
CREATE TEMPORARY FUNCTION FILE_FORMAT(extension STRING, type STRING) AS (
32+
LOWER(IFNULL(REGEXP_EXTRACT(type, '/(?:x-)?(?:font-)?(.*)'), extension))
33+
);
34+
35+
-- Normalize a foundry name. Used in FOUNDRY.
36+
CREATE TEMPORARY FUNCTION FOUNDRY_INNER(name STRING) AS (
37+
CASE UPPER(name)
38+
WHEN 'ADBO' THEN 'ADBE'
39+
WHEN 'PFED' THEN 'AWSM'
40+
ELSE NULLIF(TRIM(REGEXP_REPLACE(name, r'[[:cntrl:]]+', '')), '')
41+
END
42+
);
43+
44+
-- Extract the foundry name from a payload.
45+
CREATE TEMPORARY FUNCTION FOUNDRY(payload STRING) AS (
46+
FOUNDRY_INNER(JSON_EXTRACT_SCALAR(payload, '$._font_details.OS2.achVendID'))
47+
);
48+
49+
-- Infer scripts from codepoints. Used in SCRIPTS.
50+
CREATE TEMPORARY FUNCTION SCRIPTS_INNER(codepoints ARRAY<STRING>)
51+
RETURNS ARRAY<STRING>
52+
LANGUAGE js
53+
OPTIONS (library = ["gs://httparchive/lib/text-utils.js"])
54+
AS r"""
55+
if (codepoints && codepoints.length) {
56+
return detectWritingScript(codepoints.map((character) => parseInt(character, 10)), 0.05);
57+
} else {
58+
return [];
59+
}
60+
""";
61+
62+
-- Infer scripts from a payload.
63+
CREATE TEMPORARY FUNCTION SCRIPTS(payload STRING) AS (
64+
SCRIPTS_INNER(JSON_EXTRACT_STRING_ARRAY(payload, '$._font_details.cmap.codepoints'))
65+
);
66+
67+
-- Infer the service from a URL.
68+
CREATE TEMPORARY FUNCTION SERVICE(url STRING) AS (
69+
CASE
70+
WHEN REGEXP_CONTAINS(url, r'(fonts|use)\.typekit\.(net|com)') THEN 'Adobe'
71+
WHEN REGEXP_CONTAINS(url, r'cloud\.typenetwork\.com') THEN 'typenetwork.com'
72+
WHEN REGEXP_CONTAINS(url, r'cloud\.typography\.com') THEN 'typography.com'
73+
WHEN REGEXP_CONTAINS(url, r'cloud\.webtype\.com') THEN 'webtype.com'
74+
WHEN REGEXP_CONTAINS(url, r'f\.fontdeck\.com') THEN 'fontdeck.com'
75+
WHEN REGEXP_CONTAINS(url, r'fast\.fonts\.(com|net)\/(jsapi|cssapi)') THEN 'fonts.com'
76+
WHEN REGEXP_CONTAINS(url, r'fnt\.webink\.com') THEN 'webink.com'
77+
WHEN REGEXP_CONTAINS(url, r'fontawesome\.com') THEN 'fontawesome.com'
78+
WHEN REGEXP_CONTAINS(url, r'fonts\.(gstatic|googleapis)\.com|themes.googleusercontent.com/static/fonts|ssl.gstatic.com/fonts') THEN 'Google'
79+
WHEN REGEXP_CONTAINS(url, r'fonts\.typonine\.com') THEN 'typonine.com'
80+
WHEN REGEXP_CONTAINS(url, r'fonts\.typotheque\.com') THEN 'typotheque.com'
81+
WHEN REGEXP_CONTAINS(url, r'kernest\.com') THEN 'kernest.com'
82+
WHEN REGEXP_CONTAINS(url, r'typefront\.com') THEN 'typefront.com'
83+
WHEN REGEXP_CONTAINS(url, r'typesquare\.com') THEN 'typesquare.com'
84+
WHEN REGEXP_CONTAINS(url, r'use\.edgefonts\.net|webfonts\.creativecloud\.com') THEN 'edgefonts.net'
85+
WHEN REGEXP_CONTAINS(url, r'webfont\.fontplus\.jp') THEN 'fontplus.jp'
86+
WHEN REGEXP_CONTAINS(url, r'webfonts\.fontslive\.com') THEN 'fontslive.com'
87+
WHEN REGEXP_CONTAINS(url, r'webfonts\.fontstand\.com') THEN 'fontstand.com'
88+
WHEN REGEXP_CONTAINS(url, r'webfonts\.justanotherfoundry\.com') THEN 'justanotherfoundry.com'
89+
ELSE 'self-hosted'
90+
END
91+
);
92+
93+
-- Extract the color formats from a formats payload and remove spurious entries
94+
-- via a table-sizes payload.
95+
--
96+
-- When nonempty, it is expected that
97+
--
98+
-- * `CBDT` is larger than 2 + 2 bytes,
99+
-- * `COLR` is larger than 2 + 2 + 4 + 4 + 2 (+ 4 + 4 + 4 + 4 + 4) bytes,
100+
-- * `SVG ` is larger than 2 + 4 + 4 + 2 bytes, and
101+
-- * `sbix` is larger than 2 + 2 + 4 + 4 bytes.
102+
--
103+
-- For simplicity, the threshold is set to 50 bytes.
104+
CREATE TEMPORARY FUNCTION COLOR_FORMATS_INNER(jsonFormats STRING, jsonSizes STRING)
105+
RETURNS ARRAY<STRING>
106+
LANGUAGE js AS '''
107+
try {
108+
const formats = JSON.parse(jsonFormats);
109+
const sizes = JSON.parse(jsonSizes);
110+
return formats.filter((format) => {
111+
const table = `${format} `.slice(0, 4);
112+
return sizes[table] > 50;
113+
});
114+
} catch (e) {
115+
return [];
116+
}
117+
''';
118+
119+
-- Extract the color formats from a payload.
120+
CREATE TEMPORARY FUNCTION COLOR_FORMATS(payload STRING) AS (
121+
COLOR_FORMATS_INNER(
122+
JSON_EXTRACT(payload, '$._font_details.color.formats'),
123+
JSON_EXTRACT(payload, '$._font_details.table_sizes')
124+
)
125+
);
126+
127+
-- Check if the font is a color font given its payload.
128+
CREATE TEMPORARY FUNCTION IS_COLOR(payload STRING) AS (
129+
ARRAY_LENGTH(COLOR_FORMATS(payload)) > 0
130+
);
131+
132+
-- Check if the font was successfully parsed given its payload.
133+
CREATE TEMPORARY FUNCTION IS_PARSED(payload STRING) AS (
134+
JSON_EXTRACT(payload, '$._font_details.table_sizes') IS NOT NULL
135+
);
136+
137+
-- Check if the font is a variable font given its payload.
138+
CREATE TEMPORARY FUNCTION IS_VARIABLE(payload STRING) AS (
139+
REGEXP_CONTAINS(
140+
JSON_EXTRACT(payload, '$._font_details.table_sizes'),
141+
'(?i)gvar|CFF2'
142+
)
143+
);
144+
145+
-- Extract the variable formats from a payload.
146+
CREATE TEMPORARY FUNCTION VARIABLE_FORMATS(payload STRING) AS (
147+
REGEXP_EXTRACT_ALL(
148+
JSON_EXTRACT(payload, '$._font_details.table_sizes'),
149+
'(?i)glyf|CFF2'
150+
)
151+
);
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
-- Section: Design
2+
-- Question: Which designers are popular?
3+
-- Normalization: Pages
4+
5+
-- INCLUDE https://github.com/HTTPArchive/almanac.httparchive.org/blob/main/sql/2024/fonts/common.sql
6+
7+
WITH
8+
designers AS (
9+
SELECT
10+
client,
11+
NULLIF(TRIM(JSON_EXTRACT_SCALAR(payload, '$._font_details.names[9]')), '') AS designer,
12+
COUNT(DISTINCT page) AS count,
13+
ROW_NUMBER() OVER (PARTITION BY client ORDER BY COUNT(DISTINCT page) DESC) AS rank
14+
FROM
15+
`httparchive.all.requests`
16+
WHERE
17+
date = '2024-07-01' AND
18+
type = 'font' AND
19+
is_root_page AND
20+
IS_PARSED(payload)
21+
GROUP BY
22+
client,
23+
designer
24+
QUALIFY
25+
rank <= 100
26+
),
27+
pages AS (
28+
SELECT
29+
client,
30+
COUNT(DISTINCT page) AS total
31+
FROM
32+
`httparchive.all.requests`
33+
WHERE
34+
date = '2024-07-01' AND
35+
is_root_page
36+
GROUP BY
37+
client
38+
)
39+
40+
SELECT
41+
client,
42+
designer,
43+
count,
44+
total,
45+
count / total AS proportion
46+
FROM
47+
designers
48+
JOIN
49+
pages USING (client)
50+
ORDER BY
51+
client,
52+
proportion DESC
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
-- Section: Design
2+
-- Question: Which families are used broken down by foundry?
3+
-- Normalization: Requests (parsed only)
4+
5+
-- INCLUDE https://github.com/HTTPArchive/almanac.httparchive.org/blob/main/sql/2024/fonts/common.sql
6+
7+
WITH
8+
requests AS (
9+
SELECT
10+
client,
11+
FOUNDRY(payload) AS foundry,
12+
FAMILY(payload) AS family,
13+
COUNT(0) OVER (PARTITION BY client) AS total
14+
FROM
15+
`httparchive.all.requests`
16+
WHERE
17+
date = '2024-07-01' AND
18+
type = 'font' AND
19+
IS_PARSED(payload) AND
20+
is_root_page
21+
)
22+
23+
SELECT
24+
client,
25+
foundry,
26+
family,
27+
COUNT(0) AS count,
28+
total,
29+
COUNT(0) / total AS proportion,
30+
ROW_NUMBER() OVER (PARTITION BY client ORDER BY COUNT(0) DESC) AS rank
31+
FROM
32+
requests
33+
GROUP BY
34+
client,
35+
foundry,
36+
family,
37+
total
38+
QUALIFY
39+
rank <= 100
40+
ORDER BY
41+
client,
42+
proportion DESC
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
-- Section: Design
2+
-- Question: Which families are used broken down by script?
3+
-- Normalization: Requests (parsed only)
4+
5+
-- INCLUDE https://github.com/HTTPArchive/almanac.httparchive.org/blob/main/sql/2024/fonts/common.sql
6+
7+
WITH
8+
requests AS (
9+
SELECT
10+
client,
11+
SCRIPTS(payload) AS scripts,
12+
FAMILY(payload) AS family,
13+
COUNT(0) OVER (PARTITION BY client) AS total
14+
FROM
15+
`httparchive.all.requests`
16+
WHERE
17+
date = '2024-07-01' AND
18+
type = 'font' AND
19+
is_root_page AND
20+
IS_PARSED(payload)
21+
)
22+
23+
SELECT
24+
client,
25+
script,
26+
family,
27+
COUNT(0) AS count,
28+
total,
29+
COUNT(0) / total AS proportion,
30+
ROW_NUMBER() OVER (PARTITION BY client, script ORDER BY COUNT(0) DESC) AS rank
31+
FROM
32+
requests,
33+
UNNEST(scripts) AS script
34+
WHERE
35+
family != 'Adobe Blank'
36+
GROUP BY
37+
client,
38+
script,
39+
family,
40+
requests.total
41+
QUALIFY
42+
rank <= 10
43+
ORDER BY
44+
client,
45+
script,
46+
proportion DESC

0 commit comments

Comments
 (0)