Specifying fallback fonts with Pango markup for Gtk application - ruby

I am developing a dialog for my application using Ruby Gtk and have a requirement of displaying the text on the dialog in the Open Sans font. I have used Pango markup below to achieve this and seems to work as expected on my system.
<span font_family=\"Open Sans\" foreground=\"black\" size=\"x-small\" weight=\"bold\">#{value}</span>
To make it work though, I also had to manually install the Open Sans font onto my system. Without doing so, I was seeing the following warning in the application log file.
Pango-WARNING **:couldn't load font "Open Sans Bold Not-Rotated 10", falling back to "Sans Bold Not-Rotated 10", expect ugly output.
I know it is possible to specify multiple fonts in case of HTML in descending order of preference as a fallback in case a certain font doesn't exist and such a logic would be acceptable in my case. But I can't seem to find an example on the internet. Is it even possible to specify multiple fonts with Pango markup? If so, how? If not, is there any other way around this warning other than installing the font?

AFAIK there is no way to specify multiple fonts. You can obtain a list of all available fonts (that's how it's done in C) and then iterate over that list, finding the one that fits best.

Related

how do you change the default font used by apache nifi

We're doing a proof of concept test on Apache NiFi. The font for the layout screen looks like it's about 10 pt, which is way too small
I can zoom the screen to 140%, but that makes everything bigger, and a lot less useful
How Do I simply change the font used?
To change the font-size for particular areas of Apache NiFi you can simply update the appropriate css files found in:
nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/css/
Then rebuild and restart the application. Most of the time you can tell by the file names where the styles are applied within the application but you can also use your browsers developer tools to inspect the styles of any particular element in the UI and determine the precise file you will need to edit.

In Firefox, from a WebExtension, can I enumerate fonts, and if so, how?

