找回密码
 快速注册
搜索
楼主: hbghlyj

[pdftex] Merging duplicate embedded fonts

[复制链接]

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-2-7 17:26
groups.google.com/g/comp.text.tex/c/PEkxWUJfV_c
If pdfTeX knows a font that is used inside an included PDF file, then
it throws away the font in the included file and uses its known font.
AFAIK the reason for this behaviour is that this avoids embedding
a font several times (with different subsets).


The author and maintainer of pdfTeX Han The Thanh has provided
a better solution:

| I think it's useful to have a summary of the problem for further reference:
|
| - fig.pdf contains a font named NimbusRomNo9L-Regu
| - pdftex sees that it has the same font on disk and tries to use the font on
| +disk instead of copying the font from fig.pdf. (Reason: if we have eg fig.pdf &
| +fig2.pdf, the font would be included once instead of twice)

| - however these 2 fonts are different: the one embedded in fig.pdf has extra
| +glyphs that the font on disk doesn't have. pdftex cannot know this, since the
| +font names are the same.
| - hence the output pdf doesn't have those glyphs, too.
|
| workarounds/solutions:
| - if you are in hurry, just say: \pdfinclusioncopyfonts=1
| - for more detailed info, see bug report #2092
| - the proper solution IMO is to change the font name to denote that it differ
| +from the original NimbusRomNo9L-Regu
|
| It's questionable whether pdftex should use the font on disk instead of copying
| +the font from fig.pdf by default. There are 2 main arguments for this behavior:
|
| - that behavior was the default since the beginning, and it's not wise to change
| +it; it can break pdf inclusion in existing documents
| - if this behavior is not desired, it can be changed easily
| +(\pdfinclusioncopyfonts=1)
| ...

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-2-7 17:34
copyprogramming.com/howto/file-size-generated-from-pdflatex-is-too-big
To restrict the size, it's advisable to minimize the usage of font inclusion and let the PDF viewer provide the fonts. However, even for the "standard 35" Adobe fonts, this approach is not promoted in current times.

Include the file labeled nodownload.map beside your primary document.
  1. phvb8r Helvetica-Bold 0 "TeXBase1Encoding ReEncodeFont" <8r.enc
  2. phvb8y Helvetica-Bold 0 "TeXnANSIEncoding ReEncodeFont"
复制代码

Now compiling the following example
  1. \pdfmapfile{=nodownload.map}
  2. \documentclass[10pt,a4paper,oneside]{article}
  3. \usepackage[utf8]{inputenc}
  4. \usepackage[T1]{fontenc}
  5. \usepackage{mathptmx}
  6. \usepackage[scaled]{helvet}
  7. \usepackage{amsmath}
  8. \usepackage{amsfonts}
  9. \usepackage{amssymb}
  10. \usepackage{lipsum}
  11. \title{Test}
  12. \author{John doe}
  13. \begin{document}
  14. \maketitle
  15. \section{This is a test}
  16. \textsf{Abc\itshape def} and an integral
  17. \[
  18. \int_{-\infty}^{\infty}e^{-x^{2}}\,dx=\sqrt{\pi}
  19. \]
  20. \lipsum
  21. \end{document}
复制代码

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-2-7 17:35
kuing 发表于 2024-2-6 14:38
我最近弄的
《kuing网络撸题集》(2022~2023懒人版)
可能也存在字体重复的问题,你可否帮我瞧瞧。


