Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

experimental vertical orientation writing support #563

Merged
merged 5 commits into from
Apr 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions doc/sample.css
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,21 @@ p.flushright {
.width-080per { width: 80%; }
.width-090per { width: 90%; }
.width-100per { width: 100%; }

.tcy {
-webkit-text-combine: horizontal;
-webkit-text-combine-upright: all;
text-combine-upright: all;
-epub-text-combine: horizontal;
}

upright-1 {
-webkit-text-combine: horizontal;
-webkit-text-combine-upright: all;
text-combine-upright: all;
-epub-text-combine: horizontal;
}
.upright {
-webkit-text-orientation: upright;
-epub-text-orientation: upright;
}
6 changes: 5 additions & 1 deletion lib/review/builder.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# encoding: utf-8
#
# Copyright (c) 2002-2014 Minero Aoki, Kenshi Muto
# Copyright (c) 2002-2016 Minero Aoki, Kenshi Muto
#
# This program is free software.
# You can distribute or modify this program under the terms of
Expand Down Expand Up @@ -309,6 +309,10 @@ def inline_column_chap(chapter, id)
chapter.column(id).caption
end

def inline_tcy(arg)
"#{arg}[rotate 90 degree]"
end

def raw(str)
if matched = str.match(/\|(.*?)\|(.*)/)
builders = matched[1].split(/,/).map{|i| i.gsub(/\s/, '') }
Expand Down
4 changes: 3 additions & 1 deletion lib/review/compiler.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8
#
# Copyright (c) 2002-2007 Minero Aoki
# Copyright (c) 2009-2010 Minero Aoki, Kenshi Muto
# Copyright (c) 2009-2016 Minero Aoki, Kenshi Muto
#
# This program is free software.
# You can distribute or modify this program under the terms of
Expand Down Expand Up @@ -190,6 +190,7 @@ def inline_defined?(name)
definline :href
definline :recipe
definline :column
definline :tcy

definline :abbr
definline :acronym
Expand Down Expand Up @@ -220,6 +221,7 @@ def inline_defined?(name)
definline :hidx
definline :comment
definline :include
definline :tcy

private

Expand Down
7 changes: 7 additions & 0 deletions lib/review/htmlbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,13 @@ def inline_comment(str)
end
end

def inline_tcy(str)
# 縦中横用のtcy、uprightのCSSスタイルについては電書協ガイドラインを参照
style = "tcy"
style = "upright" if str.size == 1 && str.match(/[[:ascii:]]/)
%Q[<span class="#{style}">#{escape_html(str)}</span>]
end

def inline_raw(str)
super(str)
end
Expand Down
4 changes: 4 additions & 0 deletions lib/review/latexbuilder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,10 @@ def inline_comment(str)
end
end

def inline_tcy(str)
macro('rensuji', escape(str))
end

def bibpaper_header(id, caption)
puts "[#{@chapter.bibpaper(id).number}] #{compile_inline(caption)}"
puts macro('label', bib_label(id))
Expand Down
106 changes: 62 additions & 44 deletions lib/review/layout.tex.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
\documentclass[<%= documentclassoption %>]{<%= documentclass %>}
<% if texcompiler == "uplatex" %>
<%- if texcompiler == "uplatex" -%>
\usepackage[deluxe,uplatex]{otf}
<% else %>
<%- else -%>
\usepackage[deluxe]{otf}
<% end %>
<%- end -%>
\usepackage[dvipdfmx]{color}
\usepackage[dvipdfmx]{graphicx}
\usepackage{framed}
Expand All @@ -28,20 +28,21 @@
\MakeFramed {\FrameRestore}}%
{\endMakeFramed}

<%- unless ["utbook", "tbook"].include?(values["texdocumentclass"][0]) -%>
\usepackage[top=10zw,bottom=12zw,left=10zw,right=10zw]{geometry}
%\usepackage[top=5zw,bottom=5zw,left=1zw,right=1zw]{geometry}

<%- end -%>

\newcommand{\parasep}{\vspace*{3zh}}
\setlength{\footskip}{30pt}

<% if texcompiler == "uplatex" %>
<%- if texcompiler == "uplatex" -%>
\usepackage[dvipdfmx,bookmarks=true,bookmarksnumbered=true,colorlinks=true,%
pdftitle={<%= values.name_of("booktitle") %>},%
pdfauthor={<%= values.names_of("aut").join(I18n.t("names_splitter")) %>}]{hyperref}
% uplatexでのBookmarkの文字化け対策(日本語向け)
\usepackage[dvipdfmx]{pxjahyper}
<% else %>
<%- else -%>
%% Bookmarkの文字化け対策(日本語向け)
\ifnum 46273=\euc"B4C1 % 46273 == 0xB4C1 == 漢(EUC-JP)
\usepackage{atbegshi}%
Expand All @@ -57,14 +58,19 @@
pdftitle={<%= values.name_of("booktitle") %>},%
pdfauthor={<%= values.names_of("aut").join(I18n.t("names_splitter")
) %>}]{hyperref}
<% end %>
<%- end -%>

<%- if ["utbook", "tbook"].include?(values["texdocumentclass"][0]) -%>
\newcommand{\headfont}{\gtfamily\sffamily\bfseries}
\usepackage{plext}
<%- end -%>

