Unicode and fonts - unicode

This is something that I don't see much discussed. I'm developing a software that will support multilingualism, thus, I would need to use Unicode compatible fonts, right? Where could I possibly find such fonts and how would I know for sure they support Chinese, Korean, Japanese, whatever there exist?
It's a shame you can't use beautiful fonts found in the Internet, because most of them support ASCII only.

Just to make sure: do not expect to find a font that supports Chinese Traditional, Chinese Simplified, and Japanese.
There are glyph differences for the same Unicode code points, so a native user will immediately spot that you are not using the proper font for their language.
For a web application it is probably best to give a list of fonts, and in the list you need a typical Windows font, a typical Mac font, and a generic one (like "serif").
Tagging the html page (or the paragraph) with the proper lang tag will help some (smarter) browsers to select the right font if the specific ones are not installed.

From my unicode/font bookmark collection
http://en.wikipedia.org/wiki/Category:Free_software_Unicode_typefaces
http://en.wikipedia.org/wiki/Unicode_typefaces
http://unifoundry.com/unifont.html
http://www.fileformat.info/info/unicode/font/index.htm
http://www.alanwood.net/unicode/fontsbyrange.html
http://www.alanwood.net/unicode/fonts.html
http://www.unifont.org/fontguide/
http://www.wazu.jp/index.html

http://www.alanwood.net/unicode/fonts.html
Alan Wood's site has alot of Unicode fonts. By each font there is a list explaining which languages is supported by it.
Another great site is the fontguide at Unifont. To find it just google for it, don't have the reputation to link it yet. When there, just click the continent-tabs at top of the site to view fonts including languages from those countries.

