summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/texnegar/texnegar-xetex-kashida.tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-08-30 21:12:39 +0000
committerKarl Berry <karl@freefriends.org>2020-08-30 21:12:39 +0000
commit5474b1b43c3b0b1c86af620a938589c42e9cd01e (patch)
tree39b0ee71d1b1d6891b5cd7c58adab853ac565f18 /Master/texmf-dist/tex/latex/texnegar/texnegar-xetex-kashida.tex
parent9fbec9a9d124a7b55050150eb52e1e3239597579 (diff)
texnegar (30aug20)
git-svn-id: svn://tug.org/texlive/trunk@56215 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/texnegar/texnegar-xetex-kashida.tex')
-rw-r--r--Master/texmf-dist/tex/latex/texnegar/texnegar-xetex-kashida.tex213
1 files changed, 213 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/texnegar/texnegar-xetex-kashida.tex b/Master/texmf-dist/tex/latex/texnegar/texnegar-xetex-kashida.tex
new file mode 100644
index 00000000000..5f927502cea
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/texnegar/texnegar-xetex-kashida.tex
@@ -0,0 +1,213 @@
+%%
+%% This is file `texnegar-xetex-kashida.tex',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% texnegar.dtx (with options: `texnegar-xetex-kashida-tex')
+%%
+%% Copyright (C) 2020 Hossein Movahhedian
+%%
+%% It may be distributed and/or modified under the LaTeX Project Public License,
+%% version 1.3c or higher (your choice). The latest version of
+%% this license is at: http://www.latex-project.org/lppl.txt
+%%
+\ProvidesExplFile {texnegar-xetex-kashida.tex} {2020-08-30} {0.1b} { Full implementation of kashida feature in XeLaTex and LuaLaTeX }
+
+\newXeTeXintercharclass \c_texnegar_d_charclass % dual-joiner class
+\newXeTeXintercharclass \c_texnegar_l_charclass % lam
+\newXeTeXintercharclass \c_texnegar_r_charclass % right-joiner
+\newXeTeXintercharclass \c_texnegar_a_charclass % alef
+\newXeTeXintercharclass \c_texnegar_y_charclass % yeh
+
+\tex_input:D { texnegar-common-kashida.tex }
+
+\tl_set:Nn \l_texnegar_use_color_tl
+ {
+ \bool_if:NTF \l_texnegar_color_bool
+ {
+ \colorlet{default}{\l_texnegar_color_tl}
+ }
+ {
+ \colorlet{default}{.}
+ }
+ \color{default}
+ }
+
+%% Partly adapted from the code provided by David Carlisle in:
+%% https://tex.stackexchange.com/questions/356709/how-to-know-the-width-and-fill-the-glue-space-between-two-characters-when-using/356721#356721
+\cs_new:Npn \texnegar_kashida_glyph #1
+{
+ \bool_if:NT \l_texnegar_kashida_fix_bool
+ {
+ \c_texnegar_lrm_int\tex_penalty:D 10000
+ \mode_leave_vertical:
+ \tex_global:D \tex_advance:D \l_texnegar_counter_int \c_one_int
+
+ \tl_set:Nx \l_texnegar_pos_tl { p\tex_romannumeral:D \l_texnegar_counter_int }
+ \tl_set:Nx \l_texnegar_zref_tl { z\tex_romannumeral:D \l_texnegar_counter_int }
+
+ \zsaveposx{x_i_\l_texnegar_zref_tl}
+ \tl_set:Nx \l_tmpa_tl
+ {
+ \iow_now:cx { @auxout }
+ {
+ \token_to_str:N \gdef \exp_after:wN \token_to_str:N \cs:w xi\l_texnegar_pos_tl \cs_end: { \zposx{ x_i_\l_texnegar_zref_tl } }
+ }
+ }
+ \l_tmpa_tl
+ \skip_horizontal:n { #1 }
+ \zsaveposx{x_f_\l_texnegar_zref_tl}
+ \tl_set:Nx \l_tmpa_tl
+ {
+ \iow_now:cx { @auxout }
+ {
+ \token_to_str:N \gdef \exp_after:wN \token_to_str:N \cs:w xf\l_texnegar_pos_tl \cs_end: { \zposx{ x_f_\l_texnegar_zref_tl } }
+ }
+ }
+ \l_tmpa_tl
+ \exp_after:wN
+ \if_meaning:w
+ \cs:w xi\l_texnegar_pos_tl \cs_end: \tex_relax:D
+ \else:
+ \dim_set:Nn \l_texnegar_diff_pos_dim
+ {
+ \dim_eval:n { \cs:w xi\l_texnegar_pos_tl \cs_end: sp - \cs:w xf\l_texnegar_pos_tl \cs_end: sp }
+ }
+ \dim_compare:nTF { \l_texnegar_diff_pos_dim == 0sp }
+ { }
+ { \llap { \resizebox { \l_texnegar_diff_pos_dim \tex_relax:D } { \height } { \l_texnegar_use_color_tl \c_texnegar_ksh_int } } }
+ \fi:
+ }
+}
+
+\cs_new:Npn \texnegar_kashida_leaders #1
+{
+ \bool_if:NT \l_texnegar_kashida_fix_bool
+ {
+ \tl_if_eq:NNTF \l_texnegar_gap_filler_tl \l_texnegar_stretch_leaders_glyph_tl
+ {
+ \tl_set:Nx \l_texnegar_font_full_tl { \tex_fontname:D \tex_the:D \tex_font:D }
+ \tl_set:Nx \l_texnegar_font_name_tl { \l_texnegar_font_full_tl }
+ \tl_set:Nx \l_texnegar_font_init_tl { \l_texnegar_font_name_tl }
+ \regex_replace_once:nnN { ^"\[?(HM)[\_\ ](X|F).* } { \1\2 } \l_texnegar_font_init_tl\relax
+ \tl_set:Nn \l_tmpa_tl { HMF }
+ \tl_set:Nn \l_tmpb_tl { HMX }
+ \bool_if:nTF { \str_if_eq_p:NN { \l_texnegar_font_init_tl } { \l_tmpa_tl } || \str_if_eq_p:NN { \l_texnegar_font_init_tl } { \l_tmpb_tl } }
+ {
+ \hbox_set:Nn \l_texnegar_ksh_box { \l_texnegar_use_color_tl \XeTeXglyph\XeTeXglyphindex"kashida" }
+ \c_texnegar_zwj_int \tex_penalty:D 10000
+ \tex_leaders:D \copy\l_texnegar_ksh_box \skip_horizontal:n { #1 }
+ \c_texnegar_zwj_int
+ }
+ {
+ \msg_error:nnx { texnegar } { hm-series-font-not-found } { \l_texnegar_font_name_tl }
+ }
+ }
+ {
+ %% Partly adapted from the code provided by Jonathan Kew in:
+ %% https://tug.org/pipermail/xetex/2009-February/012307.html.
+ %% Somebody notified me that the code in 'kashida-xepersian.def' from xepersian
+ %% package is an exact copy of Jonathan Kew's code. Being unaware of this, in
+ %% the earlier versions of this package I made a mistake and acknowledged
+ %% Vafa Khalighi instead of Jonathan Kew. A sincere thank you to Jonathan Kew
+ %% for his excellent code.
+ \c_texnegar_lrm_int\c_texnegar_zwj_int
+ {\l_texnegar_use_color_tl\tex_penalty:D 10000
+ \tex_leaders:D \tex_hrule:D height \XeTeXglyphbounds \c_texnegar_two_int
+ \int_use:N \XeTeXcharglyph \c_texnegar_ksh_int depth \XeTeXglyphbounds \c_texnegar_four_int
+ \int_use:N \XeTeXcharglyph \c_texnegar_ksh_int \skip_horizontal:n { #1 }
+ }
+ \c_texnegar_zwj_int
+ }
+ }
+}
+
+\XeTeXinterchartokenstate = 1
+
+\clist_set:Nn \l_texnegar_a_clist { 0622,0623,0625,0627 } % ‏ا، إ، أ، آ‏
+\clist_map_inline:Nn \l_texnegar_a_clist
+ {
+ \XeTeXcharclass "#1 \c_texnegar_a_charclass
+ }
+
+\clist_set:Nn \l_texnegar_d_clist { 0626,0628,062A,062B,062C,062D,062E,0633,0634,0635,0636,0637,0638,0639,063A,0640,0641,0642,0643,0645,0646,0647,067E,0686,06A9,06AF } % ‏ئ,ب,ت,ث,ج,ح,خ,س,ش,ص,ض,ط,ظ,ع,غ,ـ,ف,ق,ك,م,ن,ه,پ,چ,ک,گ‏
+\clist_map_inline:Nn \l_texnegar_d_clist
+ {
+ \XeTeXcharclass "#1 \c_texnegar_d_charclass
+ }
+
+\clist_set:Nn \l_texnegar_l_clist { 0644 } % ‏ل‏
+\clist_map_inline:Nn \l_texnegar_l_clist
+ {
+ \XeTeXcharclass "#1 \c_texnegar_l_charclass
+ }
+
+\clist_set:Nn \l_texnegar_r_clist { 0624,0629,062F,0630,0631,0632,0648,0698 } % ‏ؤ,ة,د,ذ,ر,ز,و,ژ‏
+\clist_map_inline:Nn \l_texnegar_r_clist
+ {
+ \XeTeXcharclass "#1 \c_texnegar_r_charclass
+ }
+
+\clist_set:Nn \l_texnegar_y_clist { 0649,064A,06CC } % ‏ی,ي,ى‏
+\clist_map_inline:Nn \l_texnegar_y_clist
+ {
+ \XeTeXcharclass "#1 \c_texnegar_y_charclass
+ }
+
+\tl_if_eq:NNTF \l_texnegar_gap_filler_tl \l_texnegar_stretch_glyph_tl {
+ \XeTeXinterchartoks \c_texnegar_y_charclass \c_texnegar_y_charclass = {
+ \bool_if:NTF \l_texnegar_kashida_fix_bool
+ { \c_texnegar_zwj_int \texnegar_kashida_glyph \l_texnegar_skip_default_tl \c_texnegar_zwj_int }
+ { \c_texnegar_zwj_int \texnegar_kashida_glyph \c_texnegar_skip_a_tl \c_texnegar_zwj_int }
+ }
+ \XeTeXinterchartoks \c_texnegar_d_charclass \c_texnegar_y_charclass = {
+ \bool_if:NTF \l_texnegar_kashida_fix_bool
+ { \c_texnegar_zwj_int \texnegar_kashida_glyph \l_texnegar_skip_default_tl \c_texnegar_zwj_int }
+ { \c_texnegar_zwj_int \texnegar_kashida_glyph \c_texnegar_skip_a_tl \c_texnegar_zwj_int }
+ }
+ \XeTeXinterchartoks \c_texnegar_y_charclass \c_texnegar_d_charclass = { \c_texnegar_zwj_int \texnegar_kashida_glyph \c_texnegar_skip_a_tl \c_texnegar_zwj_int }
+ \XeTeXinterchartoks \c_texnegar_d_charclass \c_texnegar_d_charclass = { \c_texnegar_zwj_int \texnegar_kashida_glyph \c_texnegar_skip_a_tl \c_texnegar_zwj_int }
+ \XeTeXinterchartoks \c_texnegar_l_charclass \c_texnegar_d_charclass = { \c_texnegar_zwj_int \texnegar_kashida_glyph \c_texnegar_skip_a_tl \c_texnegar_zwj_int }
+ \XeTeXinterchartoks \c_texnegar_d_charclass \c_texnegar_l_charclass = { \c_texnegar_zwj_int \texnegar_kashida_glyph \c_texnegar_skip_a_tl \c_texnegar_zwj_int }
+ \XeTeXinterchartoks \c_texnegar_l_charclass \c_texnegar_l_charclass = { \c_texnegar_zwj_int \texnegar_kashida_glyph \c_texnegar_skip_a_tl \c_texnegar_zwj_int }
+ \XeTeXinterchartoks \c_texnegar_d_charclass \c_texnegar_r_charclass = { \c_texnegar_zwj_int \texnegar_kashida_glyph \c_texnegar_skip_a_tl \c_texnegar_zwj_int }
+ \XeTeXinterchartoks \c_texnegar_d_charclass \c_texnegar_a_charclass = { \c_texnegar_zwj_int \texnegar_kashida_glyph \c_texnegar_skip_a_tl \c_texnegar_zwj_int }
+ \XeTeXinterchartoks \c_texnegar_l_charclass \c_texnegar_r_charclass = { \c_texnegar_zwj_int \texnegar_kashida_glyph \c_texnegar_skip_a_tl \c_texnegar_zwj_int }
+ \XeTeXinterchartoks \c_texnegar_l_charclass \c_texnegar_a_charclass = { }
+}
+{
+ \bool_if:nTF {
+ \tl_if_eq_p:NN \l_texnegar_gap_filler_tl \l_texnegar_stretch_leaders_glyph_tl ||
+ \tl_if_eq_p:NN \l_texnegar_gap_filler_tl \l_texnegar_stretch_leaders_hrule_tl
+ }
+ {
+ \XeTeXinterchartoks \c_texnegar_y_charclass \c_texnegar_y_charclass = {
+ \bool_if:NTF \l_texnegar_kashida_fix_bool
+ { \texnegar_kashida_leaders \l_texnegar_skip_default_tl }
+ { \texnegar_kashida_leaders \c_texnegar_skip_a_tl }
+ }
+ \XeTeXinterchartoks \c_texnegar_d_charclass \c_texnegar_y_charclass = {
+ \bool_if:NTF \l_texnegar_kashida_fix_bool
+ { \texnegar_kashida_leaders \l_texnegar_skip_default_tl }
+ { \texnegar_kashida_leaders \c_texnegar_skip_a_tl }
+ }
+ \XeTeXinterchartoks \c_texnegar_y_charclass \c_texnegar_d_charclass = { \texnegar_kashida_leaders \c_texnegar_skip_a_tl }
+ \XeTeXinterchartoks \c_texnegar_d_charclass \c_texnegar_d_charclass = { \texnegar_kashida_leaders \c_texnegar_skip_a_tl }
+ \XeTeXinterchartoks \c_texnegar_l_charclass \c_texnegar_d_charclass = { \texnegar_kashida_leaders \c_texnegar_skip_a_tl }
+ \XeTeXinterchartoks \c_texnegar_d_charclass \c_texnegar_l_charclass = { \texnegar_kashida_leaders \c_texnegar_skip_a_tl }
+ \XeTeXinterchartoks \c_texnegar_l_charclass \c_texnegar_l_charclass = { \texnegar_kashida_leaders \c_texnegar_skip_a_tl }
+ \XeTeXinterchartoks \c_texnegar_d_charclass \c_texnegar_r_charclass = { \texnegar_kashida_leaders \c_texnegar_skip_a_tl }
+ \XeTeXinterchartoks \c_texnegar_d_charclass \c_texnegar_a_charclass = { \texnegar_kashida_leaders \c_texnegar_skip_a_tl }
+ \XeTeXinterchartoks \c_texnegar_l_charclass \c_texnegar_r_charclass = { \texnegar_kashida_leaders \c_texnegar_skip_a_tl }
+ \XeTeXinterchartoks \c_texnegar_l_charclass \c_texnegar_a_charclass = { }
+ }
+ {
+ \msg_error:nnx { texnegar } { error-value-not-available-for-kashida-option } { \l_texnegar_gap_filler_tl }
+ }
+}
+
+ \endinput
+%%
+%%
+%% End of file `texnegar-xetex-kashida.tex'.