XeLaTeX 如何产生旧印刷的粗糙度或不规则度?

XeLaTeX 如何产生旧印刷的粗糙度或不规则度?

我已经非常成功地复制了我在这里描述的古书的古董风格:如何在 LaTeX 中生成古董风格的书籍 然而,还有一件事没有实现。旧印刷品中常见的字体粗糙、不规则或随机性在现代 Latex 中默认无法重现。有一篇关于此的帖子,但我再也找不到了。

有人知道有什么软件包可以做到这一点吗?

答案1

这可以使用 GIMP 来完成。了解 GIMP 的基础知识,这样您就可以在图像上应用不同的效果。在 GIMP 中以更高的分辨率导入您的 pdf(我使用 400+ 像素值,我的显示器是 4k,用这个试试)。此外,将以下脚本放在插件目录中,对于 Windows,它位于C:\Users\<User>\AppData\Roaming\GIMP\2.10\plug-ins

from gimpfu import *

# 1012982852
# 2826674371

def antiquify(image, rndm_pct, rndm_rcount, randomize, seed, horizontal, vertical, low_threshold, high_threshold, spread_amount_x, spread_amount_y, filename='D:/Projects/integer-seqs/output.pdf'):
    pdb.gimp_undo_push_group_start(image)
    for subimage in gimp.image_list():
        pdb.gimp_message('Antiquifying '+str(subimage.ID))
        opacity = 80
        pdb.gimp_context_set_opacity(opacity)
        drawable = subimage.active_layer
        pdb.plug_in_randomize_pick(image,drawable,rndm_pct, rndm_rcount, randomize, seed)
        pdb.plug_in_spread(subimage,drawable,spread_amount_x, spread_amount_y)
        # pdb.plug_in_spread(subimage,drawable,spread_amount_x, spread_amount_y)
        pdb.plug_in_gauss_rle2(subimage,drawable,horizontal, vertical)
        opacity = 97.2
        pdb.gimp_context_set_opacity(opacity)
        pdb.gimp_threshold(drawable, low_threshold, high_threshold)
    pdb.gimp_undo_push_group_end(image)
    pdb.gimp_message('All processing done. Creating pdf')
    images = gimp.image_list()
    # num_images, image_ids = pdb.gimp_image_list()
    num_images = len(images)
    image_ids = [subimage.ID for subimage in images]
    pdb.file_pdf_save_multi(num_images, image_ids, False, False, False, filename, filename)
    pdb.gimp_message('Pdf created at '+filename)
    

register(
    "python-fu-antiquify",
    "Make a LaTeX document antique",
    "",
    "Masum Billal",
    "Masum Billal",
    "2022",
    "Antiquify",
    "",
    [
        # basic parameters are: (UI_ELEMENT, "variable", "label", Default)
        (PF_IMAGE, "image", "takes current image", None),
        (PF_SLIDER, "rndm_pct", "Random Percent for Pick", 10, (0, 100, .5)),
        (PF_SLIDER, "rndm_rcount", "Number of Iteration for Pick", 1, (0, 10, 1)),
        (PF_BOOL, "randomize", "Randomize or not for Pick", True),
        (PF_INT, "seed", "Seed of randomization for Pick", 1),
        (PF_SLIDER, "horizontal", "Horizontal for Gaussian blur", .5, (0, 10, .5)),
        (PF_SLIDER, "vertical", "Vertical for Gaussian blur", .5, (0, 10, .5)),
        (PF_SLIDER, "low_threshold", "Threshold low", 200, (0, 255, 1)),
        (PF_SLIDER, "high_threshold", "Threshold high", 255, (0, 255, 1)),
        (PF_SLIDER, "spread_amount_x", "Horizontal spread", 2, (0, 20, 1)),
        (PF_SLIDER, "spread_amount_y", "Vertical spread", 2, (0, 20, 1)),
        (PF_STRING, "filename", "PDF Filename", None),
    ],
    [],
    antiquify,
    menu="<Image>/Filters/Noise",
)

main()

显然,您可以尝试调整值并添加/删除效果。这样做并获得所需的古代数量。这是一个示例输出。

输出

相关内容