mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-07 09:01:38 -04:00
Fix #7241 ('Generate Cover' cannot support Asian characters)
This commit is contained in:
parent
51a79f25c7
commit
e83dc0e800
@ -203,3 +203,11 @@ content_server_wont_display = ['']
|
|||||||
# level sorts, and if you are seeing a slowdown, reduce the value of this tweak.
|
# level sorts, and if you are seeing a slowdown, reduce the value of this tweak.
|
||||||
maximum_resort_levels = 5
|
maximum_resort_levels = 5
|
||||||
|
|
||||||
|
# Absolute path to a TTF font file to use as the font for the title and author
|
||||||
|
# when generating a default cover. Useful if the default font (Liberation
|
||||||
|
# Serif) does not contain glyphs for the language of the books in your library.
|
||||||
|
generate_cover_title_font = None
|
||||||
|
|
||||||
|
# Absolute path to a TTF font file to use as the font for the footer in the
|
||||||
|
# default cover
|
||||||
|
generate_cover_foot_font = None
|
||||||
|
@ -9,6 +9,7 @@ import os
|
|||||||
|
|
||||||
from calibre.utils.magick import Image, DrawingWand, create_canvas
|
from calibre.utils.magick import Image, DrawingWand, create_canvas
|
||||||
from calibre.constants import __appname__, __version__
|
from calibre.constants import __appname__, __version__
|
||||||
|
from calibre.utils.config import tweaks
|
||||||
from calibre import fit_image
|
from calibre import fit_image
|
||||||
|
|
||||||
def normalize_format_name(fmt):
|
def normalize_format_name(fmt):
|
||||||
@ -113,7 +114,9 @@ def add_borders_to_image(img_data, left=0, top=0, right=0, bottom=0,
|
|||||||
|
|
||||||
def create_text_wand(font_size, font_path=None):
|
def create_text_wand(font_size, font_path=None):
|
||||||
if font_path is None:
|
if font_path is None:
|
||||||
font_path = P('fonts/liberation/LiberationSerif-Bold.ttf')
|
font_path = tweaks['generate_cover_title_font']
|
||||||
|
if font_path is None:
|
||||||
|
font_path = P('fonts/liberation/LiberationSerif-Bold.ttf')
|
||||||
ans = DrawingWand()
|
ans = DrawingWand()
|
||||||
ans.font = font_path
|
ans.font = font_path
|
||||||
ans.font_size = font_size
|
ans.font_size = font_size
|
||||||
@ -203,8 +206,11 @@ def create_cover_page(top_lines, logo_path, width=590, height=750,
|
|||||||
bottom += line.bottom_margin
|
bottom += line.bottom_margin
|
||||||
bottom -= top_lines[-1].bottom_margin
|
bottom -= top_lines[-1].bottom_margin
|
||||||
|
|
||||||
|
foot_font = tweaks['generate_cover_foot_font']
|
||||||
|
if not foot_font:
|
||||||
|
foot_font = P('fonts/liberation/LiberationMono-Regular.ttf')
|
||||||
vanity = create_text_arc(__appname__ + ' ' + __version__, 24,
|
vanity = create_text_arc(__appname__ + ' ' + __version__, 24,
|
||||||
font=P('fonts/liberation/LiberationMono-Regular.ttf'))
|
font=foot_font)
|
||||||
lwidth, lheight = vanity.size
|
lwidth, lheight = vanity.size
|
||||||
left = int(max(0, (width - lwidth)/2.))
|
left = int(max(0, (width - lwidth)/2.))
|
||||||
top = height - lheight - 10
|
top = height - lheight - 10
|
||||||
|
Loading…
x
Reference in New Issue
Block a user