Repository navigation
Thai edition: edit text set in Sarabun in Sarabun, not TH Sarabun PSK - #1
Open
cyk-logistics wants to merge 7 commits into
Open
cyk-logistics wants to merge 7 commits into
cyk-logistics wants to merge 7 commits into
Conversation
Text set in Google's Sarabun (Chrome and TCPDF embed it as AAAAAC+Sarabun-Regular) was
redrawn in TH Sarabun PSK when edited: like_font mapped the plain name "sarabun" to the
built-in TH Sarabun PSK. At one size PSK's letters are 68% as tall (ก 400 against 586
thousandths of an em), so an edited line came out a third smaller and lighter than the rest.
Sarabun (SIL OFL 1.1, google/fonts ofl/sarabun, unmodified) joins TH Sarabun PSK in
thai/fonts as its own family, Family::GoogleSarabun ("Sarabun"). like_font maps the
TH Sarabun names to TH Sarabun PSK and "sarabun" to Sarabun, falling back to an installed
font when the build lacks the face. The Thai fallback for runs restyled within a paragraph
(text_regions::thai_face) goes through like_font too, instead of going straight from
installed fonts to TH Sarabun PSK. build-windows.ps1 copies both font folders and appends
each manifest line not there yet, so an existing font set gains the new lines.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts: README-TH.md (the English summary names Sarabun and now v0.9.0) and ATTRIBUTION.toml (the Sarabun entries follow the new vello_common entry and the updated Slovene catalogue hash). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflict: README-TH.md (the English summary names Sarabun and now v0.10.1). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflict: ATTRIBUTION.toml (the Sarabun entries follow the new Thai edition mark and screenshot entries). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
mixlnwuu
pushed a commit
that referenced
this pull request
Oct 23, 2026
mixlnwuu
pushed a commit
that referenced
this pull request
Oct 23, 2026
verify_noting adds the note only when the signature verifies. The test uses a synthetic 1024-bit key and its PKCS #1 v1.5 signature: the valid signature carries the note, and one that doesn't verify has none.
Conflicts: README-TH.md (the English summary names Sarabun and now v0.13.0) and ATTRIBUTION.toml (the Sarabun entries follow the new catalogue and icon entries). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts: README-TH.md (the English summary names Sarabun and now v0.14.0) and ATTRIBUTION.toml (translation catalogs no longer carry a sha256; the Sarabun font entries keep theirs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thai split added.rs (Family is now in added/types.rs) and text_regions.rs (thai_face is now in text_regions/styled.rs). The upstream files are taken as they are, with the Sarabun change made again where the code now lives: Family::GoogleSarabun and like_font in added/types.rs, and thai_face through like_font in text_regions/styled.rs. Also README-TH.md (v0.15.0) and ATTRIBUTION.toml (the Sarabun entries follow the Catalan catalogue's new usage line). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Editing existing text set in Google's Sarabun (what Chrome's print-to-PDF and TCPDF embed, e.g.
AAAAAC+Sarabun-Regular) redrew it in TH Sarabun PSK.Family::like_fonttreated the plain namesarabunlikethsarabunpsk. At one point size, TH Sarabun PSK's letters are 68% as tall as Sarabun's (ก is 400 vs 586 thousandths of an em; H is 476 vs 700). So every edited line came out about a third smaller and lighter than the text around it, even when only one digit changed. Fonts installed on the machine weren't consulted for that name. On macOS, Sarabun is only an on-demand system font collection, which isn't scanned and couldn't be embedded anyway.ofl/sarabun, Regular/Bold/Italic/Bold Italic, about 90 KB each). It goes inthai/fonts/sarabun/next to TH Sarabun PSK, withOFL.txtand 4 manifest lines. They're taggedDocu, so the interface and Thai-fallback face order is unchanged.Family::GoogleSarabun(label "Sarabun") is added incrates/edit/src/added.rs.like_fontmaps the TH Sarabun names to TH Sarabun PSK andsarabunto Sarabun. If the build lacks the face, it falls back to an installed font, as before.text_regions::thai_face(Thai fallback for runs restyled within a paragraph) goes throughlike_fonttoo. It used to go straight from installed fonts to TH Sarabun PSK.thai/build-windows.ps1copies both font folders and appends every manifest line that isn't there yet. The old script appended once, keyed on^TH Sarabun PSK, so an existingtarget\thai-fontswould never have gained the new lines.package.ps1already ships eachfonts/<family>/OFL.txt.README-TH.mdlists the new font and its licence.ATTRIBUTION.tomlgets entries for the 4 font files.Side effect: upstream's
embedding::matching_facesnow finds the approved full face for*+Sarabun-Regular/*+Sarabun-Boldsources. That affects the inline editor's font stack and the renderer's substitute for a non-embedded Sarabun.How you verified it
Built natively on macOS (Apple silicon) with
CRAFT_FONTS_DIR= craft-fonts@3d9ab3a plusthai/fonts, asbuild-windows.ps1does.End to end, using
pdfcraft-cli run --script(doc_open → text_edit by line → doc_save), rendered with pdftoppm and with MuPDF. Both renderers gave the same numbers.pdftotextfinds every edited line.ranges) now use Sarabun. Before, they used a TH Sarabun PSK Type 3 font or an embedded copy of TH Sarabun PSK.Checklist
cargo fmt --check -p pdfcraft-edit: OK.clippy with
-D warnings: no warnings in the changed files.cargo clippy -p pdfcraft-edit -- -D warningsstill stops on 3 existing lints incrates/fonts/src/installed.rs(clippy 1.99:type_complexity, twochunks_exact_to_as_chunks) and 1 incrates/edit/src/text.rs(too_many_arguments). This PR doesn't touch those files.Tests:
cargo test -p pdfcraft-edit -p pdfcraft-fonts -p pdfcraft-automationwith the craft-fonts input gives edit 141 passed, fonts 69 passed, automation 194 passed.added_thai_text_wraps_clusters_and_survives_reopen(the narrow-box wrap expects 3 rows and gets 2).thaiat 4326798 without this change (checked fromgit archivewith a separate target dir), so it's an existing failure.cargo xtask layers: OK.cargo xtask assets: the new Sarabun files pass. 37 violations already exist onthaiand remain:docs/brandanddocs/imagesATTRIBUTION.mdout of dateI didn't regenerate
ATTRIBUTION.md, so this PR touches no unrelated entries.Tests. New regression test
sarabun_text_is_redrawn_in_sarabun_not_th_sarabun_pskincrates/edit/src/tests.rs. It edits a line and a paragraph whose font isAAAAAC+Sarabun-Regular(expects Sarabun) andBCDEEE+THSarabunPSK(expects TH Sarabun PSK still). When the build lacks the faces it is skipped, like the other Thai-edition tests. With the oldlike_fontmapping restored, it fails withleft: Some("TH Sarabun PSK Type3") right: Some("Sarabun Type3").Never-crash
unwrap/expect/panic!/unreachable!/todo!outside testsunsafeProvenance
thai/fonts. Sarabun isn't in craft-fonts@3d9ab3a. If you'd rather not commit fonts, the build script could download these four files from the pinned google/fonts commit and check their SHA-256 (listed inmanifest-additions.txtandATTRIBUTION.toml). I'm happy to change it.ATTRIBUTION.tomlentrySecurity
Anything a reviewer should look at first
Family::Sarabunmeans TH Sarabun PSK. I didn't rename it, to keep the diff small, so the new variant isGoogleSarabun, labelled "Sarabun" in the font menu. In the automation tools,font: "sarabun"still means TH Sarabun PSK (unchanged, so existing scripts behave the same), while"Sarabun"reaches the new family throughfrom_name.TH Sarabun Newsource with that font installed,thai_facenow prefers the bundled TH Sarabun PSK over the installed font, matching whatlike_fontalready did for line edits. The two are the same design.THSarabunIT๙(common on Thai government forms) reduces tothsarabunit, which still isn't mapped to TH Sarabun PSK.🤖 Generated with Claude Code