How to add a new font set ?

Hello.
Everything is in the question !
Yours
Al

Do you mean you would like to import a custom font and use it with the font() function? This is not possible.

To use a custom font, you could import images containing all the letters, numbers, and symbols of that font and write your own function to draw those to match a string.

Way, way back - before Codea had native fonts - a few of us implemented our own font methods. If you really want to do that then it is possible and there is code available to do it.

Two are on the wiki and a third is on my Codea page.

to Andrew_Stacey.
Thank you for your answer.
I will read these links
Yours

to JakAttak. Thank you for your answer.
After reading the proposed links, you seem to be right… No easy way.

slightly off topic: does anyone know how to get the list of available fonts? As a text file, i mean?

@Jmv38

I don’t remember how I got this list, and it may be out of date if they’ve added a few since I made my font picker, but here’s what I have.

FontPicker.Fonts = {
        {"Academy Engraved", "AcademyEngravedLetPlain"},
        {"American Typewriter","AmericanTypewriter",
            {
            {"Light", "AmericanTypewriter-Light"},
            {"Regular", "AmericanTypewriter"},
            {"Bold", "AmericanTypewriter-Bold"},
            {"Condensed Light", "AmericanTypewriter-CondensedLight"},
            {"Condensed", "AmericanTypewriter-Condensed"},
            {"Condensed Bold", "AmericanTypewriter-CondensedBold"},
            }
        },
        {"Arial","ArialMT",
            {
            {"Regular","ArialMT"},
            {"Italic","Arial-ItalicMT"},
            {"Bold","Arial-BoldMT"},
            {"Bold Italic","Arial-BoldItalicMT"},
            }
        },
        {"Baskerville","Baskerville",
            {
            {"Regular","Baskerville"},
            {"Italic","Baskerville-Italic"},
            {"SemiBold","Baskerville-SemiBold"},
            {"SemiBold Italic","Baskerville-SemiBoldItalic"},
            {"Bold","Baskerville-Bold"},
            {"Bold Italic","Baskerville-BoldItalic"},
            }
        },
        {"Bodoni IT","BodoniSvtyTwoITCTT-Book",
            {
            {"Regular","BodoniSvtyTwoITCTT-Book"},
            {"Italic","BodoniSvtyTwoITCTT-BookIta"},
            {"Bold","BodoniSvtyTwoITCTT-Bold"},
            {"Small Caps","BodoniSvtyTwoSCITCTT-Book"},
            }
        },
        {"Bodoni OSIT","BodoniSvtyTwoOSITCTT-Book",
            {
            {"Regular","BodoniSvtyTwoOSITCTT-Book"},
            {"Italic","BodoniSvtyTwoOSITCTT-BookIta"},
            {"Bold","BodoniSvtyTwoOSITCTT-Bold"},
            }
        },
        --{"Bodoni Ornaments","BodoniOrnamentsITCTT"},
        {"Bradley Hand","BradleyHandITCTT-Bold"},
        {"Chalkboard","ChalkboardSE-Light",
            {
            {"Regular","ChalkboardSE-Regular"},
            {"Bold","ChalkboardSE-Bold"},
            }
        },
        {"Chalkduster","Chalkduster"},
        {"Copperplate","Copperplate",
            {
            {"Light","Copperplate-Light"},
            {"Regular","Copperplate"},
            {"Bold","Copperplate-Bold"},
            }
        },
        {"Courier","Courier",
            {
            {"Regular","Courier"},
            {"Oblique","Courier-Oblique"},
            {"Bold","Courier-Bold"},
            {"Bold Oblique","Courier-BoldOblique"},
            }
        },
        {"Courier New","CourierNewPSMT",
            {
            {"Regular","CourierNewPSMT"},
            {"Bold","CourierNewPS-BoldMT"},
            {"Bold Italic","CourierNewPS-BoldItalicMT"},
            {"Italic","CourierNewPS-ItalicMT"},
            }
        },
        -- {"DBLCDTempBlack","DBLCDTempBlack"},
        {"Didot","Didot",
            {
            {"Regular","Didot"},
            {"Italic","Didot-Italic"},
            {"Bold","Didot-Bold"},
            }
        },
        {"Futura","Futura-Medium",
            {
            {"Medium","Futura-Medium"},
            {"Medium Italic","Futura-MediumItalic"},
            {"Condensed Medium","Futura-CondensedMedium"},
            {"Condensed Extra Bold","Futura-CondensedExtraBold"},
            }
        },
        {"Georgia","Georgia",
            {
            {"Regular","Georgia"},
            {"Italic","Georgia-Italic"},
            {"Bold","Georgia-Bold"},
            {"Bold Italic","Georgia-BoldItalic"},
            }
        },
        {"Gill Sans", "GillSans",
            {
            {"Light","GillSans-Light"},
            {"Light Italic","GillSans-LightItalic"},
            {"Regular","GillSans"},
            {"Italic","GillSans-Italic"},
            {"Bold","GillSans-Bold"},
            {"Bold Italic","GillSans-BoldItalic"},
            }
        },
        {"Helvetica","Helvetica",
            {
            {"Light","Helvetica-Light"},
            {"Light Oblique", "Helvetica-LightOblique"},
            {"Regular","Helvetica"},
            {"Oblique","Helvetica-Oblique"},
            {"Bold","Helvetica-Bold"},
            {"Bold Oblique","Helvetica-BoldOblique"},
            }
        },
        {"Helvetica Neue","HelveticaNeue",
            {
            {"Ultra Light","HelveticaNeue-UltraLight"},
            {"Ultra Light Italic", "HelveticaNeue-UltraLightItalic"},
            {"Light","HelveticaNeue-Light"},
            {"Light Italic","HelveticaNeue-LightItalic"},
            {"Regular","HelveticaNeue"},
            {"Italic","HelveticaNeue-Italic"},
            {"Medium","HelveticaNeue-Medium"},
            {"Bold","HelveticaNeue-Bold"},
            {"Bold Italic","HelveticaNeue-BoldItalic"},
            {"Condensed Bold","HelveticaNeue-CondensedBold"},
            {"Condensed Black","HelveticaNeue-CondensedBlack"},
            }
        },
        {"Hoefler","HoeflerText-Regular",
            {
            {"Regular","HoeflerText-Regular"},
            {"Italic","HoeflerText-Italic"},
            {"Bold","HoeflerText-Black"},
            {"Bold Italic","HoeflerText-BlackItalic"},
            }
        },
        {"Inconsolata","Inconsolata"},
        {"Marion","Marion-Regular",
            {
            {"Regular","Marion-Regular"},
            {"Italic","Marion-Italic"},
            {"Bold","Marion-Bold"},
            }
        },
        {"MarkerFelt","MarkerFelt-Thin",
            {
            {"Thin","MarkerFelt-Thin"},
            {"Wide","MarkerFelt-Wide"},
            }
        },
        {"Noteworthy","Noteworthy-Light",
            {
            {"Light","Noteworthy-Light"},
            {"Bold","Noteworthy-Bold"},
            }
        },
        {"Optima","Optima-Regular",
            {
            {"Italic","Optima-Italic"},
            {"Regular","Optima-Regular"},
            {"Bold","Optima-Bold"},
            {"Bold Italic","Optima-BoldItalic"},
            {"Extra Bold","Optima-ExtraBlack"},
            }
        },
        {"Palatino","Palatino-Roman",
            {
            {"Regular","Palatino-Roman"},
            {"Italic","Palatino-Italic"},
            {"Bold","Palatino-Bold"},
            {"Condensed","Palatino-BoldItalic"},
            }
        },
        {"Papyrus","Papyrus",
            {
            {"Regular","Papyrus"},
            {"Condensed","Papyrus-Condensed"},
            }
        },
        {"PartyLetPlain","PartyLetPlain"},
        {"Snell Roundhand","SnellRoundhand",
            {
            {"Regular","SnellRoundhand"},
            {"Bold","SnellRoundhand-Bold"},
            {"Black","SnellRoundhand-Black"},
            }
        },
        {"Times New Roman","TimesNewRomanPSMT",
            {
            {"Regular","TimesNewRomanPSMT"},
            {"Italic","TimesNewRomanPS-ItalicMT"},
            {"Bold","TimesNewRomanPS-BoldMT"},
            {"Bold Italic","TimesNewRomanPS-BoldItalicMT"},
            }
        },
        {"Trebuchet","TrebuchetMS",
            {
            {"Regular","TrebuchetMS"},
            {"Italic","TrebuchetMS-Italic"},
            {"Bold","TrebuchetMS-Bold"},
            {"Bold Italic","Trebuchet-BoldItalic"},
            }
        },
        {"Verdana","Verdana",
            {
            {"Regular","Verdana"},
            {"Italic","Verdana-Italic"},
            {"Bold","Verdana-Bold"},
            {"Bold Italic","Verdana-BoldItalic"},
            }
        },
     -- "ZapfDingbatsITC", -- Interesting chars not in range 0-255
        --]]
        --{"Zapfino","Zapfino"}
        --]]
    }

