1#ifndef NOVASVG_FOREIGN_OBJECT_H
2#define NOVASVG_FOREIGN_OBJECT_H
19#include <stb/color.hpp>
20#include <stb/image.hpp>
71 virtual std::optional<css_declaration>
declared(
const std::vector<html_tag>& nodes,
int index, std::string_view property)
const = 0;
88 const stb::color& color_,
const text_squeeze& squeeze = {}) = 0;
123 float max_width)
const
virtual ~css_query()=default
virtual std::optional< css_declaration > declared(const std::vector< html_tag > &nodes, int index, std::string_view property) const =0
virtual void fill_text(std::u32string_view text, const foreign_object_font &font_, float x, float y, const stb::color &color_, const text_squeeze &squeeze={})=0
x, y: the left end of the baseline.
virtual ~foreign_object_painter()=default
virtual float measure_text(std::u32string_view text, const foreign_object_font &font_) const =0
virtual foreign_object_font_metrics metrics(const foreign_object_font &font_) const =0
virtual void draw_image(const stb::image &image, const vg::box &dest)=0
Straight (not premultiplied) RGBA, stretched to dest. For renderers that rasterize.
virtual void fill_rect(const vg::box &box_, const stb::color &color_)=0
Called concurrently from const methods on one document: keep no mutable state without a lock.
virtual std::optional< foreign_object_size > measure(const foreign_object_context &context, const foreign_object_painter &painter, float max_width) const
virtual ~foreign_object_renderer()=default
virtual std::shared_ptr< void > prepare(std::string_view markup, const css_query &css) const
virtual void render(const foreign_object_context &context, foreign_object_painter &painter) const =0
Represents a 2D axis-aligned bounding box.
std::shared_ptr< foreign_object_renderer > default_foreign_object_renderer()
int specificity
the larger one wins; a later declaration wins a tie
std::string_view markup
untouched, as in the source
vg::box box
the foreignObject's x, y, width, height
foreign_object_font font
inherited through the svg cascade
const void * prepared
what prepare() returned for this element
float device_scale
device pixels per user unit (the larger axis), for renderers that rasterize
float height
ascent + descent
int weight
CSS font-weight, 1 to 1000 (400 normal, 700 bold).
bool bold
weight >= 600: for a painter that only knows regular and bold; novasvg sets it with weight
std::string style
the style="" attribute, verbatim
std::string tag
lower case
Condense text horizontally about about_x (a line that is wider than its box).