How to enable font variant like "Italic Display" - css

I've got a font rendered on webkit (specifically in the text editor "Nano") and I'd like to display an OTF font that has a variant called "Garamond Premier Pro Italic Display". I believe it's a "suitcase" font.
Here's what the font looks like in Font Book:
Things I've tried:
font-variant-alternates: character-variant("ItDisp");
and
font-variant-alternates: character-variant("Garamond Premier Pro Italic Display");
No dice.
Any thoughts here? Or is this just not possible?

Unfortunatly this is not possible on the web at the time of writing.
The only real options available to use are as follows:
italic
normal
oblique
You can read up on the font-style attribute and the different things you can do with it here: https://developer.mozilla.org/en-US/docs/Web/CSS/font-style
There are /MANY/ fonts on desktop platforms that simply will not work on the web, as the web use different file formats. It is recommended to use fonts that are specifically designed for use on the web.
Also a note that font-variant-alternates is only supported in Firefox 34+ and Safari, and as such should not be used in production.

Related

Why is font-family render differently on iOS?

I'm using monospace for dollar sign my website, I get the result I'm looking for on chrome / windows and mobile phone but font render different on iOS? Why is the font display different? Is there a way to fix it?
It would be helpful if you provided the CSS code that you are using but I'm guessing you are doing something like this
font-family: monospace;
The reason this looks different on different operating systems is that "monospace" doesn't actually refer to a particular font it refers to any font where "All glyphs have the same fixed width" so each browser has a different font that it uses for "monospace".
If you would like your font to be consistent across different browsers and operating systems you will need to specify a particular font. This article from MDN explains how to specify font on the web https://developer.mozilla.org/en-US/docs/Learn/CSS/Styling_text/Web_fonts
Chrome font for monospace is consolas , you can check each font using chrome://fonts. Think this might be useful to someone

Can someone explain why using web safe fonts in CSS doesn't seem to work for me?

I know this is an extremely basic and stupid question, but I seem to be having a genuinely curious problem.
When using what are supposed to be web-safe fonts like Didot, and using
header h1{
font-family: Didot, serif;
font-size: 36px;
}
my browser just displays the standard serif font.
In fact I can't seem to get it to display any web safe font, it will only display either the standard serif or sans-serif font. I know my selector is correct because I CAN change between serif and sans-serif, but I know its not displaying other web-safe fonts because I tried both Arial and Helvetica (which are both definitely web safe) and when I refreshed from one to another there was absolutely no difference in the font displayed.
I'm a complete beginner and I'm using the simplest possible beginner environment, just an html page linking to a css file which I'm opening with my browser (the url shows up as file:///C:/Users/Agent%201/Desktop/Web%20Projects/ResumeSite/index.html if that is at all relevant). I've tried opening it with both chrome and edge, same results on both
Is there something wrong with my css? Or are there limitations when just opening a local html file with my browser?
Sorry if I'm this is a really dumb question, but I really can't find an answer as to why my fonts aren't working, I've tried !important and some other weird solution I found which involves changing the selector to "header h1, header h1 *" and that did nothing.
Thank-you for any help you can provide me!
When using what are supposed to be web-safe fonts like Didot, and using...
Didot is not a "web-safe" font.
Didot is included with macOS, which may lead some web-designers to assume that it's also available on other platforms (like Windows, Linux and Android) or that those platforms have automatically-mapped equivalents (like how many browsers will map Helvetica to Arial), however that is not guaranteed.
Also, just because a typeface is included with an OS does not mean it is licensed to you to use commercially or in a website - you can be sued for publishing an OS-licensed font onto the public web without having your own font-license.
A "web-safe" font is a typeface that is broadly installed and supported by most contemporary browsers without the need for additional downloads or font installations.
Many typefaces are broadly installed, such as Microsoft's Core fonts for the web which are preinstalled on all Windows computers - and many other operating systems such as macOS either come with the same fonts or have very similar equivalents (e.g. Helvetica instead of Arial) which are automatically mapped by the browser.
The only way to determine if a font is "web-safe" is by doing your own leg-work and manually checking to see if all-or-most of your target users' devices have that typeface available. You can check font availability on Wikipedia and other sites:
macOS: https://en.wikipedia.org/wiki/List_of_typefaces_included_with_macOS
Windows: https://en.wikipedia.org/wiki/List_of_typefaces_included_with_Microsoft_Windows
iOS: http://iosfonts.com/
Android: Consult Android's fonts.xml for the minimum set of stock fonts and default fallback mappings (e.g. "Helvetica" goes to "sans-serif").
You might notice that Android's font list is very... short. That's because the base Android OS isn't what ships on most peoples' phones: Google's layer on top of Android, and OEMs (like Samsung, etc) will add their own fonts on top, but I don't know where to get that list from at-present, sorry.
A "web-safe font stack" means that at least one of the fonts listed in a font-family property value can be safely assumed to be available for use, not that all of them are - nor that the first-preferred-font will be available.
And any font-family list can be made "safe" by adding a CSS fallback generic-family name to the end (i.e. specifying the least-preferred font). Those names are specified in the CSS Fonts Module and are:
serif
sans-serif
cursive
fantasy
monospace
In your case, the property font: Didot, serif is "web-safe" because it has the serif generic-family name at the end. Your visitors will only see the Didot font being used if they already have it installed on their computer, phone, tablet, etc.
If you do want to use Didot, then you need to publish it as a WOFF file and add it to your stylesheet with a #font-face rule: https://css-tricks.com/snippets/css/using-font-face/

