Thursday, December 4, 2008

RandomFontGenerator: No fonts found

com.octo.captcha.component.image.fontgenerator.RandomFontGenerator Constructor threw exception; nested exception is java.lang.Error: Probable fatal error: No fonts found

my os: centos linux

probable reason: in bean configuration are mentioned only windows fonts, that are not shipped by default with linux

<bean id="randomFontGenerator"
  class="com.octo.captcha.component.image.fontgenerator.RandomFontGenerator">
  <!-- Minimal font size -->
  <constructor-arg index="0">
    <value>40</value>
  </constructor-arg>
  <!-- Maximal font size -->
  <constructor-arg index="1">
    <value>50</value>
  </constructor-arg>
  <!-- Allowed font list -->
  <constructor-arg index="2">
    <list>
      <ref bean="fontArial" />
      <ref bean="fontVerdana" />

    </list>
  </constructor-arg>
</bean>

this is bean configuration example from emforge (WEB-INF/classes/META-INF/spring/emforge-security-web.xml)

solution: just install a package that includes windows fonts (Arisl and Verdana). for centos it is yum install liberation-fonts

5 comments:

  1. Am using Icefaces in Centos5( jdk 1.6.06 and jre 6u11 and no X window system in my server ).. Me too getting the same error(java.lang.Error: Probable fatal error: No fonts found) when am using the functions getFontMetrics() and drawString() methods in my Captcha Image Generation programs. I am only using the fonts that me retrieved using ge.getAllFonts() ( i.e., the fonts available in the system ). Pls help me..
    ReplyDelete
  2. Try to install font packages such as freetype and liberation-fonts, maybe they are not installed.
    While googling on that problem I had also found that some jre rpm packages (not the official ones) do not include fonts by default, maybe this is the problem.
    Tell me the results =)
    ReplyDelete
  3. I did yum install liberation-fonts and was able to see magic.Thank you very much...:))
    ReplyDelete
  4. Excellent tip, I was thinking I was going to re-install the JDK, but this took care of the problem. Thanks for posting!
    ReplyDelete
  5. Thank you, guys!
    I have installed Sonar (http://docs.codehaus.org/display/SONAR/Documentation) and got the same error (Probable fatal error:No fonts found) on CentOS 6.0 without graphical interface.

    After installing follow packages it was been resolved:
    liberation-fonts-common
    liberation-mono-fonts
    liberation-sans-fonts
    liberation-serif-fonts

    Best regards
    Eugene Z.
    ReplyDelete