// Copyright 2025 International Digital Economy Academy
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

///|
/// Facade for types that can provide font metadata.
///
/// Ported from `fontations/skrifa/src/provider.rs` (Apache-2.0 OR MIT).
pub(open) trait MetadataProvider {
  fn attributes(Self) -> Attributes
  fn axes(Self) -> AxisCollection
  fn named_instances(Self) -> NamedInstanceCollection
  fn localized_strings(Self, StringId) -> LocalizedStrings
  fn glyph_names(Self) -> GlyphNames
  fn metrics(Self, Size, LocationRef) -> Metrics
  fn glyph_metrics(Self, Size, LocationRef) -> GlyphMetrics
  fn charmap(Self) -> Charmap
  fn outline_glyphs(Self) -> @skrifa_outline.OutlineGlyphCollection
  fn bitmap_strikes(Self) -> BitmapStrikes
  fn color_glyphs(Self) -> ColorGlyphCollection
  fn color_palettes(Self) -> ColorPalettes
}

///|
pub impl MetadataProvider for FontRef with fn attributes(font) {
  FontRef::attributes(font)
}

///|
pub impl MetadataProvider for FontRef with fn axes(font) {
  AxisCollection(font)
}

///|
pub impl MetadataProvider for FontRef with fn named_instances(font) {
  NamedInstanceCollection(font)
}

///|
pub impl MetadataProvider for FontRef with fn localized_strings(font, id) {
  FontRef::localized_strings(font, id)
}

///|
pub impl MetadataProvider for FontRef with fn glyph_names(font) {
  GlyphNames(font)
}

///|
pub impl MetadataProvider for FontRef with fn metrics(font, size, location) {
  FontRef::metrics(font, size, location)
}

///|
pub impl MetadataProvider for FontRef with fn glyph_metrics(
  font,
  size,
  location,
) {
  FontRef::glyph_metrics(font, size, location)
}

///|
pub impl MetadataProvider for FontRef with fn charmap(font) {
  Charmap(font)
}

///|
pub impl MetadataProvider for FontRef with fn outline_glyphs(font) {
  @skrifa_outline.OutlineGlyphCollection::from_font(font)
}

///|
pub impl MetadataProvider for FontRef with fn bitmap_strikes(font) {
  BitmapStrikes(font)
}

///|
pub impl MetadataProvider for FontRef with fn color_palettes(font) {
  ColorPalettes(font)
}

///|
pub impl MetadataProvider for FontRef with fn color_glyphs(font) {
  ColorGlyphCollection(font)
}