You can create your own custom webfonts with tools like the Icomoon App.
The Icomoon App allows you to do each of the following :
Get one or more icons from several popular icon fonts
Upload other fonts, which may be icon fonts but also regular fonts
Upload SVG files to use as glyphs
Combine any number of glyphs from any number of available fonts
Set the UNICODE hex value for whichever characters you need
Export and/or save the font set you create
I used the Icomoon App to create the Emoji emoticon font as well as for creating custom icon fonts on a per project basis.
To include an icon font in your CSS, you can include the following code :
#font-face {
font-family: 'myfont';
src:url('fonts/myfont.eot?-td2xif');
src:url('fonts/myfont.eot?#iefix-td2xif') format('embedded-opentype'),
url('fonts/myfont.woff?-td2xif') format('woff'),
url('fonts/myfont.ttf?-td2xif') format('truetype'),
url('fonts/myfont.svg?-td2xif#myfont') format('svg');
// Different URLs are required for optimal browser support
// Make sure to :
// 1) replace the URLs with your font's URLs
// 2) replace `#myfont` with the name of your font
font-weight: normal; // To avoid the font inherits boldness
font-style: normal; // To avoid font inherits obliqueness or italic
}
.icon {
font-family: 'myfont', Verdana, Arial, sans-serif; // Use regular fonts as fallback
speak: none; // To avoid screen readers trying to read the content
font-style: normal; // To avoid font inherits obliqueness or italic
font-weight: normal; // To avoid the font inherits boldness
font-variant: normal; // To avoid the font inherits small-caps
text-transform: none; // To avoid the font inherits capitalization/uppercase/lowercase
line-height: 1; // To avoid the font inherits an undesired line-height
-webkit-font-smoothing: antialiased; // For improved readability on Webkit
-moz-osx-font-smoothing: grayscale; // For improved readability on OSX + Mozilla
}
To use an icon in your HTML, you can do each of the following :
<!-- Method 1 -->
<!--- * * * * * * * * * * * * -->
<!-- Set a font-family for an entire HTML element -->
<!-- Define your icon fonts in your CSS font-family after your regular fonts -->
<!-- This means that regular characters are default. Icons are a fallback -->
<!-- Use UTF-8 characters directly in your HTML for improved human readability -->
<div class="rate"><p>I rate this movie ★★★★☆!!</p></div>
<!-- Method 2 -->
<!--- * * * * * * * * * * * * -->
<!-- Set a font-family for an entire HTML element -->
<!-- Define your icon fonts in your CSS font-family after your regular fonts -->
<!-- This means that regular characters are default. Icons are a fallback -->
<!-- Use entity codes in your HTML when UTF-8 support is uncertain -->
<div class="rate"><p>I rate this movie ★★★★☆!!</p></div>
<!-- Method 3 -->
<!--- * * * * * * * * * * * * -->
<!-- Set a font-family only for the icons but not the HTML elements that include them -->
<!-- Define your icon fonts in your CSS font-family before your regular fonts -->
<!-- This means that icons are default. Regular characters are a fallback -->
<!-- Use UTF-8 characters directly in your HTML for improved human readability -->
<p>I rate this movie <span class="icon">★★★★☆</span>!!</p>
<!-- Method 4 -->
<!--- * * * * * * * * * * * * -->
<!-- Set a font-family only for the icons but not the HTML elements that include them -->
<!-- Define your icon fonts in your CSS font-family before your regular fonts -->
<!-- This means that icons are default. Regular characters are a fallback -->
<!-- Use entity codes in your HTML when UTF-8 support is uncertain -->
<p>I rate this movie <span class="icon">★★★★☆</span>!!</p>
<!-- Method 5 -->
<!--- * * * * * * * * * * * * -->
<!-- Set a font-family only for the icons and use a separate HTML tag for each icon -->
<!-- Define your icon fonts in your CSS font-family before your regular fonts -->
<!-- This means that icons are default. Regular characters are a fallback -->
<!-- Use UTF-8 characters directly in your HTML for improved human readability -->
<p>I rate this movie
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">☆</span>
!!
</p>
<!-- Method 6 -->
<!--- * * * * * * * * * * * * -->
<!-- Set a font-family only for the icons and use a separate HTML tag for each icon -->
<!-- Define your icon fonts in your CSS font-family before your regular fonts -->
<!-- This means that icons are default. Regular characters are a fallback -->
<!-- Use entity codes in your HTML when UTF-8 support is uncertain -->
<p>I rate this movie
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">☆</span>
!!
</p>
<!-- Method 7-->
<!--- * * * * * * * * * * * * -->
<!-- Set a font-family only for the icons and use a separate HTML tag for each icon -->
<!-- Define your icon fonts in your CSS font-family before your regular fonts -->
<!-- This means that icons are default. Regular characters are a fallback -->
<!-- Use the 'content' style rule with a ':before selector' in your CSS -->
<p>I rate this movie
<span class="icon icon-star"></span>
<span class="icon icon-star"></span>
<span class="icon icon-star"></span>
<span class="icon icon-star"></span>
<span class="icon icon-star-unfilled"></span>
!!
</p>
If you want to opt for method 7, you'll need some additional CSS code. This CSS code would look like this :
.icon-star:before {
content: "\2605";
}
.icon-star-unfilled:before {
content: "\2606";
}
Icon fonts like Iconic, Font Awesome or Glyphicons typically all use method 7. This, to avoid you having to copy-paste special characters from a cheat sheet or being forced to use HTML entities.
It is, however, a method that has several downsides. First of all, it requires support for the :before CSS selector and the use of an escape sequence for UNICODE characters. Neither IE6-7 nor certain versions of Webkit provide this support.
Another downside is that you have to use a seperate HTML tag for each icon, with each tag corresponding to one character from the icon font. Displaying several icons within HTML tag is not possible with method 7, unlike with other methods.
Other methods have their own downsides, though. Methods 1, 3 and 5 require you to copy-paste the character from a cheat sheet or use means to put the character itself within your code. Your code editor may not be capable of displaying the character or it may display a different character from the one in your icon font if the icon font uses a non-standard mapping that character.
Methods 1, 3 and 5 also require that your browser uses the proper encoding to display the correct character. For UNICODE characters, this isn't as obvious as it is for ASCII characters. This should, however, be ensured by adding the meta-tag <meta charset="utf-8" /> somewhere in the head of your HTML-document.
Methods 2, 4 and 6 do not require you to copy-paste the character, however it makes your code less readable by humans and makes any changes to the code more prone to human error. Also, as you will need to look up the HTML-entity code for each of the icons you want to use or you'll need to memorize them. While the same obviously applies to the classes used in method 7 as well, those classes are much easier to memorize than an HTML entity code.

