Skip to content

Commit

Permalink
Add register_font endpoint (#918)
Browse files Browse the repository at this point in the history
  • Loading branch information
wkazmierczak authored Jan 14, 2025
1 parent 76f9b84 commit c030d0f
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 35 deletions.
83 changes: 51 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ rand = { workspace = true }
reqwest = { workspace = true }
rubato = { workspace = true }
tokio = { workspace = true }
axum = { version = "0.7.4", features = ["ws"] }
axum = { version = "0.7.4", features = ["ws", "multipart"] }
futures-util = { workspace = true }
wgpu = { workspace = true }
glyphon = { workspace = true }
http-body-util = "0.1.2"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
7 changes: 7 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct Config {
pub output_sample_rate: u32,
pub stun_servers: Arc<Vec<String>>,
pub required_wgpu_features: WgpuFeatures,
pub load_system_fonts: bool,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -191,6 +192,11 @@ fn try_read_config() -> Result<Config, String> {
Err(_) => queue::DEFAULT_BUFFER_DURATION,
};

let load_system_fonts = match env::var("LIVE_COMPOSITOR_LOAD_SYSTEM_FONTS") {
Ok(enable) => bool_env_from_str(&enable).unwrap_or(true),
Err(_) => true,
};

let log_file = match env::var("LIVE_COMPOSITOR_LOG_FILE") {
Ok(path) => Some(Arc::from(PathBuf::from(path))),
Err(_) => None,
Expand Down Expand Up @@ -236,6 +242,7 @@ fn try_read_config() -> Result<Config, String> {
output_sample_rate,
stun_servers,
required_wgpu_features,
load_system_fonts,
};
Ok(config)
}
Expand Down
3 changes: 3 additions & 0 deletions src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ pub fn routes(state: ApiState) -> Router {
.route("/:id/register", post(register_request::handle_shader))
.route("/:id/unregister", post(unregister_request::handle_shader));

let font = Router::new().route("/register", post(register_request::handle_font));

async fn handle_start(State(state): State<ApiState>) -> Result<Response, ApiError> {
Pipeline::start(&state.pipeline);
Ok(Response::Ok {})
Expand All @@ -67,6 +69,7 @@ pub fn routes(state: ApiState) -> Router {
.nest("/api/image", image)
.nest("/api/web-renderer", web)
.nest("/api/shader", shader)
.nest("/api/font", font)
// Start request
.route("/api/start", post(handle_start))
// WebSocket - events
Expand Down
Loading

0 comments on commit c030d0f

Please sign in to comment.