fonts: Reduce the public API surface (#39112)

This change marks all items that are not used by other crates as
`pub(crate)` instead of `pub`.

Additionally, I've removed all code that turned out to be unused. I
think most of it was used only by `layout-2013`.


Testing: The correctness of these changes is verified by the compiler,
so no tests are needed.

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2025-09-03 22:15:51 +02:00 committed by GitHub
parent 8993235e8f
commit 73e39cf085
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 106 additions and 157 deletions

View file

@ -9,23 +9,31 @@ mod font_context;
mod font_store;
mod glyph;
#[allow(unsafe_code)]
pub mod platform;
pub mod platform; // Public because integration tests need this
mod shapers;
mod system_font_service;
pub use font::*;
pub use font_context::*;
pub use font_store::*;
pub use fonts_traits::{LocalFontIdentifier, *};
pub use glyph::*;
pub use shapers::*;
pub use system_font_service::*;
pub(crate) use font::*;
// These items are not meant to be part of the public API but are used for integration tests
pub use font::{Font, FontFamilyDescriptor, FontSearchScope, PlatformFontMethods};
pub use font::{
FontBaseline, FontGroup, FontMetrics, FontRef, LAST_RESORT_GLYPH_ADVANCE, ShapingFlags,
ShapingOptions,
};
pub use font_context::{FontContext, FontContextWebFontMethods};
pub use font_store::FontTemplates;
pub use fonts_traits::*;
pub(crate) use glyph::*;
pub use glyph::{GlyphInfo, GlyphRun, GlyphStore};
pub use platform::font_list::fallback_font_families;
pub(crate) use shapers::*;
pub use system_font_service::SystemFontService;
use unicode_properties::{EmojiStatus, UnicodeEmoji, emoji};
/// Whether or not font fallback selection prefers the emoji or text representation
/// of a character. If `None` then either presentation is acceptable.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum EmojiPresentationPreference {
pub(crate) enum EmojiPresentationPreference {
None,
Text,
Emoji,
@ -33,8 +41,8 @@ pub enum EmojiPresentationPreference {
#[derive(Clone, Copy, Debug)]
pub struct FallbackFontSelectionOptions {
pub character: char,
pub presentation_preference: EmojiPresentationPreference,
pub(crate) character: char,
pub(crate) presentation_preference: EmojiPresentationPreference,
}
impl Default for FallbackFontSelectionOptions {
@ -47,7 +55,7 @@ impl Default for FallbackFontSelectionOptions {
}
impl FallbackFontSelectionOptions {
pub fn new(character: char, next_character: Option<char>) -> Self {
pub(crate) fn new(character: char, next_character: Option<char>) -> Self {
let presentation_preference = match next_character {
Some(next_character) if emoji::is_emoji_presentation_selector(next_character) => {
EmojiPresentationPreference::Emoji