thank you very much @Andrew_Stacey

Perhaps the AnyFont app might help? It allows installation of fonts that can then be used in other apps.

http://appshopper.com/utilities/anyfont

Haven’t tried it myself, so cannot verify if Codea will see them.

@time_trial I haven’t tried it either, but I expect they would be picked up by Codea.

@Simeon, hmmmm - I guess the ‘new font’ wouldn’t be picked up if you exported the project to Xcode to run as a standalone app on another device? :-/

Apologies for bumping 18 month-old thread, I wanted to ask whether anyone had managed to get a custom font working in an Xcode Codea project?

Several iOS apps can install custom fonts onto the iPad (as device profiles), I use one called FondFont, and these can be accessed with Codea’s font command.

I’ve then tried dragging the font onto the Xcode Resources bundle (which also contains the fonts Inconsolata and SourceSansPro, so seems the logical place to put a font), and in the resulting add file dialogue, added my project as a build target. When I build for the simulator, I’ve confirmed that the font file is present in the app bundle alongside the other two fonts. But when the app runs, either in the simulator or on a device, the font doesn’t display.

Anyone had any luck with this, or know whether it’s possible?

On the subject of fonts and Xcode, Codea adds some extra fonts to the system ones (Inconsolata, Source Sans Pro, Vegur, perhaps some others I haven’t spotted). Vegur however is not part of the exported runtime, so won’t be available in Xcode projects (the other two are available).

