alonso.torres 645a977ece ✨ Add Chinese regional and Korean word layout
Add named Chinese punctuation presets and a Korean keep-words mode for
horizontal and vertical layout. Preserve the saved spaces-only mode and
keep source offsets stable through safe emergency wrapping.

Apply bounded CJK spacing and justification, expose the new choices in the
sidebar, and document preset bounds and remaining release checks.

Verify renderer, frontend, common and exporter tests, both WASM builds,
and sample save/reload plus PNG, PDF and SVG exports. Existing CI failures
remain documented in the layout notes.

AI-assisted-by: GPT-6
2026-11-03 17:36:40 +01:00

74 lines
1.8 KiB
Rust

use crate::get_resources;
use crate::render::FallbackFonts;
use crate::skia::textlayout::FontCollection;
use crate::skia::Image;
use crate::uuid::Uuid;
use crate::with_state;
pub fn uuid_from_u32_quartet(a: u32, b: u32, c: u32, d: u32) -> Uuid {
let hi: u64 = ((a as u64) << 32) | b as u64;
let lo: u64 = ((c as u64) << 32) | d as u64;
Uuid::from_u64_pair(hi, lo)
}
pub fn uuid_to_u32_quartet(id: &Uuid) -> (u32, u32, u32, u32) {
let (hi, lo) = id.as_u64_pair();
let hihi32 = (hi >> 32) as u32;
let hilo32 = hi as u32;
let lohi32 = (lo >> 32) as u32;
let lolo32 = lo as u32;
(hihi32, hilo32, lohi32, lolo32)
}
pub fn uuid_from_u32(id: [u32; 4]) -> Uuid {
uuid_from_u32_quartet(id[0], id[1], id[2], id[3])
}
pub fn get_image(image_id: &Uuid) -> Option<&Image> {
get_resources().images.get(image_id)
}
// FIXME: move to a different place ?
pub fn get_fallback_fonts() -> &'static FallbackFonts {
get_resources().fonts.get_fallback()
}
pub fn get_font_collection() -> &'static FontCollection {
if crate::globals::has_render_resources() {
get_resources().fonts.font_collection()
} else {
with_state!(state, { state.font_collection() })
}
}
/// A negative f32 means "unset" — the renderer falls back to its default.
pub fn decode_optional_f32(value: f32) -> Option<f32> {
if value.is_finite() && value >= 0.0 {
Some(value)
} else {
None
}
}
#[derive(Debug, Clone, Copy)]
#[repr(u8)]
pub enum Browser {
Firefox = 0,
Chrome = 1,
Safari = 2,
Edge = 3,
Unknown = 4,
}
impl From<u8> for Browser {
fn from(value: u8) -> Self {
match value {
0 => Browser::Firefox,
1 => Browser::Chrome,
2 => Browser::Safari,
3 => Browser::Edge,
_ => Browser::Unknown,
}
}
}