Related

Change font color in Scribble (html backend)

Is there any way to change the font color in scribble with an HTML backend?
(More specifically, I want to put a large red WARNING label in the manual for a library.)
It turns out you can do this directly in scribble without using a backend dependent solution. The trick is to use styles that have color-property.
Using elem to set the style, as shown here, you can create a colorize function, that sets the color of your text.
(define (colorize #:color c . content)
(elem #:style (style #f (list (color-property c)))
content))
And then you could use it like this:
#colorize[#:color "red"]{WARNING}
There is also background-color-property you can sue to set the background of the text.
As Alexis mentioned, you can use a class paired with a Cascading Style Sheet (CSS) like so:
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
<!-- that's to link our styles to the webpage. -->
</head>
<body>
<!-- some time later... -->
<p class = "example">test</p>
<!-- the rest of the website -->
And in mystyle.css:
.example{ /* select all tags with the "example" class */
color: #FF0000; /* change font color using hex value */
background-color: #552222; /* change background color using hex value */
}
Now, this would be great if we were able to use multiple files. But, if you want to have it all in one file, we can send that same information in a <style> tag:
<head>
<!-- no need to link our styles, since they're embedded in the webpage. -->
</head>
<body>
<style>
.example{ /* select all tags with the "example" class */
color: #FF0000; /* change font color using hex value */
background-color: #552222; /* change background color using hex value */
}
</style>
<!-- some time later... -->
<p class = "example">test</p>
<!-- the rest of the website -->
There's another way to embed it, but you shouldn't use it. Ever. This is always the correct way.
See http://www.w3schools.com/css/css_examples.asp if you need anything more from the CSS side of things.
Manually creating a style struct containing an attributes property appears to work:
#lang scribble/base
#(require scribble/core
scribble/html-properties)
#para[#:style (style #f `(,(attributes '([style . "color:blue;"]))))]{blue text}

Outlook 2007 / 2013 not rendering CSS font-family declarations