One other thing. If you set font to a non-existent font eg (in Xcode) font("Vegur"), text will still display using the default font (Helvetica I think?), BUT one gotcha to be aware of is that textSize will return 0,0. I don’t think this is very helpful behaviour, I think that if the font is not available (and text is displaying with the default font), then textSize should also report values using the default font.

I spent about an hour trying to work out why images weren’t displaying in my Xcode project (it was because the width and height of the image were being set by textSize, and I was trying to use “Vegur”, therefore w and h = 0).

@yojimbo2000 You need to do this:

1 - You need to have the .tff or .otf on your mac;

2 - Open Fonts, find the font, right button and ‘show on finder’;

3 - Open Xcode, click on + button, select add files to "nameOfYourProject";

4 - Add your font;

5 - Go to info tab on your project;

6 - On Fonts provided by application, click on + and put the font name.

Thats it!

If you dont´t understand, please PM me!

@erickyamato

Thanks for these steps, I’ll try these out this evening!

@erickyamato

It works, excellent! It was the last two steps that I was missing, I’m still fairly new to Xcode.

@yojimbo2000 no problems!

This forum was created to help people!

I know more Xcode than Codea, but, I’m learning about it!

@TimuEke there is no need to jailbreak to do this. Apps such as FondFont install fonts on the iPad, and Codea can access these with the font command.