是否可以像上面那樣,生成fontmap,輸入pdfTeX,就可以去重?pdfTeX默認就會把它認識的字體去重,只需把字體的fontmap給它:\pdfmapfile{...}(overleaf.com/learn/latex/Questions/I_have_a_custom_font_I%27d_li ... How_can_I_do_this%3F

点评

8好意思,我完全看8懂上面的内容  发表于 2024-2-7 17:39

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-2-7 18:21
@kuing 例如兩個10KB的PDF
$type include1.pdf (9.14 KB, 下载次数: 0)
$type include2.pdf (9.14 KB, 下载次数: 0)

下面的保存為1.tex
  1. \def\folio{}  % disable page number
  2. \pdfximage width 2cm {include1.pdf}
  3. \pdfximage width 2cm {include2.pdf}
  4. \pdfrefximage1
  5. \pdfrefximage2
  6. \bye
复制代码

运行
  1. pdftex 1.tex
复制代码

用pdfTeX合併後,只有12KB:
$type 1.pdf (11.47 KB, 下载次数: 0)
說明pdfTeX合併了字體

点评

發現有2個font,但指向同一個Basefont  发表于 2024-2-7 18:30

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-2-7 22:01
radamir.com/tex/ttf-tex.htm
Windows的ttf字體很難導入pdfTeX。。没弄成

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-2-7 22:22
hbghlyj 发表于 2024-2-7 10:21
@kuing 用pdfTeX合併後,只有12KB:
說明pdfTeX合併了字體


測試xetex:將下面的保存為1.tex
  1. \def\folio{}  % disable page number
  2. \XeTeXpdffile "include1.pdf" width 2cm
  3. \XeTeXpdffile "include2.pdf" width 2cm
  4. \bye
复制代码
运行xetex 1.tex得到1.pdf,看上去內容和pdfTeX生成的1.tex相同,但大小為16.9KB,檢查發現含有2個相同的fontfile,說明xeTeX没有合併字體
$type 1.pdf (16.97 KB, 下载次数: 0)

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-2-8 16:04
hbghlyj 发表于 2024-2-6 12:43
用pdfpages的\includepdf嵌入其它PDF時,會把被嵌入的PDF所含的字體原封不動全部引入,即使它與當前的PDF使 ...


1#圖片不可見?昨天還能看到……

点评

我前晚回帖时就已经看不到 1# 的第一个图。你昨天看到的可能是缓存?  发表于 2024-2-8 17:01
但為啥啊😦  发表于 2024-2-8 17:33

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-2-8 17:35
最新版7.0.1没有Glyph name:
Screenshot 2024-02-08 093714.png
font-viewer發现7.0.0版本有Glyph name:
Screenshot 2024-02-08 093757.png
所以ttf2tfm需要用Version 7.0.0
$type Tahoma.ttf (877.35 KB, 下载次数: 0)
$type Untitled-1.sh (753 Bytes, 下载次数: 0)
将這兩個文件 放在同一目录下,打開bash运行:
$ ./Untitled-1.sh
ttf2tfm: WARNING: Cannot find character `compwordmark'
         specified in input encoding.
ttf2tfm: WARNING: Cannot find character `perthousandzero'
         specified in input encoding.
ttf2tfm: WARNING: Cannot find character `dotlessj'
         specified in input encoding.
ttf2tfm: WARNING: Cannot find character `ff'
         specified in input encoding.
ttf2tfm: WARNING: Cannot find character `ffi'
         specified in input encoding.
ttf2tfm: WARNING: Cannot find character `ffl'
         specified in input encoding.
ttf2tfm: WARNING: Cannot find character `visualspace'
         specified in input encoding.
ttf2tfm: WARNING: Character `hyphen' encoded twice in input encoding
         (positions 2d and 7f; the latter is ignored).
ttf2tfm: WARNING: Cannot map character `compwordmark'
         specified in output encoding.
ttf2tfm: WARNING: Cannot map character `perthousandzero'
         specified in output encoding.
ttf2tfm: WARNING: Cannot map character `dotlessj'
         specified in output encoding.
ttf2tfm: WARNING: Cannot map character `ff'
         specified in output encoding.
ttf2tfm: WARNING: Cannot map character `ffi'
         specified in output encoding.
ttf2tfm: WARNING: Cannot map character `ffl'
         specified in output encoding.
ttf2tfm: WARNING: Cannot map character `visualspace'
         specified in output encoding.
tahoma   tahoma.ttf Encoding=T1-WGL4.enc
This is VPtoVF, Version 1.6 (MiKTeX 22.7.25 NEXT)
'000 '001 '002 '003 '004 '005 '006 '007
'010 '011 '012 '013 '014 '015 '016 '017
'020 '021 '022 '023 '024 '025 '026 '031
'034 '035 '041 '042 '043 '044 '045 '046
'047 '050 '051 '052 '053 '054 '055 '056
'057 '060 '061 '062 '063 '064 '065 '066
'067 '070 '071 '072 '073 '074 '075 '076
'077 '100 '101 '102 '103 '104 '105 '106
'107 '110 '111 '112 '113 '114 '115 '116
'117 '120 '121 '122 '123 '124 '125 '126
'127 '130 '131 '132 '133 '134 '135 '136
'137 '140 '141 '142 '143 '144 '145 '146
'147 '150 '151 '152 '153 '154 '155 '156
'157 '160 '161 '162 '163 '164 '165 '166
'167 '170 '171 '172 '173 '174 '175 '176
'177 '200 '201 '202 '203 '204 '205 '206
'207 '210 '211 '212 '213 '214 '215 '216
'217 '220 '221 '222 '223 '224 '225 '226
'227 '230 '231 '232 '233 '234 '235 '236
'237 '240 '241 '242 '243 '244 '245 '246
'247 '250 '251 '252 '253 '254 '255 '256
'257 '260 '261 '262 '263 '264 '265 '266
'267 '270 '271 '272 '273 '274 '275 '276
'277 '300 '301 '302 '303 '304 '305 '306
'307 '310 '311 '312 '313 '314 '315 '316
'317 '320 '321 '322 '323 '324 '325 '326
'327 '330 '331 '332 '333 '334 '335 '336
'337 '340 '341 '342 '343 '344 '345 '346
'347 '350 '351 '352 '353 '354 '355 '356
'357 '360 '361 '362 '363 '364 '365 '366
'367 '370 '371 '372 '373 '374 '375 '376
'377.
I had to round some heights by 0000011 units.
I had to round some depths by 0000001 units.

Warning: ttf2afm (file tahoma.ttf): glyph `compwordmark' not found

Warning: ttf2afm (file tahoma.ttf): glyph `perthousandzero' not found

Warning: ttf2afm (file tahoma.ttf): glyph `dotlessj' not found

Warning: ttf2afm (file tahoma.ttf): glyph `ff' not found

Warning: ttf2afm (file tahoma.ttf): glyph `fi' not found

Warning: ttf2afm (file tahoma.ttf): glyph `fl' not found

Warning: ttf2afm (file tahoma.ttf): glyph `ffi' not found

Warning: ttf2afm (file tahoma.ttf): glyph `ffl' not found

Warning: ttf2afm (file tahoma.ttf): glyph `visualspace' not found

Warning: ttf2afm (file tahoma.ttf): glyph `Odblacute' not found

Warning: ttf2afm (file tahoma.ttf): glyph `Tcedilla' not found

Warning: ttf2afm (file tahoma.ttf): glyph `Udblacute' not found

Warning: ttf2afm (file tahoma.ttf): glyph `Zdot' not found

Warning: ttf2afm (file tahoma.ttf): glyph `odblacute' not found

Warning: ttf2afm (file tahoma.ttf): glyph `tcedilla' not found

Warning: ttf2afm (file tahoma.ttf): glyph `udblacute' not found

Warning: ttf2afm (file tahoma.ttf): glyph `zdot' not found

Warning: ttf2afm (file tahoma.ttf): glyph `Germandbls' not found
可以看到,有些glyph找不到,但是常用glyph都有了。
將生成的
tahomamn8t.afm放入MiKTeX\fonts\afm\ms\tahoma
tahomamn8t.tfm放入MiKTeX\fonts\tfm\ms\tahoma
剩下的tahoma.vpl、tahomamn8t.vf好像没有用,可以删了
新建文件t1tahoma.fd、tahoma.map放入MiKTeX\fonts\map\pdftex\ms\tahoma
$type t1tahoma.fd (486 Bytes, 下载次数: 0)
$type Tahoma.map (81 Bytes, 下载次数: 1)
在MiKTeX console刷新File name database和font map files

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-2-8 18:20
Business research包含Georgia和Tahoma!
...The main target
group are users who work with pdfLATEX on MS Windows. The style will work on other platforms, too,
but more additional preparation is needed as the fonts ``Georgia'' and ``Tahoma'' are part of the MS
Windows operating system, but are not immediately available on other platforms

If you want to use the style on a system where
``Georgia'' and ``Tahoma'' are not available, you
have to install them:
1. Get a copy of both font families1
2. Extract the packages (e.g. by using cabextract)
3. Copy all extracted .ttf files (Georgia.ttf, Geor-
giab.ttf, Georgiai.ttf, Georgiaz.ttf, Tahoma.ttf,
Tahomabd.ttf) into your working directory.
To put the fonts in the working directory is the
most simple though not a smart way to access
them. You can also install them as well to your TeX
distribution. Please refer to ist documentation for
details.

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2024-2-8 20:41
本帖最后由 hbghlyj 于 2024-2-8 23:34 编辑 @kuing 請問1#的附件丢了嗎?

在編輯頁打開圖片列表能看到,說明不是編輯帖子删除的:
Screenshot 2024-02-08 233306.png

在“最新圖片”裡還可以看到:
Screenshot 2024-02-08 232811.png

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 11:58

Powered by Discuz!

× 快速回复 返回顶部 返回列表