I'm testing an email design with Litmus and for the life of me I cannot get my fonts to be properly set in Outlook 2007 / 2010 / 2013. Every single HTML / CSS trick / hack continues to render in Times New Roman:
`
I'm mostly using simple tables for layout, so all content is ultimately inside a TD element.
Here are the various techniques I've tried to set the font.
My STYLE declaration: Have tried this in both the HEAD and BODY tags & neither works.
<style>
#font-face {
font-family: proxima-nova;
src: url('assets/ProximaNova-Reg.otf');
}
#font-face {
font-family: proxima-nova-blk;
src: url('http://assets/ProximaNova-Black.otf');
}
body *, td, p, li {
font-family: font-family:proxima-nova,'Proxima Nova Regular','Proxima Nova',verdana,sans-serif;
}
</style>
CSS STYLE attribute set on TD elements:
<td style="font-family:proxima-nova,'Proxima Nova Regular','Proxima Nova',verdana,sans-serif; color:#FFFFFF; font-weight:300;font-size:18px;">
FONT tag with both FACE and STYLE attributes set:
<font face="proxima-nova,Proxima Nova Regular,Proxima Nova,verdana,sans-serif"
style="font-size:28px;
font-family:proxima-nova,'Proxima Nova Regular','Proxima Nova',verdana,sans-serif;">
Inline CSS STYLE attributes on all inner text elements (P, LI, A):
I am COMPLETELY baffled. On all other relevant clients everything is working as well as can be expected (i.e. fonts are rendering as I'd expect given various bugs & rendering weirdnesses), including iOS, Gmail, Outlook 2003 / Express, etc.:
I traced the issue to my STYLE declaration, which uses the #font-face to pull in a custom font file for supporting clients (i.e. Apple). Apparently, something about this use of the #font-face declaration breaks in Outlook 2007 - 20013.
<style>
#font-face {
font-family: proxima-nova;
src: url('http://assets/ProximaNova-Reg.otf');
}
#font-face {
font-family: proxima-nova-blk;
src: url('http://assets/ProximaNova-Black.otf');
}
</style>
I needed to get MS Outlook to ignore this STYLE tag, so I wrapped the entire block with the [if !mso] tag:
<!--[if !mso]><!-->
<style>
#font-face {
...
}
</style>
<!--<![endif]-->
Wow, that was driving me crazy.
I've tried your solution with the [if !mso] tag, but for some reason it wouldn't work. I eventually found a different solution:
You can use the font-tag with the face-attribute to force the right fallback-font in clients like Outlook 2007/2010/2013. For example:
<td style="color:#FFFFFF; font-weight:300;font-size:18px;">
<font face="proxima-nova,'Proxima Nova Regular','Proxima Nova',verdana,sans-serif"
</td>
I tested this in Litmus and in Outlook 2007/2010/2013 it would fallback to Verdana and in clients who do support the custom font, it would show proxima-nova.
I hope this helps.

Support for Unicode By browser

I am using the CSS Buttons With Icons But No Images.The icons are generated using unicode values. In this I faced a problem that some browsers doesn't support some unicode values. So instead of proper icon it shows some unwanted symbol.
To provide support for Unicode in any browser what steps do we have to follow?
This is primarily a font problem, but if the fonts listed in your CSS do not cover some character, then different browsers will use fallback fonts differently. The cure is to try and find a list of fonts that probably covers all the characters you use. The difficulty of doing this greatly depends on the characters you use. Using recently introduced characters in buttons is mostly pointless, because images work more reliably. Using characters in text proper is a different issue. See my Guide to using special characters in HTML for details.
All browsers that support Unicode at all support all character codes, but not all fonts have character glyphs for all Unicode characters.
So, to get support for the characters that you want, you would need to provide download of a font that has those characters, in formats used by all different operating systems.
You can create your own fonts with tools like the Icomoon App.
The Icomoon App allows you to do each of the following :
Get one or more icons from several popular icon fonts
Upload other fonts, which may be icon fonts but also regular fonts
Combine any number of icons from any number of available fonts
Set the UNICODE hex value for whichever characters you need
Export and/or save the font set you create
I used the Icomoon App to create the Emoji emoticon font as well as for creating custom icon fonts on a per project basis.
To include an icon font in your CSS, you can include the following code :
#font-face {
font-family: 'myfont';
src:url('fonts/myfont.eot?-td2xif');
src:url('fonts/myfont.eot?#iefix-td2xif') format('embedded-opentype'),
url('fonts/myfont.woff?-td2xif') format('woff'),
url('fonts/myfont.ttf?-td2xif') format('truetype'),
url('fonts/myfont.svg?-td2xif#myfont') format('svg');
// Different URLs are required for optimal browser support
// Make sure to :
// 1) replace the URLs with your font's URLs
// 2) replace `#myfont` with the name of your font
font-weight: normal; // To avoid the font inherits boldness
font-style: normal; // To avoid font inherits obliqueness or italic
}
.icon {
font-family: 'myfont', Verdana, Arial, sans-serif; // Use regular fonts as fallback
speak: none; // To avoid screen readers trying to read the content
font-style: normal; // To avoid font inherits obliqueness or italic
font-weight: normal; // To avoid the font inherits boldness
font-variant: normal; // To avoid the font inherits small-caps
text-transform: none; // To avoid the font inherits capitalization/uppercase/lowercase
line-height: 1; // To avoid the font inherits an undesired line-height
-webkit-font-smoothing: antialiased; // For improved readability on Webkit
-moz-osx-font-smoothing: grayscale; // For improved readability on OSX + Mozilla
}
To use an icon in your HTML, you can do each of the following :
<!-- Method 1 -->
<!--- * * * * * * * * * * * * -->
<!-- Set a font-family for an entire HTML element -->
<!-- Define your icon fonts in your CSS font-family after your regular fonts -->
<!-- This means that regular characters are default. Icons are a fallback -->
<!-- Use UTF-8 characters directly in your HTML for improved human readability -->
<div class="rate"><p>I rate this movie ★★★★☆!!</p></div>
<!-- Method 2 -->
<!--- * * * * * * * * * * * * -->
<!-- Set a font-family for an entire HTML element -->
<!-- Define your icon fonts in your CSS font-family after your regular fonts -->
<!-- This means that regular characters are default. Icons are a fallback -->
<!-- Use entity codes in your HTML when UTF-8 support is uncertain -->
<div class="rate"><p>I rate this movie ★★★★☆!!</p></div>
<!-- Method 3 -->
<!--- * * * * * * * * * * * * -->
<!-- Set a font-family only for the icons but not the HTML elements that include them -->
<!-- Define your icon fonts in your CSS font-family before your regular fonts -->
<!-- This means that icons are default. Regular characters are a fallback -->
<!-- Use UTF-8 characters directly in your HTML for improved human readability -->
<p>I rate this movie <span class="icon">★★★★☆</span>!!</p>
<!-- Method 4 -->
<!--- * * * * * * * * * * * * -->
<!-- Set a font-family only for the icons but not the HTML elements that include them -->
<!-- Define your icon fonts in your CSS font-family before your regular fonts -->
<!-- This means that icons are default. Regular characters are a fallback -->
<!-- Use entity codes in your HTML when UTF-8 support is uncertain -->
<p>I rate this movie <span class="icon">★★★★☆</span>!!</p>
<!-- Method 5 -->
<!--- * * * * * * * * * * * * -->
<!-- Set a font-family only for the icons and use a separate HTML tag for each icon -->
<!-- Define your icon fonts in your CSS font-family before your regular fonts -->
<!-- This means that icons are default. Regular characters are a fallback -->
<!-- Use UTF-8 characters directly in your HTML for improved human readability -->
<p>I rate this movie
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">☆</span>
!!
</p>
<!-- Method 6 -->
<!--- * * * * * * * * * * * * -->
<!-- Set a font-family only for the icons and use a separate HTML tag for each icon -->
<!-- Define your icon fonts in your CSS font-family before your regular fonts -->
<!-- This means that icons are default. Regular characters are a fallback -->
<!-- Use entity codes in your HTML when UTF-8 support is uncertain -->
<p>I rate this movie
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">★</span>
<span class="icon">☆</span>
!!
</p>
<!-- Method 7-->
<!--- * * * * * * * * * * * * -->
<!-- Set a font-family only for the icons and use a separate HTML tag for each icon -->
<!-- Define your icon fonts in your CSS font-family before your regular fonts -->
<!-- This means that icons are default. Regular characters are a fallback -->
<!-- Use the 'content' style rule with a ':before selector' in your CSS -->
<p>I rate this movie
<span class="icon icon-star"></span>
<span class="icon icon-star"></span>
<span class="icon icon-star"></span>
<span class="icon icon-star"></span>
<span class="icon icon-star-unfilled"></span>
!!
</p>
If you want to opt for method 7, you'll need some additional CSS code. This CSS code would look like this :
.icon-star:before {
content: "\2605";
}
.icon-star-unfilled:before {
content: "\2606";
}
Icon fonts like Iconic, Font Awesome or Glyphicons typically all use method 7. This, to avoid you having to copy-paste special characters from a cheat sheet or being forced to use HTML entities.
It is, however, a method that has several downsides. First of all, it requires support for the :before CSS selector and the use of an escape sequence for UNICODE characters. Neither IE6-7 nor certain versions of Webkit provide this support.
Another downside is that you have to use a seperate HTML tag for each icon, with each tag corresponding to one character from the icon font. Displaying several icons within HTML tag is not possible with method 7, unlike with other methods.
Other methods have their own downsides, though. Methods 1, 3 and 5 require you to copy-paste the character from a cheat sheet or use means to put the character itself within your code. Your code editor may not be capable of displaying the character or it may display a different character from the one in your icon font if the icon font uses a non-standard mapping that character.
Methods 2, 4 and 6 do not require you to copy-paste the character, however it makes your code less readable by humans and makes any changes to the code more prone to human error. Also, as you will need to look up the HTML-entity code for each of the icons you want to use or you'll need to memorize them. While the same obviously applies to the classes used in method 7 as well, those classes are much easier to memorize than an HTML entity code.

