2012-06-19 2 views
0

verdana.ttf 글꼴을 사용하여 Java로 RTF 보고서를 만들려고하는데 Linux에서 작동하지 않습니다.verdana font on linux

아무도 내가 이것을하는 방법을 알고 있습니까?

 String contextPath = FacesUtil.getServletContext().getRealPath("\\"); 
    try { 
      FontFactory.register(contextPath + "WEB-INF\\Fonts\\verdana.ttf"); 
    } catch (Exception e) { 
      e.printStackTrace(); 
    } 

    if (negrito) { 
      font = FontFactory.getFont("Verdana", 8, Font.BOLD, new Color(0, 0, 0)); 
    } 
    cell = new Cell(new Paragraph(paragraph, font)); 
      cell.setBackgroundColor(new Color(255, 255, 255)); 
      cell.setBorderColor(new Color(255, 255, 255)); 
      if (center) 
       cell.setHorizontalAlignment(Cell.ALIGN_LEFT); 

      cell.setRowspan(1); 
      cell.setColspan(1); 
      return cell; 
+0

정의는 "작동하지 않습니다." 네 문제가 뭐니? –

답변

2

나는

\\

는 윈도우 전용입니다 ... 리눅스에서 작동하지 않는 경우 하드 코드 파일 분리 당신에게 있기 때문에 같아요. 필드를 System.getProperty("file.separator")으로 바꾸십시오.

예 :

String separator = System.getProperty("file.separator"); 
FontFactory.register(contextPath + "WEB-INF"+separator+"Fonts"+separator+"verdana.ttf"); 
+0

정말 고마워요 ... : D –

+0

괜찮습니다. 아무쪼록 환영합니다;) –