想學字體知識,但不知道怎麼下手嗎?Max在修改別人的字體時,收集到一些實用的小程式,也許你也用的到:
基本入門:
- 字型(.ttf) / Web Font (.woff2) / FontForge專案(.sfdir) 互轉
https://codereview.max-everyday.com/font-to-fontforge/ - 轉換 otf 為 ttf
https://codereview.max-everyday.com/otf2ttf/ - 合併字型較安全的方法
https://codereview.max-everyday.com/a-safer-way-to-merge-fonts/ - 字體常見特性概述
https://codereview.max-everyday.com/font-feature/
進階:
- 取得字體的包含文字
https://codereview.max-everyday.com/get-font-chars/ - 增加空白文字到字體檔
https://codereview.max-everyday.com/new-glyph/ - 透過指令合併2個字體檔案
https://codereview.max-everyday.com/merge-font/ - 從字體專案裡取得特定文字glyph
https://codereview.max-everyday.com/get-selected-glyph-from-font/ - 從圖片目錄裡取得特定文字檔案
https://codereview.max-everyday.com/copy_selected_image_out/ - 從字體專案裡刪除特定文字
https://codereview.max-everyday.com/delete-selected-glyph/ - 從2個字體專案裡取得共通或差異
https://codereview.max-everyday.com/get-lost-glyph-from-two-project/ - 從文字檔移除特定文字集合
https://codereview.max-everyday.com/remove-selected-char/ - 取得待補字清單
https://codereview.max-everyday.com/get-wait-compose-list/ - 從其他檔案置換區塊內容
https://codereview.max-everyday.com/update-block-from-file/ - 使用程式協助字體補字
https://codereview.max-everyday.com/python-aided-compose-glyph/ - 以描摹方式建立或更新字型
https://codereview.max-everyday.com/create-new-font-by-draw/ - 使用繪圖軟體修改字型檔
https://codereview.max-everyday.com/modify-font-by-photo-editor/ - 分割字型為多個檔案
https://codereview.max-everyday.com/split_font/ - 如何進行AI造字的模型訓練
https://codereview.max-everyday.com/font-ai-train/
檔案格式的轉換與批次處理:
- opencv 轉換圖片的 3 channel 為 1 channel
https://stackoverflow.max-everyday.com/2025/01/opencv-convert-3-channel-to-1/ - 批次簡化目錄下的 svg 檔
https://codereview.max-everyday.com/svg_simplify/ - 批次轉換目錄下的 bmp 為 svg 檔
https://codereview.max-everyday.com/bmp-to-svg/ - 批次縮放某目錄下的圖片檔案
https://codereview.max-everyday.com/resize_all_image/ - 簡化字型線條
https://codereview.max-everyday.com/simplify/ - 移除字型檔的 lookups
https://codereview.max-everyday.com/remove_lookups/ - 字型轉圖片 font to image
https://codereview.max-everyday.com/font-to-image/ - 取代圖片中顏色
https://codereview.max-everyday.com/change-color-in-image/ - 影像反鋸齒處理
https://codereview.max-everyday.com/image-anti-aliasing/ - ImageFilter.GaussianBlur(radius=sigma) 對訓練資料的影響
https://stackoverflow.max-everyday.com/2025/02/image-filter-gaussian-blur-radius-sigma/ - 向量檔匯入字體檔
https://codereview.max-everyday.com/import-svg-to-font/
CodeReive的外部網站:
- 在 macOS 使用 FontForge
https://stackoverflow.max-everyday.com/2020/09/macos-fontforge-command/ - FontForge 調整字型在 Windows 的安裝顯示名稱
https://stackoverflow.max-everyday.com/2020/02/fontforge-chinese/ - 字型裡符號橫排直排自動轉換的方法
https://stackoverflow.max-everyday.com/2020/07/font-position-alternate-vertical-half-metrics-lookup/ - 轉換字型為webfont
https://stackoverflow.max-everyday.com/2020/08/convert-ttf-to-webfont/ - 二點之間內縮後坐標
https://max-everyday.com/2020/04/two-point-extend/ - 筆畫交叉的判斷
https://max-everyday.com/2020/04/stroke-join-check/ - FontForge Expand Stroke 裡 Line Join 的差異比較
https://stackoverflow.max-everyday.com/2020/03/fontforge-expand-stroke-line-join-miter-round/ - FontForge 調整字型在 Windows 的安裝顯示名稱
https://stackoverflow.max-everyday.com/2020/02/fontforge-chinese/ - FontForge 移除字型檔案裡所有空白字
https://stackoverflow.max-everyday.com/2020/03/fontforge-auto-clear-empty-glyph/ - FontForge使用合併節點消除多的筆畫
https://youtu.be/dvk54uaqBc4 - 幫字型檔補缺字
https://max-everyday.com/2020/02/how-to-add-new-glyph-to-font/ - 幫字型加字重
https://max-everyday.com/2020/02/change-weight-for-font/ - 常見的「台灣方言字」整理
https://max-everyday.com/2020/03/taiwanese-common-word-700/ - 查「部首」、「筆畫」、「異體字」、「同義字」和「文字組件」的字典
這篇內容對應表被使用在字型的 AltUni2 欄位
https://max-everyday.com/2020/04/chinese-dictionary-radical/ - 從「狀」字,打包失敗來看字型檔 AltUni2 欄位用法
https://stackoverflow.max-everyday.com/2020/04/fontforge-aalt-lookup-fail/ - 使用OpenType 字型實現簡體轉繁體字型
https://ayaka.shn.hk/s2tfont/hant/ - 苦累蛙圓體修正錯字示範
https://stackoverflow.max-everyday.com/2021/07/correct-font-glyph-error/ - AI造字經驗分享
https://max-everyday.com/2021/07/zi2zi-ai-font/
AI 造字相關問題
- zi2zi-pytorch 裡, 的 kernel_size=4, padding=1 是否效果等於 kernel_size=3, padding=0
- 將殘差塊添加到 zi2zi-pytorch 的 UNetGenerator 中,分別在第 3 層和第 5 層之後
- 將 self-attention 添加到 zi2zi-pytorch 的 UnetSkipConnectionBlock 之中
- zi2zi-pytorch 除了 vgg 之外, 還有什麼方法可以有效地提升網路特徵提取的能力?
- UNetGenerator 中, 應該加入 self-attention 層或是 channel attention 層, 還是2個都加入比較好?
- zi2zi-pytorch 使用 Adam 優化器,需要修改或增加那些程式碼?
- UNetGenerator 中, 沒有加入 self-attention 層的訓練結果, 可以轉移到有 self-attention 層的訓練模型當中嗎?
- zi2zi 的 UNetGenerator 中,加入 Self-Attention layer, 應該每一個 layer 之後都加, 還是全部 8個 layer 之中的一個增加即可?
- zi2zi-pytorch initial learning rate=0.001, learning rate 的高與低, 對字型生成與訓練有什麼影響, 應該使用更高的 learning rate 還是更低的?
- zi2zi-pytorch 中 ReLU(Rectified Linear Unit)和 LeakyReLU(Leaky Rectified Linear Unit)差異
- zi2zi 已經使用 nn.ReLU(True) 訓練的資料, 要怎麼轉成 nn.LeakyReLU(0.2, True)?
- zi2zi-pytorch 為什麼 uprelu = nn.ReLU(True), uprelu 不使用 LeakyReLU?
- zi2zi-pytorch 裡, 是使用 GAN 還是 patchGAN ?
- 整理 MF-Net 使用的技術中,與 zi2zi-pytorch 明顯不同的部分
- 修改 zi2zi-pytorch 的對生成器和判別器使用 Spectral Normalization
- 比較 nn.BatchNorm2d 與 spectral_norm 二種方式在 zi2zi-pytorch 訓練時的差別
- 為什麼卷積層 (Conv2d) 後面緊接著批次正規化層 (BatchNorm2d) 的情況下,可以省略 Conv2d 的 bias (偏差) 項
- zi2zi-pytorch 的 normalization layer 在 batch size 大於 32 情況下, 最好的方式是 nn.BatchNorm2d 嗎?
- 簡介 MA-Font: Few-shot Font Generation by Multi-Adaptation Method
- 如何實作 MA-Font 的 Multi-Head Attention Module
- MA-Font 的 Multi-Head Attention Module 與 Self-Attention (SA) 的差異
- zi2zi-pytorch image 在 data.Dataset 的 img_A = transforms.ToTensor()(img_A) 與 img_A = self.transform(img_A) 資料會變什麼樣子?
- zi2zi-pytorch UnetSkipConnectionBlock 的 def forward(self, x) 的 x 的 input 資料是從那裡來的?
- 解釋 torch.cat 用法, 為什麼會使用在 UnetSkipConnectionBlock 的 forward 的 return
- torch.cat 與 torch.view 差異
- shape torch.Size([8, 1, 512, 512]) 的訓練資料與 shape torch.Size([8, 1, 256, 256]) 的訓練資料, 在 nn.Conv2d(1, 64, kernel_size=4, stride=2, padding=1) 的產生結果是否shape 相同
- 在 zi2zi-pytorch 專案裡的 UnetSkipConnectionBlock 的 innermost 的 up 是只需要 [uprelu, upnorm] 不需要 nn.ConvTranspose2d?
- zi2zi-pytorch UnetSkipConnectionBlock 調整圖片解析度,256×256 改成 400×400, 在 forward() 的 torch.cat([x, dec], 1) 遇到問題, x 的 shape 是 torch.Size([8, 512, 3, 3]), dec 的 shape 是 torch.Size([8, 512, 2, 2]), 無法使用 torch.cat() 合併
- zi2zi-pytorch 專案, 使用 8層的 UnetSkipConnectionBlock, 請問如何使用 知識蒸餾 (Knowledge Distillation) 把模型變的更小
- 修改了 UNetGenerator 為 half(), 需要修改 Discriminator 為 half() 嗎?
- ImageFilter.GaussianBlur(radius=sigma) 對訓練資料的影響
- zi2zi-pytorch 過擬合 (Overfitting) 現象
- zi2zi-pytorch 加入 L2 正則化
- zi2zi-pytorch 判別器 (Discriminator) 強或弱是以 Conv2d 的次數嗎?
- 如何決定 zi2zi-pytorch 判別器 (Discriminator) final channels 大小
AI相關實作
- MA-Font: Few-shot Font Generation by Multi-Adaptation Method
https://www.researchgate.net/publication/380204074_MA-Font_Few-shot_Font_Generation_by_Multi-Adaptation_Method
We use theAdam optimizer with a batch size of 256 to train the Chinesecharacter generation model for 20 epochs. The learning rateis set to 0.0002 for the first 10 epochs and gradually decaysto 0 for the remaining 10 epochs. - 自注意力機制手寫字生成模型
https://hdl.handle.net/11296/cvaffh
gihub: zi2zi-self-attention:
https://github.com/chiaoooo/03_zi2zi
Self-attention Handwriting Generative Model
https://dl.acm.org/doi/abs/10.1145/3681756.3697883 - Masking Cascaded Self-Attentions for Few-Shot Font-Generation Transformer
https://openaccess.thecvf.com/content/ACCV2024/papers/Ma_Masking_Cascaded_Self-Attentions_for_Few-Shot_Font-Generation_Transformer_ACCV_2024_paper.pdf - FTransGAN in PyTorch
https://github.com/ligoudaner377/font_translator_gan
intro-duces contextaware modules and hierarchical attention mod-ules to capture local and global features. - MF-Net: A Novel Few-shot Stylized Multilingual Font Generation Method
https://github.com/iamyufan/MF-Net
paper:
https://dl.acm.org/doi/10.1145/3503161.3548414 - FFG-benchmarks
https://github.com/clovaai/fewshot-font-generation
Few-shot font generation tasks aim to generate a new font library using only a few reference glyphs, e.g., less than 10 glyph images, without additional model fine-tuning at the test time.