Markdownize an Emacs buffer

I am looking for a Markdown variant of the Htmlize addon.
The idea is simple: say, you wish to publish code to a GIST on GitHub, or any place which supports Markdown. You type your code in Emacs, do M-x markdownize-buffer and you get a new buffer containing the full Markdown markup.
Anybody knows if such an addon exists?
Markdown isn't powerful enough to generate span classes. To do this, you need to drop down into pure HTML.
Htmlize will generate a syntax-highlighted version of your code based on your current Emacs theme settings. Take a look at the generated markup: it does this by generating both DOM elements and styles to replicate your current syntax highlighting:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<!-- Created by htmlize-1.36 in css mode. -->
<html>
<head>
<title>sha1test.rb</title>
<style type="text/css">
<!--
body {
color: #eeeeec;
background-color: #2e3434;
}
.comment {
/* font-lock-comment-face */
color: #888a85;
}
.comment-delimiter {
/* font-lock-comment-delimiter-face */
color: #888a85;
}
/* [...] */
-->
</style>
</head>
<body>
<pre>
require <span class="string">'digest/sha1'</span>
<span class="type">SLICE_SIZE</span> = 20
<span class="keyword">def</span> <span class="function-name">myhash</span>(input)
<span class="type">Digest</span>::<span class="type">SHA1</span>.hexdigest(input).slice(0,<span class="type">SLICE_SIZE</span>)
<span class="keyword">end</span>
hashmap = {}
inputs = 0
unique_inputs = 0
<span class="type">ARGF</span>.each <span class="keyword">do</span> |line, idx|
[...]
</body>
</html>
Markdown can't replicate the kind of information here. It's good for translating semantic plain-text into semantic markup (i.e. headers should turn into H1 or H2, **text** should generate <strong>text</strong>, etc.). Which lines of your Emacs buffer are headers? Which should translate into <em> tags?