<% if config["highlight"] && config["highlight"]["latex"] == "listings" %>
<% if config["language"] == "ja" %>
<%- if config["highlight"] && config["highlight"]["latex"] == "listings" -%>
<%- if config["language"] == "ja" -%>
\usepackage{listings,jlisting}
<% else %>
<%- else -%>
\usepackage{listings}
<% end %>
<%- end -%>
\renewcommand{\lstlistingname}{<%= I18n.t("list")%>}
\lstset{%
breaklines=true,%
Expand Down Expand Up @@ -94,7 +100,7 @@

\lstnewenvironment{reviewcmdlst}[1][]{%
\lstset{backgroundcolor=\color{white}, frameround=tttt, frame=trbl, #1}}{}
<% end %>
<%- end -%>

\newenvironment{reviewimage}{%
\begin{figure}[H]
Expand Down Expand Up @@ -179,9 +185,9 @@
\newcommand{\reviewminicolumntitle}[1]{%
{\large <%= I18n.t("memo_head")%>: #1}\\}

<% if values["toctitle"].present? %>
<%- if values["toctitle"].present? -%>
\renewcommand{\contentsname}{<%= values["toctitle"]%>}
<% end %>
<%- end -%>

\newenvironment{reviewminicolumn}{%
\vspace{1.5zw}\begin{screen}}{%
Expand Down Expand Up @@ -236,26 +242,41 @@
}
\makeatother

<%- if values["usepackage"] -%>
<%= values["usepackage"] %>
<%- end -%>

\usepackage[T1]{fontenc}

\begin{document}

\reviewmainfont

<% if values["titlepage"] %>
<% if custom_titlepage %>
<%- if values["titlepage"] -%>
<%- if custom_titlepage -%>
<%= custom_titlepage %>
<% else %>
<%- else -%>
<%- unless ["utbook", "tbook"].include?(values["texdocumentclass"][0]) -%>
\begin{titlepage}
<% if values["coverimage"] %>
<%- if values["coverimage"] -%>
\begin{center}
%%%\mbox{}\vskip5zw%
\includegraphics[width=\textwidth,height=\textheight,keepaspectratio]{./images/<%= values["coverimage"] %>}
\end{center}
\clearpage
<% end %>
<%- end -%>
<%- else -%>
% 縦書きの表紙
\begin{titlepage}
<%- if values["coverimage"] -%>
\begin{center}
%%%\mbox{}\vskip5zw%
\includegraphics[width=\textheight,height=\textwidth,keepaspectratio,angle=90]{./images/<%= values["coverimage"] %>}
\end{center}
\clearpage
<%- end -%>
<%- end -%>
<%- end -%>
\thispagestyle{empty}
\begin{center}%
\mbox{} \vskip5zw
Expand All @@ -272,30 +293,28 @@
\vskip4zw\mbox{}
\end{center}%
\end{titlepage}
<% end %>
<% end %>
<%- end -%>

\renewcommand{\chaptermark}[1]{{}}
\frontmatter

%%% originaltitle
<% if values["originaltitlefile"] %>
<%- if values["originaltitlefile"] -%>
<%= custom_originaltitlepage %>
<% end %>
<%- end -%>

%%% credit
<% if values["creditfile"] %>
<%- if values["creditfile"] -%>
<%= custom_creditpage %>
<% end %>

<%- end -%>

%% preface
<%= values["pre_str"] %>

<% if values["toc"] %>
<%- if values["toc"] -%>
\setcounter{tocdepth}{<%= values["toclevel"] %>}
\tableofcontents
<% end %>
<%- end -%>

\renewcommand{\chaptermark}[1]{\markboth{\prechaptername\thechapter\postchaptername~#1}{}}
\mainmatter
Expand All @@ -305,30 +324,29 @@
<%= values["appendix_str"] %>

%% backmatter begins
<% if values["post_str"] or values["colophon"] %>
<%- if values["post_str"] or values["colophon"] -%>
\backmatter
<% end %>
<%- end -%>

<% if values["post_str"] %>
<%- if values["post_str"] -%>
<%= values["post_str"] %>
<% end %>

<%- end -%>

%%% profile
<% if values["profile"] %>
<%- if values["profile"] -%>
<%= custom_profilepage %>
<% end %>
<%- end -%>

%%% advfile
<% if values["advfile"] %>
<%- if values["advfile"] -%>
<%= custom_advfilepage %>
<% end %>
<%- end -%>

%%% colophon
<% if values["colophon"] %>
<% if custom_colophonpage %>
<%- if values["colophon"] -%>
<%- if custom_colophonpage -%>
<%= custom_colophonpage %>
<% else %>
<%- else -%>
%% okuduke
\reviewcolophon
\thispagestyle{empty}
Expand All @@ -347,12 +365,12 @@
 \\
\rule[0pt]{14cm}{1pt} \\
<%= values.names_of("rights").join('\\' + '\\') %> \\
<% end %>
<% end %>
<%- end -%>
<%- end -%>

%%% backcover
<% if values["backcover"] %>
<%- if values["backcover"] -%>
<%= custom_backcoverpage %>
<% end %>
<%- end -%>

\end{document}
2 changes: 1 addition & 1 deletion lib/review/pdfmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def get_template

texcompiler = File.basename(@config["texcommand"], ".*")

erb = ERB.new(File.read(template))
erb = ERB.new(File.read(template), nil, '-')
values = @config # must be 'values' for legacy files
erb.result(binding)
end
Expand Down
Loading