Custom font not displaying languages other than English properly on Windows

My problem is a custom font works fine with the English language on Windows or Linux Chrome browser, but does not display other languages properly on Windows though it seems to work well on Linux.
I am using a custom font, "Source Sans Pro".
body {
font-family: 'Source Sans Pro', sans-serif;
}
Here are examples of rendering.
Linux rendering English
Linux rendering other languages ex:Tamil
Windows rendering English
Windows rendering other languages ex:Tamil
Let me know why it is happening and how to solve it.
Thanks in advance.
When debugging custom fonts, I open developer tools and do a few checks:
Check network tab, did the font file load?
Check elements, is the fallback applied instead of my custom font? In your example, using a fallback with serifs would make it much more obvious if the fallback was being applied.
If the font is being loaded and applied, is it capable of the styles I'm asking? Refined bold or light styles, Cyrillic or other languages require additional files. For example, try selecting Roboto and visit the Customize tab in the bottom drawer.
There are multiple ways to load a custom font. Seeing as Source Sans Pro is available on Google Font, here's a link to their documentation for getting started.

Garbled text when printing website

I'm working on a website where the users will be printing pages from the site fairly frequently, in order to give them to people without internet access. Some of the text comes out garbled when printed on our users' office printers:
That's supposed to say Reduced Fare and Free Ride Programs, Chicago Transit Authority.
My first thought was that this has something to do with the font we're using, so I changed that text to have font-family: 'Times New Roman', serif. Some google research made me think those font settings were widely supported and shouldn't cause problems, but our users are still having the issue.
Even if you don't know exactly how to fix this problem, I would appreciate suggestions about
What other than the font selection could be causing it?
If you do think it has something to do with the font, what is a good font to use? Or how could I figure that out, is it printer-specific?
Update
The page is being printed from the browser, which for this particular group of users is IE8. I'm not sure what version of Windows they're on. I've tested this on a Windows machine with IE8 in our office, and was not able to reproduce the issue. So while the browser might be a factor, I don't believe it's the only factor.
Second Update
The font we're using is Libre Baskerville, which we're loading through the Google Fonts API. It renders fine on screen, and actually prints with no issue from some of the printers at our client's office. The text only comes out garbled when printed on a Lexmark MS410dn.
I saw these same types of printing errors. I created a PDF in Indesign on Windows 10 using the Libre Baskerville font. When I tried to print the PDF on OSX using Preview I got the same garbled glyphs seen above. I fixed it by uninstalling the Libre Baskerville fonts which were Truetype format and installing Libre Baskerville fonts in Opentype format and resetting the fonts in the document. It seemed to work.
In the end the simplest solution was to use a different font for printing. The issue only happened with the Libre Baskerville font on a few specific printers, so in our print.css stylesheet we just use a basic serif font instead. Not ideal, but at least the printouts are legible.
In the original post I said that I had tried switching the font in the printouts and users were still having problems. This turned out to be due to caching of the print.css stylesheet, so that fix actually did solve the problem.
In the long term we'll probably find a font that works consistently on all their printers and switch the website over to that as well.
For the record (and anyone reading this with a similar issue), I had exactly the same issue trying to print a document written in Libre Baskerville on my laptop, in LibreOffice. The font is embedded in both RTF and PDF formats and the text is garbled in the same way. I also worked around the issue by changing to a different font. It's a pity as LibreBaskerville is a nice font.
Try replacing the True Type version of the font with the Open Type version - I am now able to print Libre Baskerville with no issues. The Open Type version is not easy to find as most downloads (including Google Fonts) only give you the option of a .ttf file. Search for a .otf file version - I found one here: https://www.broble.com/download-free-font/libre-baskerville
It might be that the imported font files have some errors in them. Sometimes, if you use a online font to webfont converter it makes some mistakes with the conversion. You could try Google Fonts. Find a serif font that you like and use their files and import scripts.
For example, if you want to use the font Bitter:
Just put #import url(http://fonts.googleapis.com/css?family=Bitter); at the top of your CSS file
Use font-family: 'Bitter', serif; in your style declarations.
NB: The serif part is a fallback in case something goes wrong, then the clients browser chooses the default serif font instead.

Edgy fonts using font face

I am trying to use the CSS font face property. I've made it chance the font to the right one, however it looks very edgy on the Windows platform. Especially Chrome looks awful.
When using OSX all browsers are just perfect.
How can I avoid these awful looking fonts?
On OSX Chrome:
On Windows Chrome:
The Segoe font is already installed on most Windows PC's. This can cause problems when you are also trying to link it with CSS. Try renaming the font in your CSS so that it has a different name than the built-in Windows font.
Also, Chrome just doesn't render TTF/WOFF fonts very well. You can get around that by prioritizing the SVG font (by putting it higher up in the font list). This will make Chrome select the SVG font (but most other browsers will still use the WOFF font). See here for more information.

Resources