Compare commits

..

1 Commits

Author SHA1 Message Date
Haitao Pan
c2d28a3e61 fix(pdf): use cjk font for Chinese annotations 2026-06-28 12:02:12 +08:00
2 changed files with 15 additions and 46 deletions

View File

@ -1,44 +0,0 @@
name: Validate Release PR
# release/* 分支的发布策略门禁:仅接受 hotfix/* 或带 cherry-pick/backport 标签的 PR。
# 详见 iac_modules/docs/tldr-github-branch-model.md
on:
pull_request_target:
types: [opened, synchronize, reopened, labeled, unlabeled]
permissions:
contents: read
pull-requests: read
jobs:
validate-release-source:
runs-on: ubuntu-latest
if: startsWith(github.base_ref, 'release/')
steps:
- name: Check PR source branch
run: |
SRC="${{ github.head_ref }}"
TGT="${{ github.base_ref }}"
LABELS="${{ join(github.event.pull_request.labels.*.name, ',') }}"
echo "🔍 Validating PR into release branch"
echo " source: $SRC"
echo " target: $TGT"
echo " labels: $LABELS"
if [[ "$SRC" =~ ^hotfix/ ]]; then
echo "✅ Allowed: hotfix/* branch"
exit 0
fi
if [[ "$LABELS" =~ (^|,)(cherry-pick|backport)(,|$) ]]; then
echo "✅ Allowed: cherry-pick/backport labeled PR"
exit 0
fi
echo "❌ Rejected."
echo "release/* 仅接受:"
echo " - 来自 hotfix/* 的 PR"
echo " - 带 cherry-pick 或 backport 标签的 PR已验证 feature 的 backport/cherry-pick"
echo "禁止从 main / develop / feature/* 直接合并到 release/*。"
exit 1

View File

@ -5,6 +5,19 @@ from pypdf import PdfReader, PdfWriter
from pypdf.annotations import FreeText
def _contains_cjk(text):
return any(
"\u3400" <= char <= "\u4dbf"
or "\u4e00" <= char <= "\u9fff"
or "\uf900" <= char <= "\ufaff"
for char in text
)
def _default_font_for_text(text):
if _contains_cjk(text):
return "Songti SC"
return "Arial"
def transform_from_image_coords(bbox, image_width, image_height, pdf_width, pdf_height):
@ -72,8 +85,8 @@ def fill_pdf_form(input_pdf_path, fields_json_path, output_pdf_path):
text = entry_text["text"]
if not text:
continue
font_name = entry_text.get("font", "Arial")
font_name = entry_text.get("font") or _default_font_for_text(text)
font_size = str(entry_text.get("font_size", 14)) + "pt"
font_color = entry_text.get("font_color", "000000")