fix(render): environment-aware atlas drift guard, pinned text scale, shipped-atlas coverage
This commit is contained in:
1 parent
5ca3587325
commit
1cb5970757
6 files changed
+257
-31
No files matched your search
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include <plot/core/types.hpp>
|
||||
|
||||
namespace plot::render::detail {
|
||||
|
||||
/// The factor a text run is drawn by: `requested_px / em_px`, a plain ratio.
|
||||
///
|
||||
/// It is a ratio rather than a whole multiple because the renderer's built-in
|
||||
/// face is anti-aliased: a style asking for 12 px from a 13 px bake is drawn at
|
||||
/// 12/13, where a 1-bit glyph would have had to snap to the nearest multiple of
|
||||
/// its cell. Everything the renderer stages is scaled by this one factor, so the
|
||||
/// labels a plot laid out and the glyphs the pipeline draws cannot disagree.
|
||||
///
|
||||
/// A backend that cannot state an em -- `em_px()` at or below zero, or NaN --
|
||||
/// yields a 1:1 scale rather than dividing by it or propagating a NaN into every
|
||||
/// vertex. The requested size being NaN, zero or negative does the same. The rule
|
||||
/// lives here, not inline in the renderer, so it is one function and can be
|
||||
/// asserted without a GL context; it is instrumentation-free and part of no
|
||||
/// public surface (`*/detail/` headers stay out of the umbrella).
|
||||
inline f32 text_scale(f32 requested_px, f32 em_px) noexcept {
|
||||
const f32 ratio = requested_px / em_px;
|
||||
return (em_px > 0.0f && ratio > 0.0f) ? ratio : 1.0f;
|
||||
}
|
||||
|
||||
} // namespace plot::render::detail
|
||||
Reference in new issue
Block a user