2023/09/03
Asciidoctor-pdf 한글 적용하기
개발 문서를 Asciidoctor를 사용해보고자 알아보던 중 Asciidoctor 문서를 PDF로 생성할 경우 한글 출력에 문제가 있음이 확인되었다.
Asciidoctor 의 Theme 의 font 설정을 통해 해결할 수 있다는 글을 보고 방법을 찾아 보았다.
문서의 독립적인 Theme를 설정하는 것으로 Theme중 font에 대한 내용만 재정의 하여 대응할 수 있었다.
먼저 Theme 를 재정의하고 사용할 Font를 저장하기위해 문서 폴더 하위에 res 폴더을 만들어 두었다. 그리고 그 폴더에서 사용할 맑은 고딕 폰트 "malgun.ttf"와 "D2Coding-Ver1.3.2-20180524.ttf"를 복사해 두었다.
그리고 Theme를 작성하기위해 설치된 기본 Theme인 default-theme.yaml 파일을 my-theme.yaml로 복사하였다.
default-theme.yaml파일을 asciidoctor-pdf 가 설치된 경로의 data\themes 에서 복사하였다.
복사하고 기본값을 반영하기위해 extends: default를 추가하고 필요한 부분만 아래와 같이 작성하였다.
extends: default
font:
catalog:
# Noto Serif supports Latin, Latin-1 Supplement, Latin Extended-A, Greek, Cyrillic, Vietnamese & an assortment of symbols
Noto Sans:
normal: malgun.ttf
bold: malgun.ttf
italic: malgun.ttf
bold_italic: malgun.ttf
# M+ 1mn supports ASCII and the circled numbers used for conums
M+ 1mn:
normal: D2Coding-Ver1.3.2-20180524.ttf
bold: D2Coding-Ver1.3.2-20180524.ttf
italic: D2Coding-Ver1.3.2-20180524.ttf
bold_italic: D2Coding-Ver1.3.2-20180524.ttf
page:
background_color: FFFFFF
layout: portrait
initial_zoom: FitH
margin: [0.4in, 0.4in, 0.4in, 0.4in]
# margin_inner and margin_outer keys are used for recto/verso print margins when media=prepress
margin_inner: 0.0in
margin_outer: 0.0in
size: A4
base:
font_family: Noto Sans
이렇게 정의한 theme 파일과 폰트를 적용하기위해 아래 명령을 수행하였다.
asciidoctor-pdf --theme my-theme.yml -a pdf-themesdir=res -a pdf-fontsdir="res;GEM_FONTS_DIR" test.adoc --out-file test_my2.pdf그 결과 한글은 정상적으로 출력 되는 것을 확인하였다.
그래서 추가 정보(https://docs.asciidoctor.org/pdf-converter/latest/theme/cjk/)를 찾아 수정하였다.
extends: default
font:
catalog:
merge: true
Noto Sans KR: malgun.ttf
Noto Sans Mono KR: D2Coding-Ver1.3.2-20180524.ttf
fallbacks:
- Noto Serif
page:
background_color: FFFFFF
layout: portrait
initial_zoom: FitH
margin: [0.4in, 0.4in, 0.4in, 0.4in]
# margin_inner and margin_outer keys are used for recto/verso print margins when media=prepress
margin_inner: 0.0in
margin_outer: 0.0in
size: A4
base:
font_family: Noto Sans KR
codespan:
font-family: Noto Sans Mono KR
kbd:
font-family: $codespan-font-family
code:
font-family: $codespan-font-family
위 Theme 로 얻은 결과이다.
한글과 키보드 단축키 매트로가 모두 정상적으로 출력되는 결과를 얻었다.
2016/10/04
wofstream을 이용하여 한글 출력하기
std::locale::global(std::locale("Korean")); // 방법 #1
std::locale::global(std::locale("")); // 방법 #2
wofstream fsOut;
fsOut.imbue(std::locale("Korean")); // 방법 #3
fsOut.imbue(std::locale("")); // 방법 #4
fsOut.open( L"Output File Path", std::ios::out );
2011/12/20
Doxygen 1.7.x.x 한글 출력 문제
Doxygen 설정 중에서 DOXYFILE_ENCODING(=UTF-8) 과 OUTPUT_LANGUAGE(=English) 를 아무리 바꾸어 보아도 현상은 달라지지 않았다.
OUTPUT_LANGUAGE를 Korean으로 변경을 하면 기본적인 문자는 한글로 잘 보여지는데 코드상 작성한 문서는 한글이 깨져서 보인다.
변경하던 중 Input 항목에서 INPUT_ENCODING 이 기본 값으로 UTF-8로 설정이 되어 있는데 본인이 작업중인 소스 파일(Visual Studio)은 UTF-8 형식이 아닌 일반 ASCII 파일 이다. 그래서 이 부분을 EUC-KR로 변경을 하니 한글이 잘 출력이 되었다.
혹시나 해서 INPUT_ENCODING 항목을 CP949 로 설정을 하여도 한글 출력에 문제가 없었다.<
Original Post : http://neodreamer-dev.tistory.com/626
2011/03/31
TortoiseSVN 에서 로그에 한글 입력이 안되는 경우 해결법
Log 메시지 입력 화면
원인을 찾던 중 이 문제가 영문 OS 와 영문 TortoiseSVN 을 사용할 경우 발생하는 것으로 보였다. TortoiseSVN 한글 언어팩을 설치하면 해결 될 것도 같았지만 언어팩을 설치하기 싫어서 다른 방법을 찾아 보았다.
방법은 TortoiseSVN 설정창에서 Dialog 1 의 로그 메시지 폰트 설정 부분을 한글을 지원하는 폰트로 변경을 하니 한글 입력이 가능하였다.
Log 메시지 폰트 설정 대화상자
Log 메시지 폰트를 한글로 바꾼 후 입력 화면
&
Original Post : http://neodreamer-dev.tistory.com/523
2009/10/26
Redmine 한글 PDF 출력 문제
검색된 자료 중 "Redmine pdf export 시 한글 깨지는 문제" 문서를 참조하여 해결을 하였다.
해결 방법은 PDF 출력 루틴과 한국어 출력 부분인데 "Redmine pdf export 시 한글 깨지는 문제" 문서에서 제시한 해결책이 그대로 적용되었다. 단, 버전의 차이에서 인지 수정해야할 파일들의 위치가 달랐다. 검색된 문서에서 제시된 redmine 버전은 0.8이고 현재 설치된 버전은 그 보다 상위 버전인 0.8.5 이다.
우선 PDF 출력 파일을 수정하였다.
파일의 위치는 lib\redmine\export\pdf.rb 이다. 이 파일의 내용중 "zh-tw" 의 내용을 복사하여 한글에 맞도록 수정한다.
when 'zh-tw'
extend(PDF_Chinese)
AddBig5Font()
@font_for_content = 'Big5'
@font_for_footer = 'Big5'
# 한글 출력을 위해 추가된 부분
when 'ko'
extend(PDF_Korean)
AddUHCFont()
@font_for_content = 'UHC'
@font_for_footer = 'UHC'
다음 수정 사항은 폰트에 대한 것인데, 기본 적으로 명조체 출력을 지원하고 있는데 이 부분을 고딕체로 수정하는 내용이다. 명조체로 출력을 원하면 수정하지 않으면 된다.
수정해야할 파일은 vendor\plugins\rfpdf\lib\rfpdf\korean.rb
# HYSMyeongJoStd-Medium-Acro 를 HYGoThic-Medium로 바꾼다.
def AddUHCFont(family='UHC',name='HYGoThic-Medium')
#Add UHC font with proportional Latin
cw=UHC_widths
cMap='KSCms-UHC-H'
registry={'ordering'=>'Korea1','supplement'=>1}
AddCIDFonts(family,name,cw,cMap,registry)
end
def AddUHChwFont(family='UHC-hw',name='HYGoThic-Medium')
#Add UHC font with half-witdh Latin
32.upto(126) do |i|
cw[i.chr]=500
end
cMap='KSCms-UHC-HW-H'
registry={'ordering'=>'Korea1','supplement'=>1}
AddCIDFonts(family,name,cw,cMap,registry)
end
그리고 MultiCell 함수와 MBMultiCell 함수를 chinese.rb에서 복사해 온다.
아래 내용을 복사해 온 내용이다.
def MultiCell(w,h,txt,border=0,align='L',fill=0)
if(@CurrentFont['type']=='Type0')
MBMultiCell(w,h,txt,border,align,fill)
else
super(w,h,txt,border,align,fill)
end
end
def MBMultiCell(w,h,txt,border=0,align='L',fill=0)
#Multi-byte version of MultiCell()
cw=@CurrentFont['cw']
if(w==0)
w=@w-@rMargin-@x
end
wmax=(w-2*@cMargin)*1000/@FontSize
s=txt.gsub("\r",'')
nb=s.length
if(nb>0 and s[nb-1]=="\n")
nb-=1
end
b=0
if(border)
if(border==1)
border='LTRB'
b='LRT'
b2='LR'
else
b2=''
if(border.to_s.index('L'))
b2+='L'
end
if(border.to_s.index('R'))
b2+='R'
end
b=border.to_s.index('T') ? b2+'T' : b2
end
end
sep=-1
i=0
j=0
l=0
nl=1
while(i<nb)
#Get next character
c=s[i]
#Check if ASCII or MB
ascii=(c<128)
if(c.chr=="\n")
#Explicit line break
Cell(w,h,s[j,i-j],b,2,align,fill)
i+=1
sep=-1
j=i
l=0
nl+=1
if(border and nl==2)
b=b2
end
next
end
if(!ascii)
sep=i
ls=l
elsif(c==' ')
sep=i
ls=l
end
l+=ascii ? (cw[c.chr] || 0) : 1100
if(l>wmax)
#Automatic line break
if(sep==-1 or i==j)
if(i==j)
i+=ascii ? 1 : 3
end
Cell(w,h,s[j,i-j],b,2,align,fill)
else
Cell(w,h,s[j,sep-j],b,2,align,fill)
i=(s[sep]==' ') ? sep+1 : sep
end
sep=-1
j=i
l=0
# nl+=1
if(border and nl==2)
b=b2
end
else
i+=ascii ? 1 : 3
end
end
#Last chunk
if(border and not border.to_s.index('B').nil?)
b+='B'
end
Cell(w,h,s[j,i-j],b,2,align,fill)
@x=@lMargin
end
이제 redmine 을 재시작하고 Gantt Chart 나 작업 목록에서 PDF로 출력을 해보면 한글이 깨끗하게 나오는 걸 확인할 수 있다
Original Post : http://neodreamer-dev.tistory.com/337


