Giter Site home page Giter Site logo

Comments (3)

rubyFeedback avatar rubyFeedback commented on July 1, 2024

Hmm. I am also trying other fonts:

"The font URW Palladio is not available on your device."

Or:

"The font VeraMono is not available on your device."

The font is here though:

/usr/share/fonts/ttf/VeraMono.ttf

So perhaps font handling may not be optimal if such a font
can not be found? /usr/share/fonts/ttf/ is quite common on
linux. I also ran "fc-cache -f -v" prior to trying to compile
the .java file, but it seems it can not find such fonts. Omitting
the name works, so it must work internally.

from codedraw.

Krassnig avatar Krassnig commented on July 1, 2024

Hi,

you are correct, as of version 3.0.0 there is no way to check whether a font is available on a system except for catching an exception.

Starting from version 4.0.0 the setFontName() method will be changed to accept several fonts:

CodeDraw cd = new CodeDraw();
TextFormat tf = cd.getTextFormat();
tf.setFontName("Arial", "Verdana", "JetBrains Mono");

The first font in the list which is available on executing system will be used to draw text. If none of these are available, Javas default font Font.DIALOG will be used. CodeDraws default font will be Font.DIALOG, see Physical and Logical Fonts.

Additionally, the method TextFormat.getAllAvailableFontNames() and TextFormat.isFontNameAvailable(String fontName) will be added and a method to set the font name to its default value textFormat.setFontNameToDefault().

Previously, CodeDraw set the font name to 'Arial' internally, but there was no check to see if it was actually available (the check still happened when the setFontName(String) was called from the outside). I would assume that the Tests we did on Linux just defaulted to some other font and that was why we didn't notice.

Font not found issue:

I tried checking if there is a mismatch between the fonts listed with the linux command fc-list and on first glance they seem to match with the fonts in CodeDraw/Java. I also tried installing JetBrains Mono which also worked. CodeDraw uses the GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames() method to get all available font names. This is also what is recommended in Physical and Logical Fonts.

What seems to be the issue is that the method GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames() doesn't return the font you added to your system. Maybe you could ellaborate on how you added the font to your system, what linux distribution you used and what the list of fonts returned from GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames() is. Maybe there is another method in Java which does return your font.

Thank you for your feedback 👌

from codedraw.

Krassnig avatar Krassnig commented on July 1, 2024

Implemented in version 4.0.0

from codedraw.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.