How to search and correct html tags and attributes?

In my application, I have to fix all the closing tags of the <img> tag as shown below. Instead of closing the <img> with a >, it should close with />.
Is there any easy way to search for all the <img> in this text and fix the > ?
(If it is closed with a /> already then there is no action required).
Other question, if there is no "width" or "height" to the <img> specified, what is the best way to solve the issue?
Download all the images and get the corresponding attributes of width and height, then add them back to the string?
The correct <img> tag is the one that closes with /> and have the valid width & height.
<img align="left" hspace="5" width="150" src="http://s3.dlnws.com/images/products/images/749000/749208-large" alt="" title="">
Apple today unleashed a number of goodies, including giving iMacs and Mac Pros more oomph with new processors and increased storage options. We have those deals today, along with many more items for the Mac lover. Along with the refreshed line of iMacs and Mac Pros, we’ll also look at a number of software deals [...]
<p><img src="http://feedads.g.doubleclick.net/~a/DL_-gOGSR1JMzKDbErt1EG3re3I/0/di" border="0" ismap><br>
<img src="http://feedads.g.doubleclick.net/~a/DL_-gOGSR1JMzKDbErt1EG3re3I/1/di" border="0" ismap></p><img src="http://feeds.feedburner.com/~r/cultofmac/bFow/~4/Mq5iLOaT50k" height="1" width="1">
Regular expressions will solve the problem with closing your tags correctly - make sure whatever you're using to edit your code supports regular expression searching, and then search for something like this (assuming that all of your unclosed image tags end with a ">):
\<img (.*?)"\>
and replace it with this:
<img $1" />
As far as the bit about the width and height attributes, if you're trying to display the images at their regular width and height, you shouldn't need them. The only time you should need width and height is if you're displaying the image at a different size than the original image's size, which doesn't appear to be the case here.