Skip to content

chore: embed fonts via go:embed#192

Open
fank wants to merge 1 commit intomainfrom
chore/embed-fonts
Open

chore: embed fonts via go:embed#192
fank wants to merge 1 commit intomainfrom
chore/embed-fonts

Conversation

@fank
Copy link
Member

@fank fank commented Feb 12, 2026

Summary

  • Move MapLibre glyph PBF files (768 files, ~4.4MB) from assets/fonts/ into internal/fonts/glyphs/ and serve via embed.FS
  • Remove OCAP_FONTS config option (Setting.Fonts field, env var, viper default)
  • Remove font COPY and ENV from Dockerfile — fonts are now baked into the binary

Test plan

  • go build ./cmd/ocap-webserver compiles with embedded fonts
  • go test ./... passes (pre-existing maptool failure unrelated)
  • Verify font endpoint returns PBF files: curl -I localhost:5000/fonts/OpenSans-Bold/0-255.pbf

Move MapLibre glyph PBF files from assets/fonts/ into
internal/fonts/glyphs/ and serve them from the embedded FS.
This removes the OCAP_FONTS config option and simplifies
deployment to a single binary.
@github-actions
Copy link

Merging this branch will decrease overall coverage

Impacted Packages Coverage Δ 🤖
github.com/OCAP2/web/internal/fonts 0.00% (ø)
github.com/OCAP2/web/internal/server 33.97% (-0.22%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/OCAP2/web/internal/fonts/fonts.go 0.00% (ø) 0 0 0
github.com/OCAP2/web/internal/server/handler.go 28.82% (-0.48%) 857 (+14) 247 610 (+14) 👎
github.com/OCAP2/web/internal/server/setting.go 49.43% (-0.57%) 87 (-1) 43 (-1) 44 👎

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @fank, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors how font assets are handled by embedding them directly into the Go binary using 'go:embed'. This change eliminates the need for external font directories and associated Dockerfile instructions, leading to a more self-contained and streamlined application build and deployment process. It also simplifies configuration by removing a dedicated font path setting.

Highlights

  • Font Embedding: MapLibre glyph PBF files (768 files, ~4.4MB) were moved from 'assets/fonts/' to 'internal/fonts/glyphs/' and are now served via Go's 'embed.FS' feature.
  • Configuration Simplification: The 'OCAP_FONTS' configuration option, including its 'Setting.Fonts' field, environment variable, and Viper default, has been removed.
  • Dockerfile Optimization: Font 'COPY' and 'ENV' instructions were removed from the Dockerfile, as fonts are now baked directly into the Go binary, simplifying the build process.
Changelog
  • Dockerfile
    • Removed 'OCAP_FONTS' environment variable.
    • Removed 'COPY assets/fonts' instruction.
  • assets/fonts/... (renamed to internal/fonts/glyphs/...)
    • Moved all MapLibre glyph PBF files from 'assets/fonts/' to 'internal/fonts/glyphs/'.
  • internal/fonts/fonts.go
    • Added 'internal/fonts/fonts.go' to define 'GlyphsFS' using 'go:embed all:glyphs'.
Activity
  • No human activity (comments, reviews, etc.) has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors how fonts are handled by embedding them directly into the Go binary using go:embed. This simplifies deployment by removing the need for a separate fonts directory and associated configuration. The changes in the Dockerfile and the file structure are correct and align with the goal. I've identified a potential issue with the go:embed directive in internal/fonts/fonts.go that would likely cause the font serving endpoint to fail with 404 errors. I've provided a suggestion to adjust the embed path pattern to resolve this.


import "embed"

//go:embed all:glyphs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The go:embed directive all:glyphs embeds the glyphs directory itself. This means file paths within GlyphsFS will be prefixed with glyphs/ (e.g., glyphs/OpenSans-Bold/0-255.pbf).

Given the test plan's curl command, the server is expected to serve files from /fonts/ without this glyphs/ prefix, which would lead to 404 errors.

To fix this, you can adjust the embed pattern to strip the glyphs/ prefix from the embedded file paths.

Suggested change
//go:embed all:glyphs
//go:embed all:glyphs/*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant