Repository navigation
Conversation
Chinese arrived with no glyphs: jsPDF has no per-glyph fallback, so every
character in a medication name, a note, a lab name, or the report's own
labels drew as a notdef box.
ReportSansSC-{Regular,Bold} is built the way the Korean pair is, from Noto
Sans plus Noto Sans SC: 2.3 MB a weight, the characters GB2312 defines plus
CJK punctuation, read only for a document that holds a Han character or is
drawn for zh-CN.
Two places where the change is not just a third file:
- the GB2312 set is read from the codec (lead 0xA1-0xF7, trail 0xA1-0xFE),
not from a hand-copied table of 6,763 characters, which is a transcription
that can be wrong in one row and silent about it;
- the emergency card kept its own copy of the Hangul regex, which is the
drift the fold module warns about. Both callers now ask reportFontScript()
for the script, and registration takes that instead of a boolean.
Han wins over Hangul when a document holds both: only one of the two files
can be registered, and Han is the one that would otherwise be boxes.
Author
|
Superseded by #1664. The maintainer added the Han font to the doctor report and the emergency card inside #1664, with a test that every report string of every language has a glyph. This PR carries the same two faces for one report path and no glyph coverage, so it would be a duplicate of work already in review. What survives from here is the observation that made the PR: a report with Chinese data drew boxes, and the fix belongs in the report renderer rather than in the locale. That is now true in #1664. Closing rather than rebasing: nothing in this branch is missing from #1664, and a second copy of a 4.7 MB font pair costs review attention without adding a caller. |
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 does
Embeds a Simplified Chinese font so the doctor-report PDF can draw Han
characters, and only when the report actually contains them.
Until now the PDF was drawn with the built-in Helvetica-family base fonts, which
carry no CJK glyphs: a report whose name or notes contained Chinese rendered as
blanks. Embedding a Han font unconditionally would add megabytes to every PDF,
including the ones that are pure ASCII, so the font is embedded only when the
document text contains a Han code point.
What is added
public/fonts/:ReportSansSC-Regular.ttfandReportSansSC-Bold.ttf(4.67 MB together), derived from Noto Sans SC.punctuation, which is what these files carry.
containsHan(text)is true; theHelvetica path is unchanged otherwise.
Evidence
Probed the built fonts with fontTools: 9,455 glyphs, covering 血压酮,
、。「」,%1, and — because a Chinese report still contains Latin andGreek —
ł,Ω,Ж,→,².A stub-jsPDF harness imported the real
fonts.tsand asserted the embeddingdecision: 23 assertions, 0 failures, including "ASCII report embeds no
font" and "one Han character embeds both weights when bold is used".
Checks
tsc --noEmit: cleanNote on reproducibility
Rebuilding the TTF from the same Noto source is not byte-identical: only
head.modifieddiffers, so I am not claiming a reproducible build here. Thecommitted bytes are the ones the harness measured.
Depends on
Nothing.