|
1 | 1 | # Copyright 2015,2026 AeonGames, Rodrigo Hernandez |
2 | 2 | # Licensed under the terms of the Apache 2.0 License. |
3 | 3 | # |
4 | | -# Open Sans is licensed under the Apache License, Version 2.0. |
5 | | -# https://github.com/google/fonts/blob/main/ofl/opensans/OFL.txt |
6 | | - |
7 | | -set(OPENSANS_FONT_DIR "${CMAKE_BINARY_DIR}/bin/fonts") |
8 | | -file(MAKE_DIRECTORY "${OPENSANS_FONT_DIR}") |
| 4 | +# Downloads at least one representative font for every CSS generic |
| 5 | +# font family so the test suite (and demos) always have something |
| 6 | +# for the FontDatabase to match against, regardless of the host's |
| 7 | +# system fonts. All fonts below are OFL or Apache 2.0 licensed. |
| 8 | +# |
| 9 | +# sans-serif -> Open Sans (Apache 2.0) |
| 10 | +# serif -> Noto Serif (OFL) |
| 11 | +# monospace -> Roboto Mono (Apache 2.0) |
| 12 | +# cursive -> Caveat (OFL) |
| 13 | +# fantasy -> Bungee (OFL) |
| 14 | +# |
| 15 | +# Files land in <build>/bin/fonts/ which FontDatabase auto-scans on |
| 16 | +# Initialize(). |
9 | 17 |
|
10 | | -set(OPENSANS_REGULAR "${OPENSANS_FONT_DIR}/OpenSans[wdth,wght].ttf") |
11 | | -set(OPENSANS_ITALIC "${OPENSANS_FONT_DIR}/OpenSans-Italic[wdth,wght].ttf") |
| 18 | +set(AEONGUI_FONT_DIR "${CMAKE_BINARY_DIR}/bin/fonts") |
| 19 | +file(MAKE_DIRECTORY "${AEONGUI_FONT_DIR}") |
12 | 20 |
|
13 | | -if(NOT EXISTS "${OPENSANS_REGULAR}") |
14 | | - message(STATUS "Downloading Open Sans (Regular)...") |
15 | | - file(DOWNLOAD |
16 | | - "https://github.com/google/fonts/raw/main/ofl/opensans/OpenSans%5Bwdth%2Cwght%5D.ttf" |
17 | | - "${OPENSANS_REGULAR}" |
18 | | - STATUS download_status |
19 | | - SHOW_PROGRESS) |
20 | | - list(GET download_status 0 download_status_code) |
21 | | - if(download_status_code) |
22 | | - file(REMOVE "${OPENSANS_REGULAR}") |
23 | | - message(WARNING "Failed to download Open Sans Regular: ${download_status}") |
| 21 | +# _aeongui_download_font(<label> <url> <output-path>) |
| 22 | +# |
| 23 | +# Downloads <url> into <output-path> if the file does not already |
| 24 | +# exist. Removes a partial file and emits a warning on failure so |
| 25 | +# subsequent configures retry without breaking the build. |
| 26 | +function(_aeongui_download_font label url output) |
| 27 | + if(EXISTS "${output}") |
| 28 | + return() |
24 | 29 | endif() |
25 | | -endif() |
26 | | - |
27 | | -if(NOT EXISTS "${OPENSANS_ITALIC}") |
28 | | - message(STATUS "Downloading Open Sans (Italic)...") |
| 30 | + message(STATUS "Downloading ${label}...") |
29 | 31 | file(DOWNLOAD |
30 | | - "https://github.com/google/fonts/raw/main/ofl/opensans/OpenSans-Italic%5Bwdth%2Cwght%5D.ttf" |
31 | | - "${OPENSANS_ITALIC}" |
| 32 | + "${url}" |
| 33 | + "${output}" |
32 | 34 | STATUS download_status |
33 | 35 | SHOW_PROGRESS) |
34 | 36 | list(GET download_status 0 download_status_code) |
35 | 37 | if(download_status_code) |
36 | | - file(REMOVE "${OPENSANS_ITALIC}") |
37 | | - message(WARNING "Failed to download Open Sans Italic: ${download_status}") |
| 38 | + file(REMOVE "${output}") |
| 39 | + message(WARNING "Failed to download ${label}: ${download_status}") |
38 | 40 | endif() |
39 | | -endif() |
| 41 | +endfunction() |
| 42 | + |
| 43 | +# sans-serif |
| 44 | +_aeongui_download_font( |
| 45 | + "Open Sans (Regular)" |
| 46 | + "https://github.com/google/fonts/raw/main/ofl/opensans/OpenSans%5Bwdth%2Cwght%5D.ttf" |
| 47 | + "${AEONGUI_FONT_DIR}/OpenSans[wdth,wght].ttf") |
| 48 | + |
| 49 | +_aeongui_download_font( |
| 50 | + "Open Sans (Italic)" |
| 51 | + "https://github.com/google/fonts/raw/main/ofl/opensans/OpenSans-Italic%5Bwdth%2Cwght%5D.ttf" |
| 52 | + "${AEONGUI_FONT_DIR}/OpenSans-Italic[wdth,wght].ttf") |
| 53 | + |
| 54 | +# serif |
| 55 | +_aeongui_download_font( |
| 56 | + "Noto Serif" |
| 57 | + "https://github.com/google/fonts/raw/main/ofl/notoserif/NotoSerif%5Bwdth%2Cwght%5D.ttf" |
| 58 | + "${AEONGUI_FONT_DIR}/NotoSerif[wdth,wght].ttf") |
| 59 | + |
| 60 | +# monospace |
| 61 | +_aeongui_download_font( |
| 62 | + "Roboto Mono" |
| 63 | + "https://github.com/google/fonts/raw/main/apache/robotomono/RobotoMono%5Bwght%5D.ttf" |
| 64 | + "${AEONGUI_FONT_DIR}/RobotoMono[wght].ttf") |
| 65 | + |
| 66 | +# cursive |
| 67 | +_aeongui_download_font( |
| 68 | + "Caveat" |
| 69 | + "https://github.com/google/fonts/raw/main/ofl/caveat/Caveat%5Bwght%5D.ttf" |
| 70 | + "${AEONGUI_FONT_DIR}/Caveat[wght].ttf") |
| 71 | + |
| 72 | +# fantasy |
| 73 | +_aeongui_download_font( |
| 74 | + "Bungee" |
| 75 | + "https://github.com/google/fonts/raw/main/ofl/bungee/Bungee-Regular.ttf" |
| 76 | + "${AEONGUI_FONT_DIR}/Bungee-Regular.ttf") |
0 commit comments