Use-case, in a Firefox (or soon, other browsers) WebExtension, I want to present the user with a way to customize the font used in parts of the interface. I want to use fonts that the browser is already aware of, be they installed on 1) the system, or 2) in browser "font cache" (if such a thing exists - e.g. when using CSS #font-face, local( 'Font Name' ) looks for a local cached copy of font, or on system or something).
In Firefox -> Options -> Content -> Fonts & Colors, there is a drop-down selection of fonts that Firefox found on my system. How can I get this list (and the meta-info about whether it is a serif, sans or mono or other family) for use in a WebExtension? This seems to be a list of fonts installed on the system.
How might I also get the web-fonts stored in cache somewhere (i.e. web fonts previously downloaded by other pages, the way Google Fonts API does it)?
I'd like to use the meta-info to filter the font list, whitelisting mono or serif fonts that are legible.
Before anyone says, "just include all the font files and serve them up with CSS", I'd just like to say that while technically possible and trivial, it isn't legally possible, as most system fonts are mired in intellectual-property usage-restrictions.
And before someone responds, "well, just use only open fonts then", I'd also like to say that while I may make some open fonts available, most open fonts are ugly, illegible, or otherwise unsuitable. And many copyrighted patented trademarked closed-source system fonts are already on the system and look better and also vary by system. So I'd rather serve up options of fonts to people on specific platforms that they will be familiar and comfortable with. This may even include foreign language fonts, which open fonts are severely lacking at the moment.
And before anyone suggests, "well go make your own multi-lingual open font!!", I'd like to say I already have FontForge, and it's no trivial task to create a font for one language let alone all of them (even if I knew all languages and what constituted an attractive font in each language), though I have hacked a few icon fonts so I technically know how to do it, kind of.

How to change the font in Squib

I want to change the font in Squib.
How do I do this.
There is a font folder and also I can see where I set the font in the layout, do I need to set it anywhere else.
I'm wanting to use FiraSans-Regular.otf and FiraSans-Heavy.otf
At this point in time, Squib doesn't support loading fonts locally. You'll have to install the font on your system, and then do something like text font: 'FiraSans'. I generally keep my font files in my git repo just for portability.
Loading local fonts has been discussed by the Pango team (what Squib uses for text), and they are making the process less painful as I understand it. http://mces.blogspot.com/2015/05/how-to-use-custom-application-fonts.html. It will be a while until that translates to Ruby, as well, since cross-platform compatibility is hard when it comes to fonts.
I've created a GitHub issue to track on this if you want to follow it:
https://github.com/andymeneely/squib/issues/105

WP7 - Not picking up embedded fonts

I have been trying to use some custom fonts within my WP7 app.
I followed the example as per http://www.jeffblankenburg.com/2010/10/24/31-days-of-windows-phone-day-24-embedding-fonts/ but in my project it simply will not pick up the custom font.
I have downloaded the sample project in this example and this one does work okay.
So, I have now used the same font used in there, and included in my project. I have ensured that the properties on the file are identical (Build Action = 'Content' and Copy To Output Directory = "Always")
I have used in my XAML in exactly the same way i.e.
FontFamily="Fonts/DigitalDream.ttf#Digital Dream" FontSize="24"
But to no avail. The custom font is just ignored. Is there something that I am missing, or a setting .. anything that would allow this to work in one project, but not another?
I have discovered that it will work if my XAML page is defined at the root level, i.e. immediately under the project, but in my case I have it in a 'Views' folder.
My understanding was that
FontFamily="/Fonts/DigitalDream.ttf#Digital Dream" FontSize="24"
should start at the root folder of the project?
thanks
Custom fonts can be a little tricky. I spent several hours once trying to embed an .otf font only to find that it just didn't seem to be doable.
You're on the right track, though. A .ttf font should be embedable. It's hard to get the right combination of paths and filenames to make the font work, though.
The easiest way I've found to handle some of these more difficult "magic string" type of situations in XAML is to let Expression Blend do the heavy lifting.
Here's a blog post about using Blend to embed fonts. The nice thing about using Blend is that it gives you some visual indications that things are set up correctly--i.e. you can see the font you want in the font selection menu. This is what finally clued me in on the .otf issue. I couldn't see the font in Blend.
And here's an example of a custom font that I've used in one of my apps:
<TextBlock Name="MyTextblock"
FontFamily="/MyAppName;component/fonts/Fonts.zip#Segoe UI Mono">
That's FontFamily URI is a pain to get right. I'm pretty sure that's your problem.
I was actually having the same problem. I followed everything to the dot and still I wasn't able to embed one particular font. So I created a new project and tried embedding the font there. Still no luck. I then tried embedding some other font. And lo and behold, as soon as I typed the FontFamily attribute, I could see that it had embedded. This was particularly odd since I didn't have to change any properties of the font.
I opened the project in Blend and clicked on the font property box to the right. It took a few seconds and then it embedded the font I was having problems with in the first place.

On iOS, can I access the system-provided font's TTF file

I'm trying out FTGLES to dynamically display text in arbitrary fonts on OpenGL-ES on iOS (cf. my SO question here). That library seems to require direct access to the TTF file to use the font. Using kosher methods, can one directly access -- by path -- the system font files on iOS? I've RTFM'd and couldn't find anything.
Barring that, does anyone know if it is Apple-approved to copy the system fonts into your app (before submission).
My solution was inspired by skia.
Though cannot access system built-in font files directly, we still have an indirect way:
Create a CGFont with your wanted font name, all contents of SFNT table of this CGFont can be accessed by simply calling CGFontCopyTableTags() and CGFontCopyTableForTag().
A ttf/otf font data can then be constructed by using these tables, save the new created font to disk, you can use it in FTGL ES later.
No, you can't access the system installed TTF files on iOS devices. So you'll have to embed the typefaces you'd like to use.
Disclaimer: I'm not a lawyer, and the acceptability of using Apple supplied system fonts in an iOS app is a legal question about interpreting software licenses, so you may want to seek professional advice.
You wish to embed an Apple supplied font in your app. The definition of "embed" is a bit nebulous, so adding the font to an iOS app may or may not fit within the copyright holder's definition of "embed". Some type houses define "embed" to mean just viewing predetermined content in the included font; other mean viewing and editing content in that font. Displaying content that changes during the running of your app is somewhere between these two cases.
According to the Mac OS X Lion 10.7.2 ELUA:
F. Fonts. Subject to the terms and conditions of this License, you may
use the fonts included with the Apple Software to display and print
content while running the Apple Software; however, you may only embed
fonts in content if that is permitted by the embedding restrictions
accompanying the font in question. These embedding restrictions can be
found in the Font Book/Preview/Show Font Info panel.
If using the fonts in an iOS app is indeed "embedding", you just need to check the particular fonts you wish to use in Font Book.
In this situation I would find a font or set of fonts where I had explicit permission to include the fonts in the iOS app. I would start by shopping around the various type houses for a licensing scheme that explicitly allowed this use. This may get expensive, so another tack would be to seek out open source typefaces with a license that would allow this use. Or, for a very limited set of characters (e.g. only numbers) I would even consider drawing my own typeface.
No. Your app cannot access files outside the sandbox of your app. Period (well, unless it's jailbroken ;). But you can indeed bundle the font file. Now, I see no reason why Apple would reject your app, as it's using a file already available on the device, and you're just including your local file to it. In terms of copyright, Apple already has that permission to use it on their device, so your inclusion of it should be no problem.
I say should because I haven't needed this capability and haven't tested it with a submission of my own, but based on legal instinct and font copyright issues I've seen in the past, I'd expect that it wouldn't be a problem.

Resources