FontFace.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/Bindings/PlatformObject.h>
  8. namespace Web::CSS {
  9. struct FontFaceDescriptors {
  10. String style = "normal"_string;
  11. String weight = "normal"_string;
  12. String stretch = "normal"_string;
  13. String unicode_range = "U+0-10FFFF"_string;
  14. String feature_settings = "normal"_string;
  15. String variation_settings = "normal"_string;
  16. String display = "auto"_string;
  17. String ascent_override = "normal"_string;
  18. String descent_override = "normal"_string;
  19. String line_gap_override = "normal"_string;
  20. };
  21. class FontFace final : public Bindings::PlatformObject {
  22. WEB_PLATFORM_OBJECT(FontFace, Bindings::PlatformObject);
  23. JS_DECLARE_ALLOCATOR(FontFace);
  24. public:
  25. using FontFaceSource = Variant<String, JS::Handle<JS::ArrayBuffer>, JS::Handle<WebIDL::ArrayBufferView>>;
  26. [[nodiscard]] static JS::NonnullGCPtr<FontFace> construct_impl(JS::Realm&, String family, FontFaceSource source, FontFaceDescriptors const& descriptors);
  27. virtual ~FontFace() override = default;
  28. JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Promise>> load();
  29. private:
  30. FontFace(JS::Realm&, String family, FontFaceSource source, FontFaceDescriptors const& descriptors);
  31. virtual void initialize(JS::Realm&) override;
  32. };
  33. }